カテゴリー:
QA
閲覧数:332 配信日:2019-04-23 10:43
質問履歴36
What is the difference between “stripe.handleCardPayment (clientSecret)” and “stripe.retrievePaymentIntent (clientSecret)”?
・2019/4/23
What is the difference below? Please tell me the pros and cons of each.
・stripe.handleCardPayment(clientSecret)
・stripe.retrievePaymentIntent(clientSecret)
・stripe.handleCardPayment(clientSecret)
(async () => {
let {paymentIntent, error} = await stripe.handleCardPayment(clientSecret);
if (error) {
// Handle error here
} else if (paymentIntent && paymentIntent.status === 'succeeded') {
// Handle successful payment here
}
})();
・stripe.retrievePaymentIntent(clientSecret)
(async () => {
let {paymentIntent, error} = await stripe.retrievePaymentIntent(clientSecret);
if (error) {
// Handle error here
} else if (paymentIntent && paymentIntent.status === 'succeeded') {
// Handle successful payment here
}
})();
「stripe.handleCardPayment(clientSecret)」と「stripe.retrievePaymentIntent(clientSecret)」の違いは何ですか?
下の違いは何ですか? それぞれの長所と短所を教えてください。
・What is the difference between "stripe.handleCardPayment (clientSecret)" and "stripe.retrievePaymentIntent (clientSecret)"?
質問後に気が付いたこと
指定可能な引数の数
・異なる
handleCardPaymentメソッド
・第3引数まで指定可能
stripe.handleCardPayment(clientSecret, cardElement[, data])
Retrieve a PaymentIntent
・第1引数のみ指定可能
恐らく
・第1引数のみ指定した場合の挙動は同じ
→ 誤り。両者の挙動は明確に異なる
両者の違い
・handleCardPaymentメソッドは第3引数まで指定可能なので、handleCardPaymentメソッドの方が出来ることが多い
A抜粋
両者は明確に異なる
・2つの方法で全く異なることをする
handleCardPaymentメソッド
・支払い情報を収集し、ユーザーから支払いを収集しようとするようにStripeに指示し、成功するとPaymentIntentオブジェクトを返す
retrievePaymentIntentメソッド
・支払回収を試行せずにPaymentIntentを再試行する