PayPal 按钮 - 添加自定义 属性 以从 IPN 侦听器发回
PayPal button - Add custom property to be sent back from IPN listener
我需要向我的 PayPal 按钮添加一个自定义密钥,该按钮从 IPN 侦听器返回一个值。我当前的 PayPal 代码如下。我可以将自定义 key/property 添加到 src
url 或 paypal.Buttons 脚本吗?
<!DOCTYPE html>
<html>
<head>
<base target="_blank" />
<script src="https://www.paypal.com/sdk/js?client-id=MyID_here¤cy=USD"
data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '9.99'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
</head>
<body>
<div id="paypal-button-container"></div>
</body>
</html>
在 purchase_units 对象中,您可以提供 custom_id
记录在此处:https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit
引用自 PayPal 文档:
custom_id string The API caller-provided external ID. Used to
reconcile API caller-initiated transactions with PayPal transactions.
Appears in transaction and settlement reports. Maximum length: 127
所以,我想应该是这样添加的:
purchase_units: [{
amount: {
value: '9.99'
},
custom_id: {
value: 'my_Custom_Value'
}
}]
我需要向我的 PayPal 按钮添加一个自定义密钥,该按钮从 IPN 侦听器返回一个值。我当前的 PayPal 代码如下。我可以将自定义 key/property 添加到 src
url 或 paypal.Buttons 脚本吗?
<!DOCTYPE html>
<html>
<head>
<base target="_blank" />
<script src="https://www.paypal.com/sdk/js?client-id=MyID_here¤cy=USD"
data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '9.99'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
</head>
<body>
<div id="paypal-button-container"></div>
</body>
</html>
在 purchase_units 对象中,您可以提供 custom_id
记录在此处:https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit
引用自 PayPal 文档:
custom_id string The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports. Maximum length: 127
所以,我想应该是这样添加的:
purchase_units: [{
amount: {
value: '9.99'
},
custom_id: {
value: 'my_Custom_Value'
}
}]