PayPal Rest API Create Payment Does Not Return Sale ID

I am trying to make a credit card payment using the PayPal rest API (sandbox). Here is the code:

$payment = new Payment(); $payment->setIntent('sale'); ... try { $payment->create($this->apiContext); $saleId = $payment->getTransactions()[0]->getRelatedResources()[0]->getSale()->getId(); } catch (PayPalConnectionException $ex) { ... } 

Sends the following JSON:

{"experience_profile_id": "XX-XXXX-XXXX-XXXX-XXXX", "intention": "sale", "Payer": {"payer_info": {"first_name": "Jim", "last_name": "Smith" , "email": " someone@somewhere.com ", "phone": "}," PAYMENT_METHOD ":" CREDIT_CARD "," funding_instruments ": [{" CREDIT_CARD ": {" first_name ":" Jim "" last_name ": "Smith", "number": "XXXXXXXXXXXXX4487", "type": "visa", "expire_month": "06", "expire_year": "2020", "cvv2": "123", "billing_address": {" line1 ":" 123 Test Street "," line2 ":" "," city ":" Test City "" state ":" "," postal_code ":" XXXX XXX "" country_code ":" GB "}}}] }, "transaction": [{"amount": {"currency": "GBP", "total": "13.50", "detail": {"delivery": "3.50", "tax": "1.67", "subtotal": "8.33"}}, "item_list": {"elements": [{"name": "T-shirt black Small "currency": "GBP", "quantity": "1", "s": "abc123", "price": "8.33"}], "shipping_address": {"recipient_name": "Jim Smith", " line1 ":" 123 Test Street "," line2 ":" "," city ":" Test City "," state ":" Some State "," postal_code ":" XXXX XXX "" country_code ":" GB "} }, "Description": "Payment details", "INVOICE_NUMBER": "XXXXX"}]}

This worked fine until recently, but now it returns nothing for the corresponding resources. here json i come back:

{"identifier": "PAY-XXXXXXXXXXXXXXXXXXXXXX", "create_time": "2016-06-20TT11: 45: 28Z", "update_time": "2016-06-20T11: 45: 28Z", "state": "created" , "intention": "sale", "payer": {"PAYMENT_METHOD": "CREDIT_CARD", "funding_instruments": [{"CREDIT_CARD": {"Type": "visa", "number": "xxxxxxxxxxxx4487" "expire_month ":" 6 "," expire_year ":" 2020 "," first_name ":" Jim "," last_name ":" Smith "," billing_address ": {" line1 ":" 123 Test Street "," city ":" Test City "," postal_code ":" XXXX XXX "" country_code ":" GB "}}}]}," deal ": [{" quantity ": {" total ":" 13.50 "," currency ":" GBP "," detail ": {" subtotal ":" 8.33 "," tax ":" 1.67 "," delivery ":" 3.50 "}}," description ":" Payment details "," item_list ": {" items ": [{" name ":" T-Shirt Black Small "" Code ":" abc123 "," c yen ":" 8.33 "," currency ":" GBP "," quantity ":" 1 "}]," shipping_address ": {" recipient_name ":" Jim Smith "," line1 ":" 123 Test Street " , "city": "Test City", "state": "Some State" "postal_code": "XXXX XXX", "country_code": "GB"}}, "related_resources": []}], "links": [{"href": " https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXXXXXXXXXXXXXXXXXXXXXX ", "rel": "I", "method": "GET"}]}

Please note that I am using version 1.7.2 of the API, and I recently updated it to PHP 7.

I would be grateful if anyone could explain what I am doing wrong.

thanks

+5
source share
1 answer

Finally, I managed to get this job, although not through my own fault. It looks like my sandbox buyer account is no longer working. I found the following document:

https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePayment.php

This worked well, so I played the game in a different place, and the only thing that helped solve the problem was to use the card data in my example. I have already spent a lot of time on this problem, so I agree that it works fine, and I hope I will not encounter any problems during production.

0
source

All Articles