Skip to content

Instantly share code, notes, and snippets.

@vandershraaf
Created August 26, 2015 21:22
Show Gist options
  • Save vandershraaf/c09c70842de17231aee6 to your computer and use it in GitHub Desktop.
Save vandershraaf/c09c70842de17231aee6 to your computer and use it in GitHub Desktop.
Adaptive payment with secondary receiver as fee payer
<?php
require_once('PPBootStrap.php');
require_once('Common/Constants.php');
$receiver = array();
// Receiver 1
$receiver[0] = new Receiver();
$receiver[0] -> email = "[email protected]";
$receiver[0] -> amount = 4.00;
$receiver[0] -> primary = "true";
// Receiver 2
$receiver[1] = new Receiver();
$receiver[1] -> email = "[email protected]";
$receiver[1] -> amount = 3.75;
$receiver[1] -> primary = "false";
$receiverList = new receiverList($receiver);
$payRequest = new PayRequest(new RequestEnvelope("en_US"), "PAY", "http://google.com",
"USD", $receiverList, "http://yahoo.com");
$payRequest->feesPayer = "SECONDARYONLY";
$payRequest->ipnNotificationUrl = "http://google.com";
$payRequest->memo = "THIS IS A TEST";
$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
/* wrap API method calls on the service object with a try catch */
$response = $service->Pay($payRequest);
} catch(Exception $ex) {
require_once 'Common/Error.php';
exit;
}
print_r($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment