如何异步调用 Square API 方法
How to call Square API method asynchronously
如何异步调用 paymentForm.requestCardNonce() 方法
我正在 AngularJs 中集成 Square 支付网关,现在我必须调用 paymentForm.requestCardNonce()
并且此方法在后台调用 Web 服务。现在我必须等待后台呼叫才能继续进行进一步的处理。那么我如何处理 Square Payment Gateway https://docs.connect.squareup.com/payments/sqpaymentform/setup
提供的 paymentForm.requestCardNonce()
方法的回调
初始化代码示例
var paymentForm = new SqPaymentForm({
applicationId: "sandbox-xxx-xxxxxxxxxxxx",
inputClass: 'sq-input',
callbacks: {
cardNonceResponseReceived: function (errors, nonce, cardData, billingContact, shippingContact) {
// I am receiving response of web service Here
}
}
}
如何通过调用其中的方法在我的自定义函数中获得成功响应?(注意 - 它的工作和调用方法也是如此,但我必须根据网络服务的响应执行后续步骤)
addCard = function () {
paymentForm.requestCardNonce();
// Till this function executes I need to wait here. how can I write promise here ?
}
参考链接
https://docs.connect.squareup.com/payments/sqpaymentform/how-it-works
https://github.com/square/connect-api-examples/tree/master/templates/web-ui/payment-form/basic
为了后代,从评论中提取。
requestCardNonce
是异步的,当它完成时会调用cardNonceResponseReceived
,所以如果你想在它完成后调用一个函数,你应该把它放在cardNonceResponseReceived
.
如何异步调用 paymentForm.requestCardNonce() 方法
我正在 AngularJs 中集成 Square 支付网关,现在我必须调用 paymentForm.requestCardNonce()
并且此方法在后台调用 Web 服务。现在我必须等待后台呼叫才能继续进行进一步的处理。那么我如何处理 Square Payment Gateway https://docs.connect.squareup.com/payments/sqpaymentform/setup
paymentForm.requestCardNonce()
方法的回调
初始化代码示例
var paymentForm = new SqPaymentForm({
applicationId: "sandbox-xxx-xxxxxxxxxxxx",
inputClass: 'sq-input',
callbacks: {
cardNonceResponseReceived: function (errors, nonce, cardData, billingContact, shippingContact) {
// I am receiving response of web service Here
}
}
}
如何通过调用其中的方法在我的自定义函数中获得成功响应?(注意 - 它的工作和调用方法也是如此,但我必须根据网络服务的响应执行后续步骤)
addCard = function () {
paymentForm.requestCardNonce();
// Till this function executes I need to wait here. how can I write promise here ?
}
参考链接 https://docs.connect.squareup.com/payments/sqpaymentform/how-it-works
https://github.com/square/connect-api-examples/tree/master/templates/web-ui/payment-form/basic
为了后代,从评论中提取。
requestCardNonce
是异步的,当它完成时会调用cardNonceResponseReceived
,所以如果你想在它完成后调用一个函数,你应该把它放在cardNonceResponseReceived
.