我可以在Angular 4應用中成功加載checkout.js,呈現PayPal按鈕,出現新窗口,我確認付款,付款已處理但我不知道如何設置onAuthorize回調來處理Angular 4中的響應(例如顯示成功並將支付記錄存儲到MongoDb)。這是我的代碼。我可以看到第一個包含付款響應的console.log,但我無法訪問組件的範圍,所以在執行第一個console.log之後沒有任何操作。我在控制檯中沒有錯誤。即使console.log(「成功!」)不處理。在Angular 4上處理PayPal onAuthorize回調
onAuthorize: (data, actions) => {
return actions.payment.execute().then(function(payment) {
console.log("response = " + JSON.stringify(payment));
this._alertService.success("The extension of subscription was succesfull!");
this.user.contracts.push({
"acquired": new Date(payment.create_time),
"price": payment.transactions[0].amount.total,
"expires": new Date(this.user.expires.getFullYear()+this.selectedAccountExtensionOption.addedYears, this.user.expires.getMonth(), this.user.expires.getDate())
});
console.log("successful!");
});
},
小心分享您的集成? –