I am using the PayPal Pay API, with Adaptive (Chained) Payments. I am trying to forward a user to paypal and afterwards back to my predefined return_url.
The problem is: I need to have a PayKey within my return-url. Reason for that: I need to call a PaymentDetail API to review the payment within the return_url. And, I don't want to use IPN since I need the validation with some token right on my return Url.
The problem I have is: The PayKey is beeing generated with all the parameters, including the return-url (hence after I build the actual array from which I get my $response from. I can't put the PayKey in the return-Url since it's not generated at this point yet.
//Create request payload with minimum required parameters
$bodyparams = array ("requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"currencyCode" => "USD",
"cancelUrl" => "http://www.paypal.com",
"returnUrl" => $return_url . "&payKey=${payKey}", **// Does not work - PAYKEY NEEDED TO ADD???**
"receiverList.receiver(0).email" => "account1#hotmail.com", //TODO
"receiverList.receiver(0).amount" => $price, //TODO
"receiverList.receiver(0).primary" => "true", //TODO
"receiverList.receiver(1).email" => "account2#hotmail.com", //TODO
"receiverList.receiver(1).amount" => $receiver_gets, //TODO
"receiverList.receiver(1).primary" => "false" //TODO
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38)); // Generates body data
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//set url to approve the transaction
$payPalURL = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" . $kArray["payKey"]; **// Here it works fine, since the PayKey is generated at this point ...**
//print the url to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
echo '<p>' . $payPalURL . '</p>';
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
Can somebody help?
I was at this for ages too myself. I finally figured it out. Paypal docs are hard to follow. I found the answer in the paypal adaptive pdf guide which I downloaded. It specifies to add payKey=${payKey} to the end of your return_url. I just tried it there and the paypal get request to my return url now contains the paykey.
So in rails which I'm using the return_url looks like this. Writing a php variable (I think) into the url as instructed by the guide
:return_url => "http://***********.com/paypal-return?payKey=${payKey}"
It seems that you're missing a step in the sequence.
The first step is to send your transaction parameters to
https://svcs.paypal.com/AdaptivePayments/Pay&yourtransactionparameters=blah
[sandbox]https://svcs.sandbox.paypal.com/AdaptivePayments/Pay&yourtransactionparameters=blah
You'll get the paykey in this response.
Once you've retrieved the paykey successfully, you'll call:
https://www.paypal.com/webscr&cmd=_ap-payment&paykey=xxxx
[sandbox]https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=xxxx
In the second call, the payKey represents the rest of your transaction so you don't have to build another giant query string.
Change your code for:
//Create request payload with minimum required parameters
$bodyparams = array ("requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"currencyCode" => "USD",
"cancelUrl" => "http://www.paypal.com",
"returnUrl" => $return_url . '&payKey=${payKey}', **// That's right**
"receiverList.receiver(0).email" => "account1#hotmail.com", //TODO
"receiverList.receiver(0).amount" => $price, //TODO
"receiverList.receiver(0).primary" => "true", //TODO
"receiverList.receiver(1).email" => "account2#hotmail.com", //TODO
"receiverList.receiver(1).amount" => $receiver_gets, //TODO
"receiverList.receiver(1).primary" => "false" //TODO
);
PHP interprets ${payKey} as variable between the double quotes.
Change double quotes (") for simple quotes (')
Apparently you can embed dynamic variables in the return URL: https://www.x.com/thread/49785
Unfortunately, {$payKey} is invalid. so it must be $paykey or $pay_key. Good luck!
Related
I am validating the email address using the following code :
$url = trim("https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus");
$API_UserName = "";
$API_Password = "";
$API_Signature = "";
$API_AppID = "";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"emailAddress" => $email, // email to be validate
"matchCriteria" => "NONE"
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT:" . $API_ResponseFormat . "\r\n"
));
$ctx = stream_context_create($params); //create stream context
$fp = #fopen($url, "r", false, $ctx); //open the stream and send request
$response = stream_get_contents($fp); //get response
//check to see if stream is open
if ($response === false)
{
throw new Exception("php error message = " . "$php_errormsg");
}
fclose($fp); //close the stream
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal)
{
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
if( $kArray["responseEnvelope.ack"] == "Success")
{
// do nothing
}
else
{
// error
}
However this code works for sandbox account. What changes do i make to validate the paypal account.
Any help will be appreciated.
https://svcs.sandbox.paypal.com/AdaptiveAccounts/GetVerifiedStatus
this is sandbox link change it to live account link. Thats it.
Three Things
GetVerifiedStatusAPI requires your adaptive payment application to be approved with "getverifiedstatus" feature enabled.
You will need to submit the application(with GetVerifiedStatus checkbox enabled, get the application approved at www.paypal-apps.com to get the APP-ID
Change the endpoint to https://svcs.paypal.com/AdaptiveAccounts/GetVerifiedStatus
P.S Your account should be Business/premier Verified account
I'm trying to use the PayPal AdaptivePayments API and I'm trying to set the url for paypal IPN which is supposed to be "ipnNotificationUrl" but I don't know where to add it in the request.
Here is my code:
ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
/*
*******************************************************************
PayPal API Credentials
Replace <API_USERNAME> with your API Username
Replace <API_PASSWORD> with your API Password
Replace <API_SIGNATURE> with your Signature
*******************************************************************
*/
//PayPal API Credentials
$API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO
$API_Password = "1287090610"; //TODO
$API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO
//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload with minimum required parameters
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"currencyCode" => "USD",
"cancelUrl" => "http://www.paypal.com",
"returnUrl" => "http://www.paypal.com",
"receiverList.receiver(0).email" => "r_1_1266351681_biz#paypal.com", //TODO
"receiverList.receiver(0).amount" => "20.0", //TODO
"receiverList.receiver(1).email" => "r_2_1266352427_biz#paypal.com", //TODO
"receiverList.receiver(1).amount" => "30.0" //TODO
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//set url to approve the transaction
$payPalURL = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" . $kArray["payKey"];
//print the url to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
echo '<p>' . $payPalURL . '</p>';
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
/*
//optional code to redirect to PP URL to approve payment
If ( $kArray["responseEnvelope.ack"] == "Success") {
header("Location:". $payPalURL);
exit;
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
*/
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
Thanks a lot!
It should be in $bodyparms array:
"returnUrl" => "http://www.paypal.com",
"ipnNotificationUrl" => "http://www.baseem.com/ipnhandler.php",
I am currently working on integrating paypal's chained payment method into magento.
https://cms.paypal.com/ca/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APIntro
The payment flow would be:
buyer pays seller's paypal account -> pp adaptive payment gateway -> 85% goes to seller's paypal, 15% goes to site's default paypal account (buyer not aware of this split).
I already have the api function take takes 2 paypal accounts (seller's & site's default), and payment amount, and am looking to integrate this.
Has anyone integrated adaptive payments before, or point me to where I should integrate this logic? Would I overwrite one of the functions in /app/code/core/Mage/paypal ?
I basically need to get the total cost in the current shopping cart, and the paypal email of the current store, and pass that over to my function.
First of all you need to create a seprate payment method for magento i would suggest to create a payment module for it after that you need to signup in to the paypal sandbox account . i am attaching sample code for adaptive payment integration also some useful links for the flow how it will work
ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$sandbox="";
$API_AppID = XXXXXXXXXXXXXXXXXXX;//your adaptive payment app Id
//value for check sandbox enable or disable
$sandboxstatus=1;
if($sandboxstatus==1){
$sandbox="sandbox.";
$API_AppID="APP-80W284485P519543T";
}
$url = trim("https://svcs.".$sandbox."paypal.com/AdaptivePayments/Pay");
//PayPal API Credentials
$API_UserName = XXXXXXXXXXXXXXXXXXX;//TODO
$API_Password = XXXXXXXXXXXXXXXXXXX;//TODO
$API_Signature = XXXXXXXXXXXXXXXXXXX;//TODO
//Default App ID for Sandbox
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
$bodyparams = array (
"requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"currencyCode" => "USD",//currency Code
"cancelUrl" => "",// cancle url
"returnUrl" => "paymentsuccess",//return url
"ipnNotificationUrl" => "paymentnotify"//notification url that return all data related to payment
);
$finalcart=array(
array('paypalid'=>"partner1",'price'=>50),
array('paypalid'=>"partner2",'price'=>50),
array('paypalid'=>"partner3",'price'=>50),
array('paypalid'=>"partner4",'price'=>50),
array('paypalid'=>"partner5",'price'=>50)
);
$i=0;
foreach($finalcart as $partner){
$temp=array("receiverList.receiver($i).email"=>$partner['paypalid'],"receiverList.receiver($i).amount"=>$partner['price']);
$bodyparams+=$temp;
$i++;
}
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//set url to approve the transaction
$payPalURL = "https://www.".$sandbox."paypal.com/webscr?cmd=_ap-payment&paykey=" . $kArray["payKey"];
//print the url to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
echo '<p><a id="paypalredirect" href="' . $payPalURL . '"> Click here if you are not redirected within 10 seconds...</a> </p>';
echo '<script type="text/javascript">
function redirect(){
document.getElementById("paypalredirect").click();
}
setTimeout(redirect, 2000);
</script>';
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
you may ignore the module flow but you can follow the steps for setting up the sandbox account for paypal payment hope it will help
You're probably going to need to write a completely new payment module for that. From what I've seen (and I'll admit it's been a little bit since I've looked at it in detail) the current PayPal integration in Magento does not support chained payments.
You could still extend the existing PayPal module(s) if you want, but you'll need to write the API requests to handle the adaptive payments calls accordingly. Again, there aren't any existing functions that you would simply override in your extended module. You'll just need to create your own from the start.
If the latest version of Magento added some adaptive payments then I could be wrong on that. If that's the case, you'd probably see something in the /paypal directory directly referring to it, and you can study the functions in there to see what you could override with your own. That said, if they've already adaptive payments included as a payment module then you really shouldn't need to customize it in code.
I am at my wits end trying to get this work but cant understand it. I have to use Adaptive payments in a webapp which is created using cakephp framework. I have API credentials like API Username, Password and Signature. But the main problem i am facing is how to call the Pay API to get the API key which is the first thing required to make this work. I am new to this so i dont have much knowledge about this and after lot digging in google i am asking this question. Can someone please give steps for using Adaptive Payments..
Thanks in advance for your help!
You have to follow only three steps:
1- You send a PayRequest message to PayPal
{"returnUrl":"http://example.com/returnURL.htm", \ "requestEnvelope":{"errorLanguage":"en_US"},"currencyCode":"USD", \ "receiverList":{"receiver":[{"email":"david#example.com", \
"amount":"10.00",}]},"cancelUrl":"http://example.com/cancelURL.htm",\ "actionType":"PAY"}
2- You receive a response with a pay key.
{"responseEnvelope":\ {"timestamp":"2009-10-06T14:30:39.383-07:00","ack":"Success",\ "correlationId":"cfe8f8783f1d3","build":"DEV"},\ "payKey":"AP-17266198048308436","paymentExecStatus":"CREATED"}
3- You must redirect the sender’s browser to PayPal to approve the payment.
This would be an example code for step 1 (it works on my local server):
<?php
//turn php errors on
ini_set("track_errors", true);
//set PayPal Endpoint to sandbox
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
$api_appid = 'APP-80W284485P519543T'; // para sandbox
//PayPal API Credentials
$API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO
$API_Password = "1287090610"; //TODO
$API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO
$receiver_email = "fake#email.com"; //TODO
$amount = 25; //TODO
//Default App ID for Sandbox
$API_AppID = "APP-80W284485P519543T";
$API_RequestFormat = "NV";
$API_ResponseFormat = "NV";
//Create request payload with minimum required parameters
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
"actionType" => "PAY",
"cancelUrl" => "http://cancelUrl",
"returnUrl" => "http://returnUrl",
"currencyCode" => "EUR",
"receiverList.receiver.email" => $receiver_email,
"receiverList.receiver.amount" => $amount
);
// convert payload array into url encoded query string
$body_data = http_build_query($bodyparams, "", chr(38));
try
{
//create request and add headers
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
"X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
));
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
foreach ($kArray as $key =>$value){
echo $key . ": " .$value . "<br/>";
}
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
?>
You have many examples here: https://www.x.com/developers/paypal/documentation-tools/paypal-code-samples
I am basically trying to use the PAY call of Adaptive Payments to programmatically and immediately send funds from my own paypal account to other accounts. According to the documentation, so long as I specify the senderEmail (my own paypal address, used to set up the Adaptive Payments), this should work verbatim.
However, when I make the call, I always get result "CREATED" instead of "COMPLETED". Created means the system still wants me to manually log into PayPal and approve the payments. I really need these payments to occur automatically on the spot. Any help would be appreciated.
Here is my request string:
currencyCode=USD&
returnUrl=http%3A%2F%2Fwww.website.com%2F&
actionType=PAY&
cancelUrl=http%3A%2F%2Fwww.website.com%2F&
receiverList.receiver%280%29.email=receiver%40gmail.com&
receiverList.receiver%280%29.amount=1.00&
requestEnvelope.senderEmail=me%40gmail.com&
clientDetails.deviceId=mydevice&
clientDetails.ipAddress=127.0.0.1&
clientDetails.applicationId=APP-ZZZZZZZZZZZZZ&
requestEnvelope.errorLanguage=en_US&
memo=memo&
feesPayer=EACHRECEIVER&
ipnNotificationUrl=http%3A%2F%2Fwww.website.com%2Fpay.php
And here is the response from PayPal:
[responseEnvelope.timestamp] => 2012-03-01T19:09:57.290-08:00
[responseEnvelope.ack] => Success
[responseEnvelope.correlationId] => 71efd416a2100
[responseEnvelope.build] => 2486531
[payKey] => AP-ZZZZZZZZZZZZZZZ
[paymentExecStatus] => CREATED
Forget everything I said earlier. The problem isn't an inconsistency between Sandbox and Live either, but rather a wrong parameter for 'senderEmail'.
Simply change:
requestEnvelope.senderEmail=me#gmail.com&
To:
senderEmail=me#gmail.com&
For example, the following returns a 'COMPLETED' implicit payment.
<?php
function AdaptiveCall($bodyparams, $method, $payKey) {
try
{
$body_data = http_build_query($bodyparams, "", chr(38));
$url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/".$method."");
$params = array("http" => array(
"method" => "POST",
"content" => $body_data,
"header" => "X-PAYPAL-SECURITY-USERID: xxxxxxxxx\r\n" .
"X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxxxxx\r\n" .
"X-PAYPAL-SECURITY-PASSWORD: xxxxxxx\r\n" .
"X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T\r\n" .
"X-PAYPAL-REQUEST-DATA-FORMAT: NV\r\n" .
"X-PAYPAL-RESPONSE-DATA-FORMAT: NV\r\n"
)
);
//create stream context
$ctx = stream_context_create($params);
//open the stream and send request
$fp = #fopen($url, "r", false, $ctx);
//get response
$response = stream_get_contents($fp);
//check to see if stream is open
if ($response === false) {
throw new Exception("php error message = " . "$php_errormsg");
}
//close the stream
fclose($fp);
//parse the ap key from the response
$keyArray = explode("&", $response);
foreach ($keyArray as $rVal){
list($qKey, $qVal) = explode ("=", $rVal);
$kArray[$qKey] = $qVal;
}
//print the response to screen for testing purposes
If ( $kArray["responseEnvelope.ack"] == "Success") {
echo "<strong>".$method ."</strong><br>";
foreach ($kArray as $key =>$value){
echo $key . ": " .$value . "<br/>";
}
// Return payKey
global $payKey;
if(!empty($kArray['payKey'])) { $payKey = $kArray['payKey']; return($payKey); }
}
else {
echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " <br/>";
echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " <br/>";
}
}
catch(Exception $e) {
echo "Message: ||" .$e->getMessage()."||";
}
}
//Create Pay body
$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",
'actionType' => 'PAY',
'currencyCode' => 'USD',
'receiverList.receiver(0).email' => 'another_account#domain.tld',
'receiverList.receiver(0).amount' => '1.00',
'senderEmail' => 'xxxxxxxxx',
'memo' => 'Test memo',
'ipnNotificationUrl' => 'http://xxxxxxxx',
'cancelUrl' => 'http://xxxxxxxxx',
'returnUrl' => 'http://xxxxxxxxxx'
);
// Call Pay API
AdaptiveCall($bodyparams, "Pay");
?>
Pay response:
responseEnvelope.timestamp: 2012-03-03T09%3A10%3A22.900-08%3A00
responseEnvelope.ack: Success
responseEnvelope.correlationId: 4bc5cfc4a7514
responseEnvelope.build: 2486531
payKey: AP-1XJ7636763429720C
paymentExecStatus: COMPLETED