簡體   English   中英

如何使用帶條紋托管發票頁面的3D Secure為付款卡創建付款縮進

[英]How to create payment indent for payment card with 3D Secure with stripe hosted invoice page

我創建按期付款時沒有問題,需要身份驗證時不能再收費,Stripe必須通過確認鏈接向客戶發送一封信時不理解該方法,該鏈接指向Stripe托管頁面就像在文檔中一樣

帶SCA的請求要求卡片我得到了卡片錯誤(authorization_required)。

        $intent = PaymentIntent::create([
            'amount'               => 1100,
            'currency'             => 'usd',
            'payment_method_types' => ['card'],
            'customer'             => $customerId,
            'payment_method'       => $paymentMethodId,
            'off_session'          => true,
            'confirm'              => true,
        ]);

我在這里找到了這種方法。 在Stripe儀表板中為電子郵件設置設置 也許必須與發票API有關,但我看不到文檔中的流程。

預期成功付款創建帶有require_confirmation狀態的縮進。 通過確認按鈕發送給客戶的電子郵件。

根據3D安全的新規定,需要其他付款確認。 您可以使用以下代碼來實現。

將意圖傳遞給此功能(服務器代碼)

    const generate_payment_response = (intent) => {
    if (
      intent.status === 'requires_action' &&
      intent.next_action.type === 'use_stripe_sdk'
    ) {
      // Tell the client to handle the action
      return {
        requires_action: true,
        payment_intent_client_secret: intent.client_secret
      };
    } else if (intent.status === 'succeeded') {
      // The payment didn’t need any additional actions and completed!
      // Handle post-payment fulfillment
      return {
        success: true
      };
    } else {
      // Invalid status
      return {
        error: 'Invalid PaymentIntent status'
      }
    }
  };

提示附加的3D安全彈出窗口(前端代碼)

function handleServerResponse(response) {
    console.log(response, "handling response");

    if (response.data.success) {
      // Show error from server on payment form
      alert("Paymemt successful");

    } else if (response.data.requires_action) {
        alert("require additional action");
        // Use Stripe.js to handle required card action
        stripe.handleCardAction(
            response.data.payment_intent_client_secret
            ).then(function(result) {
                if (result.error) {
                    // Show error in payment form
                } else {
                    // The card action has been handled
                    // The PaymentIntent can be confirmed again on the server
                    let data = {
                        payment_intent_id: result.paymentIntent.id 

                    }
                    axios.post(`${baseUrl}/confirmPayment`, data).then(response => {
                        handleServerResponse(response);
                    });
                }
            }).catch(error => {
                console.log(error, "error");

                alert("rejected payment");
            })
        } else {
            // Show failed
            alert("Failed transaction");
            alert(response.data.message);
            console.log(response.data, "error during payment confirmation");
    }
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM