Skip to content

Instantly share code, notes, and snippets.

@SeraphimSerapis
Created February 10, 2013 12:12
Show Gist options
  • Save SeraphimSerapis/4749391 to your computer and use it in GitHub Desktop.
Save SeraphimSerapis/4749391 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Adaptive Payments</title>
</head>
<body>
<p>This example uses parallel payments:</p>
<?php
// Include the needed files
require_once 'lib/AdaptivePayments.php';
require_once 'web_constants.php';
// Redirects after events
$return = 'http://myReturnUrl.de';
$cancel = 'http://cancelUrl.de';
$details = new ClientDetailsType();
$details->applicationId = APPLICATION_ID;
$details->deviceId = DEVICE_ID;
$details->ipAddress = IP_ADDRESS;
$envelope = new RequestEnvelope();
$envelope->errorLanguage = 'en_US';
// Create the request
$request = new PayRequest();
$request->actionType = "PAY";
$request->cancelUrl = $cancel;
$request->returnUrl = $return;
$request->currencyCode = 'EUR';
$request->requestEnvelope = $envelope;
$request->clientDetails = $clientDetails;
// Set sender & receiver(s)
$request->senderEmail = $_GET['sender'];
echo "<p>Sender: ".$_GET['sender']."</p>\n";
$receiver1 = new receiver();
$receiver1->email = $_GET['receiver1'];
$receiver1->amount = $_GET['amount1'];
echo "<p>Recever 1: ".$_GET['amount1']."€ for ".$_GET['receiver1']."</p>\n";
$receiver2 = new receiver();
$receiver2->email = $_GET['receiver2'];
$receiver2->amount = $_GET['amount2'];
echo "<p>Receiver 2: ".$_GET['amount2']."€ for ".$_GET['receiver2']."</p>\n";
$request->receiverList = array($receiver1, $receiver2);
// Create new service wrapper and handle payment
$ap = new AdaptivePayments();
$response = $ap->Pay($request);
if(strtoupper($ap->isSuccess) == 'FAILURE') {
echo "Something went wrong here!\n";
} else {
$key = $response->payKey;
echo "Transaction done! PayKey: $key\n";
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment