I am using the PHP Paypal SDK: https://github.com/paypal/PayPal-PHP-SDK
The PayPal REST API being sent via the PHP SDK return and the request for incoming JSON requests are not mapped to the API request
Continue https://stackoverflow.com/questions/39827032/paypal-how-to-get-payment-id-on-basis-of-transaction-id
Based on an existing transaction identifier, you need to get a payment identifier
I tried below code
require __DIR__ . '/bootstrap.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\CreditCard;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Api\PaymentDetail;
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$transaction = new PaymentDetail(
'{
"method" : "CASH",
"date" : "2014-07-06 03:30:00 PST",
"note" : "Cash received."
}'
);
$transaction->setTransactionId("3NT32794KF4824703");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setTransactions(array($transaction));
$request = clone $payment;
try {
$payment->create($apiContext);
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getData();
}
echo "<pre>";
print_r($payment);
exit;
When I run the code above, it gives below error view
{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"aa8bfa2a41f1f"}
PayPal\Api\Payment Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[intent] => sale
[payer] => PayPal\Api\Payer Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[payment_method] => paypal
)
)
[transactions] => Array
(
[0] => PayPal\Api\PaymentDetail Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[method] => CASH
[date] => 2014-07-06 03:30:00 PST
[note] => Cash received.
[transaction_id] => 3NT32794KF4824703
)
)
)
)
)
How to solve the above error? Please direct
Reply from Paypal Technical Support
dev , TransactionId PaymentId. PaymentId - API REST. REST API .
REST API, API [NVP/SOAP] DoEC API . , , .
, REST API , PaymentId.
: , . X . .