我对使用PayPal react bindings结帐组件有误解。
我的付款功能:
let payment = () => {
return new paypal.Promise(async (resolve, reject) => {
await appStore.payment.paypalCreatePayments();
if (!appStore.payment.paymentsError && appStore.payment.paypalToken.payment.id) {
resolve(appStore.payment.paypalToken.payment.id);
} else {
reject(appStore.payment.paymentsError);
alert('Payment failure! error:', appStore.payment.paymentsError);
}
});
};
和Button组件:
PayPalButton = paypal.Button.driver('react', { React, ReactDOM });
<PayPalButton
client={client}
payment={payment}
commit={true}
env='sandbox'
onAuthorize={onAuthorize}
onCancel={onCancel}
onError={onError}
/>;
onAuthorize功能:
onAuthorize = async (data, actions) => {
await appStore.payment.paypalExecutePayments({
paymentID: data.paymentID,
payerID: data.payerID,
keys: appStore.payment.paypalToken.keys
});
actions.close();
if (!appStore.payment.paymentsError) {
this.props.paymentSuccess();
} else {
this.props.paymentFailure(appStore.payment.paymentsError);
}
};
当一切正常时,它工作正常。但是,当我从服务器端(例如404或500)收到错误时,Paypal会抛出此错误消息:
Uncaught Error: No handler found for post message ack for message: postrobot_method from https://1b375a11.ngrok.io in https://www.sandbox.paypal.com/webapps/hermes/button
有关如何处理此错误的任何想法?
答案 0 :(得分:2)
没有处理程序意味着在完全加载paypal结帐脚本之前会显示paypal按钮。