Paypal Adaptive Payments works in sandbox mode, but not in production

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.

  • I use adaptive payments to make sure the sender and receiver actually completed the transaction

  • I set the payment type as "DIGITAL PRODUCTS"

EDIT

I have included a sample URL with an attached key for payment

 https://www.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-0H388650F08226841 
+8
php paypal paypal-adaptive-payments
source share
1 answer

I found a problem that gave me all this grief.

The Paypal SDK uses several constants, which are defined in /sdk/lib/Config/paypal_sdk_clientproperties

Constants contain username, password, application_id API URL and some others. They are used directly in the file /sdk/lib/CallerServices,php . Therefore, contrary to what you expect in the API, these values ​​are not entered at the configuration stage, therefore, if you do not notice this file and do not change the values, the above code will not work.

To fix the problem, just update the values ​​defined in the file and you should be good to go.

+4
source share

All Articles