我已经实施了新的paypal快速结账。我想将cityObj.setFajr(""+cityObject.getString("fajr"));
someObj.mutePrayerTime(view, cityObj);
网址和success_ipn.php
网址传递给checkout.js。
我做了很多谷歌以及官方文档Paypal DOC。
以下是我的文件代码:
cancelled.php
它工作正常,但我如何传递我的IPN文件URL和取消URL。
在做了更多谷歌之后,我只能得到以下变量而不是交易ID等。:
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>
<body>
<div id="paypal-button-container"></div>
<script>
var EXECUTE_PAYMENT_URL = 'http://example.com/success_ipn.php';
paypal.Button.render({
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'My Sandbox Client ID here.',
//production: '<insert production client id>'
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
return paypal.request.post(EXECUTE_PAYMENT_URL, {
paymentID: data.paymentID,
payerID: data.payerID
}).then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');
</script>
</body>
</html>
请帮帮我这些家伙。
答案 0 :(得分:1)
经过尝试后,谷歌就此发现了解决方案。
paypal在checckout.js
最新版本之后弃用了 Express Checkout - NVP / SOAP 。因此,GetExpressCheckoutDetails
和DoExpressCheckoutPayment
也已弃用。
现在,所有工作都将在Rest API上完成。
以下是更新代码,我们如何以json格式获取付款人信息和交易详情。获得json响应后,我们也可以使用aJax更新我们的数据库记录。
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div id="paypal-button-container"></div>
<script>
var EXECUTE_PAYMENT_URL = 'http://example.com/success_checkout.php';
paypal.Button.render({
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: '',
//production: '<insert production client id>'
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '10', currency: 'USD' },
custom: 'custom value here'
}
]
}
});
},
onAuthorize: function(data, actions) {
return actions.payment.get().then(function(payment) {
//debugger;
console.log(payment);
var txn_id = payment.cart;
var bookID = payment.transactions[0].custom;
var currency = payment.transactions[0].amount["currency"];
var amount = payment.transactions[0].amount["total"];
var payerID = payment.payer.payer_info["payer_id"];
var pstatus = payment.payer.status;
var successUrl = EXECUTE_PAYMENT_URL+'?txn_id='+txn_id+'&bookID='+bookID+'¤cy='+currency+'&amount='+amount+'&payerID='+payerID+'&pstatus='+pstatus;
//console.log(newUrl);
window.location.replace(successUrl);
});
},
onCancel: function(data, actions) {
var cancelUrl = "http://example.com/cancelled.php";
//console.log(newUrl);
window.location.replace(cancelUrl);
}
}, '#paypal-button-container');
</script>
您将在 success_checkout.php 中得到回复,如下所示:
<?php
echo '<pre>' print_r($_REQUEST);
// do your stuff here
header('Location: thanks.php');
?>
希望这对其他开发者有所帮助。