[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/wepay/iframe_demoapp/ -> list_accounts.php (source)

   1  <?php
   2  /**
   3   * This PHP script helps you find your account_id
   4   *
   5   */
   6  
   7  
   8  
   9  /**
  10   * Put your API credentials here:
  11   * Get these from your API app details screen
  12   * https://stage.wepay.com/app
  13   */
  14  $client_id = "PUT YOUR CLIENT_ID HERE";
  15  $client_secret = "PUT YOUR CLIENT_SECRET HERE";
  16  $access_token = "PUT YOUR ACCESS TOKEN HERE";
  17  
  18  /** 
  19   * Initialize the WePay SDK object 
  20   */
  21  require  '../wepay.php';
  22  Wepay::useStaging($client_id, $client_secret);
  23  $wepay = new WePay($access_token);
  24  
  25  /**
  26   * Make the API request to get a list of all accounts this user owns
  27   * 
  28   */
  29  try {
  30      $accounts = $wepay->request('/account/find');
  31  } catch (WePayException $e) { // if the API call returns an error, get the error message for display later
  32      $error = $e->getMessage();
  33  }
  34  
  35  ?>
  36  
  37  <html>
  38      <head>
  39      </head>
  40      
  41      <body>
  42          
  43          <h1>List all accounts:</h1>
  44          
  45          <p>The following is a list of all accounts that this user owns</p>
  46          
  47          <?php if (isset($error)): ?>
  48              <h2 style="color:red">ERROR: <?php echo $error ?></h2>
  49          <?php elseif (empty($accounts)) : ?>
  50              <h2>You do not have any accounts. Go to <a href="https://stage.wepay.com.com">https://stage.wepay.com</a> to open an account.<h2>
  51          <?php else: ?>
  52              <table border="1">
  53                  <thead>
  54                      <tr>
  55                          <td>Account ID</td>
  56                          <td>Account Name</td>
  57                          <td>Account Description</td>
  58                      </tr>
  59                  </thead>
  60                  <tbody>
  61                  <?php foreach ($accounts as $a): ?>
  62                      <tr>
  63                          <td><?php echo $a->account_id ?></td>
  64                          <td><?php echo $a->name ?></td>
  65                          <td><?php echo $a->description ?></td>
  66                      </tr>
  67                  <?php endforeach;?>
  68                  </tbody>
  69              </table>
  70          <?php endif; ?>
  71      
  72      </body>
  73      
  74  </html>


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1