I'm trying to use Paypal's adaptive payment API and it’s not easy to switch it to production. Everything works as expected in sandbox mode, and I get the correct answer, but when I switch to my live APP ID, it does not work.
These are the configuration values that I use for the sandbox
PayPal URL : https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=[TOKEN_HERE] Application ID : APP-80W284485P519543T
These values work for me in sandbox mode. But when I switch to lower production values, it stops working
PayPal URL : https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey=[TOKEN_HERE] Application ID : [ACTUAL APP ID] This is what I mean by stops working.
- In production mode, the application receives the key "paykey"
- Adds it to the Paypal URL and then redirects it to its website
- The load on the site, I get the following message
This transaction has already been approved. Please visit your PayPal Account Overview to see the details
The final URL ends - https://ic.paypal.com/webapps/adaptivepayment/flow/payinit?execution=e6s1
Screenshot - http://screencast.com/t/28qJZ9CIk
There is also a “Return” button, and when I click on it, I get to a different site each time (it looks like I'm going to random failUrls).
I have included the code that I use below
$payRequest = new PayRequest(); $payRequest->actionType = "PAY"; $payRequest->cancelUrl = $cancelURL; //my success and fail urls $payRequest->returnUrl = $returnURL; $payRequest->clientDetails = new ClientDetailsType(); $payRequest->clientDetails->applicationId = $this->config['application_id']; $payRequest->clientDetails->deviceId = $this->config['device_id']; $payRequest->clientDetails->ipAddress = $this->CI->input->ip_address(); $payRequest->currencyCode = $currencyCode; $payRequest->requestEnvelope = new RequestEnvelope(); $payRequest->requestEnvelope->errorLanguage = "en_US"; //I set the receiver and the amounts. I also define that these are digital goods payments $receiver1 = new receiver(); $receiver1->email = $opts['receiver_email']; $receiver1->amount = $opts['amount']; $receiver1->paymentType = 'DIGITALGOODS'; $payRequest->receiverList = new ReceiverList(); $payRequest->receiverList = array($receiver1); //Then I make the call $ap = new AdaptivePayments(); $response = $ap->Pay($payRequest); if(strtoupper($ap->isSuccess) == 'FAILURE') { log_message('error', "PAYMENT_FAIL : " . print_r($ap->getLastError(), true)); return false; } else { if($response->paymentExecStatus == "COMPLETED") { header("Location: " . $this->config['success_url']); exit; } else { $token = $response->payKey; $payPalURL = $this->config['paypal_redirect_url'] . 'paykey='.$token; header("Location: ".$payPalURL); exit; } }
This is code taken from their approximate implementation, so I’m not quite sure what is going on here. Other information that may be relevant.
EDIT
I have included a sample URL with an attached key for payment
https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-0H388650F08226841
php paypal paypal-adaptive-payments
Johnp
source share