phorge/externals/wepay/iframe_demoapp/list_accounts.php
epriestley 49ef13e876 Add WePay as a one-time payment provider
Summary:
Ref T2787.

I //think// we could also use WePay as a recurring payment provider, but this is somewhat messy (OAuth + requires account) -- basically it's "add a WePay account" instead of "add a credit card".

The WePay checkout workflow is a bit upsell-y but basically reasonable.

I like that their API just has a `request($method, $params)` method instead of 30,000 lines of methods for each request type. I did hit one bug; I'll send a pull for that.

Test Plan: Got as far as the charge callback in testing; the rest isn't implemented for any provider yet.

Reviewers: btrahan, vrana, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D5982
2013-05-21 15:34:46 -07:00

74 lines
1.6 KiB
PHP
Executable file

<?php
/**
* This PHP script helps you find your account_id
*
*/
/**
* Put your API credentials here:
* Get these from your API app details screen
* https://stage.wepay.com/app
*/
$client_id = "PUT YOUR CLIENT_ID HERE";
$client_secret = "PUT YOUR CLIENT_SECRET HERE";
$access_token = "PUT YOUR ACCESS TOKEN HERE";
/**
* Initialize the WePay SDK object
*/
require '../wepay.php';
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
/**
* Make the API request to get a list of all accounts this user owns
*
*/
try {
$accounts = $wepay->request('/account/find');
} catch (WePayException $e) { // if the API call returns an error, get the error message for display later
$error = $e->getMessage();
}
?>
<html>
<head>
</head>
<body>
<h1>List all accounts:</h1>
<p>The following is a list of all accounts that this user owns</p>
<?php if (isset($error)): ?>
<h2 style="color:red">ERROR: <?php echo $error ?></h2>
<?php elseif (empty($accounts)) : ?>
<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>
<?php else: ?>
<table border="1">
<thead>
<tr>
<td>Account ID</td>
<td>Account Name</td>
<td>Account Description</td>
</tr>
</thead>
<tbody>
<?php foreach ($accounts as $a): ?>
<tr>
<td><?php echo $a->account_id ?></td>
<td><?php echo $a->name ?></td>
<td><?php echo $a->description ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php endif; ?>
</body>
</html>