Как создать платежный отступ для платежной карты с помощью 3D Secure на полосе размещенного счета - PullRequest
0 голосов
/ 05 июля 2019

Нет проблем, когда я создаю сеансовый платеж, не могу произвести второй платеж, когда требуется аутентификация, не понимаю подход, когда 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,
        ]);

Я нашел этот подход здесь.Установите settings на панели инструментов Stripe для электронной почты.Может быть, это должна быть связь с API счетов, но я не вижу потока в документах.

Ожидается успешное создание paymentIndent со статусом require_confirmation.Письмо отправлено клиенту с кнопкой подтверждения.

1 Ответ

0 голосов
/ 09 июля 2019

Согласно новым правилам безопасности 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-всплывающее окно (Front-End Code)

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");
    }
  }
...