I use the SetExpressCheckout method, I get token successfully, then I pass it by reference so that the user can make a payment:

https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<? echo $token[1]; ?> 

Token creation script:

 $paypal_create_token = post('https://api-3t.paypal.com/nvp', array( 'params' => array( 'USER' => $paypal_config['user'], 'PWD' => $paypal_config['password'], 'SIGNATURE' => $paypal_config['sign'], 'METHOD' => 'SetExpressCheckout', 'VERSION' => $paypal_config['version'], 'REQCONFIRMSHIPPING' => 0, 'NOSHIPPING' => 1, 'SOLUTIONTYPE' => 'Sole', 'LANDINGPAGE' => 'Billing', 'LOGOIMG' => $protocol.'://'.$host.'/images/logo197x40.png?'.$time, 'HDRIMG' => $protocol.'://'.$host.'/images/logo.png?'.$time, 'BRANDNAME' => mb_strtoupper($host), 'PAYMENTREQUEST_0_AMT' => $amount, 'PAYMENTREQUEST_0_ITEMAMT' => $amount, 'L_PAYMENTREQUEST_0_AMT0' => $amount, 'L_PAYMENTREQUEST_0_NAME0' => $description, 'PAYMENTREQUEST_0_INVNUM' => $order_id, 'L_PAYMENTREQUEST_0_NUMBER0' => $order_id, 'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'RUB', 'EMAIL' => $orders_info['email'], 'RETURNURL' => $paypal_config['success_url'].'?order_id='.$order_id.'&order_hash='.$order_hash, 'CANCELURL' => $paypal_config['fail_url'].'?order_id='.$order_id.'&order_hash='.$order_hash, ) ) ); $paypal_create_token_content = $paypal_create_token['content']; preg_match('/TOKEN\=(.*?)\&/', $paypal_create_token_content, $token); // получаем token 

As a result, everything is as it should be, the bill payment page appears:

enter image description here

And when I click on Continue , everything goes well, but the funds from the card are not debited, as if the test mode is set, although the sandbox link is not used. For the sake of interest, I decided to connect my PayPal account to my API data for one payment service, after payment there, the funds were written off from the card.

And yet, sometimes the bank requests an SMS code to confirm the payment, but still nothing is charged. Oddities.

What is the problem? I do not use the sandbox link, but still such a misfortune. I suspect that I passed something wrong into the parameters.

  • Or maybe it would be better to ask first in support PayPal? They would be able to check how the payment goes, and if it goes as a test, they would suggest what is happening. Suddenly you have a problem not in the code, but in the stick settings? :) - intro94
  • @ intro94, if there was a problem in setting up the stick, then the payment from a third-party payment service with my data would not work. Ради интереса решил подключить свой аккаунт PayPal к одному платежному сервису, там после оплаты, с карты средства списались. - ModaL
  • But is the acceptance of payments not separate from the "personal wallet" configured? I did not understand the stick, as its support in my country is zero, but usually the reception of payments in all systems is configured separately (I know from the example of WM, robocash, w1, kiwi and many others). - intro94
  • @ intro94, digiseller service allows you to specify your PayPal data and accept payment through your PayPal account. - ModaL
  • one
    @ intro94, yeah, I'll write. I googled many such topics, but there were no answers anywhere. Maybe I will be the first: D - ModaL

1 answer 1

Everything turned out to be very simple, I did not confirm the transaction after the redirect to the successful payment page, to which the GET request sent the parameters token and PayerID .

You need to confirm the transaction as follows:

 post('https://api-3t.paypal.com/nvp', array( 'params' => array( 'USER' => $paypal_config['user'], 'PWD' => $paypal_config['password'], 'SIGNATURE' => $paypal_config['sign'], 'METHOD' => 'DoExpressCheckoutPayment', 'VERSION' => $paypal_config['version'], 'PAYMENTREQUEST_0_AMT' => $amount, 'PAYMENTREQUEST_0_ITEMAMT' => $amount, 'L_PAYMENTREQUEST_0_AMT0' => $amount, 'PAYMENTREQUEST_0_INVNUM' => $order_id, 'L_PAYMENTREQUEST_0_NUMBER0' => $order_id, 'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'RUB', 'token' => ((isset($_GET['token'])) ? $_GET['token'] : ''), 'payerid' => ((isset($_GET['PayerID'])) ? $_GET['PayerID'] : '') ) ) ); 

Thank you so much for helping a member of stackoverflow English - https://stackoverflow.com/a/37434689/5184005