Do not pass PAY-XXX or PAYID-XXX directly into createOrder. Pass the EC-XXX token instead

Echolove
Contributor
Contributor
<!DOCTYPE html>
<head>
<!-- Add meta tags for mobile and IE -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script src="http://static.lushaoming.site/js/jquery.min.js"></script>
<script src="http://static.lushaoming.site/plugin/layer/layer.js"></script>
<script src="https://www.paypal.com/sdk/js?client-id=AUQENKZ17PohBruSngHqpyt9xQtE9bgeqVcxOeo9cWg90by02Oh78ocnZnQ-5kjsutaDBqO-BOrikK-D"></script>
</head>

<body>
<button type="button" id="create_order">Create Order</button>
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>

<!-- Include the PayPal JavaScript SDK -->


<script>
var payId = '';
var isClick = false;
$('#create_order').on('click', function () {
if (isClick) return false;
isClick = true;
$('#create_order').text('Creating...');
$.ajax({
url: '../create_payment.php',
type: 'post',
dataType: 'json',
data: {},
success: function (res) {
$('#create_order').text('Create Order');
isClick = false;
if (res.code == 200) {
payId = res.data.pay_id;
}
}
})
});
// Render the PayPal button into #paypal-button-container
paypal.Buttons({

// Set up the transaction
createOrder: function(data, actions) {
return payId;
},

// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
</body>



$payment = new Payment();
$payment->setIntent('sale')
->setApplicationContext([
'locale' => 'de_DE'
])
->setPayer($payer)
->setRedirectUrls($redirectUrl)
->setTransactions([$transaction]);
$payment->create($this->paypal);
$paymentId = $payment->getId(); 

 

 The console show an error message: Do not pass PAY-XXX or PAYID-XXX directly into createOrder. Pass the EC-XXX token instead, but the payment can't get the ec-token.

Login to Me Too
1 REPLY 1

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.