没有按钮的贝宝订阅方法-Javascript/Angular



我正在实现贝宝的地方进行支付结账。我使用他们的方法渲染了贝宝按钮,但我想把这些按钮的操作放在我的自定义按钮上,但它不起作用。

我试着改变功能,但没用。

以下是呈现按钮和执行结账操作的功能:

paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: 'My ID hiden'
});
},
onApprove(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
}).render(this.paypalElement2.nativeElement);

我试着做这个:

checkout() {
paypal.Buttons({
createSubscription(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: ''
});
},
onApprove(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
});
}

但当我按下按钮时,什么也没发生。

有办法完成这项工作吗?

我想把这些按钮的操作放在我的自定义按钮上

不能用PayPal JavaScript、paypal.Buttons(...)完成

如果您想使用自己的按钮直接开始结账,您只需要与PayPal REST API(无JS SDK(集成,并重定向到通过API创建订阅时返回的approvehref。这是不推荐的,因为它显然涉及重定向离开你的网站。使用PayPal JS按钮是优越的,因为它可以在后台加载您的网站,并打开一个小窗口进行付款审批。

最新更新