Skip to content

Instantly share code, notes, and snippets.

@wehub
Created April 21, 2017 16:35
Show Gist options
  • Select an option

  • Save wehub/fdd49eb91ed61dc1526fe3e955721cd0 to your computer and use it in GitHub Desktop.

Select an option

Save wehub/fdd49eb91ed61dc1526fe3e955721cd0 to your computer and use it in GitHub Desktop.
<?php
// WePay PHP SDK - http://git.io/mY7iQQ
require 'wepay.php';
// application settings
$account_id = 123456789; // the merchant's account_id
$client_id = 9543125;
$client_secret = "1a3b5c7d9";
$access_token = "STAGE_8a19aff55b85a436dad5cd1386db1999437facb5914b494f4da5f206a56a5d20"; // the merchant's access_token
$preapproval_id = "12345"; // The preapproval_id from step 1
// change to useProduction for live environments
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
// create the checkout
$response = $wepay->request('checkout/create', array(
'account_id' => $account_id,
'amount' => '19.99',
'currency' => 'USD',
'short_description' => 'Payment for test project',
'type' => 'goods',
'payment_method' => {
'type' => 'preapproval',
'preapproval' => {
'id' => $preapproval_id
}
}
));
// display the response
print_r($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment