Полоса элементы и 3d безопасный - PullRequest
0 голосов
/ 25 июня 2018

Я недавно начал работать с полосовыми элементами.Теперь мне нужно сделать его полностью безопасным в 3D, а затем сохранить клиента в полоску и токен клиента в моей базе данных.Я знаю, как сделать клиента, но никогда ранее не работал с 3d secure и источниками.

Итак, мой вопрос: как мне проверить, можно ли использовать источник с безопасностью 3 d?Использование API v3 в моем скрипте.

Вот скрипт, который я использую после предварительной установки ключа API.

<script>
    // Custom styling can be passed to options when creating an Element.
    var style = {
      base: {
        color: '#32325d',
        lineHeight: '18px',
        fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
        fontSmoothing: 'antialiased',
        fontSize: '16px',
        '::placeholder': {
          color: '#aab7c4'
        }
      },
      invalid: {
        color: '#fa755a',
        iconColor: '#fa755a'
      }
    };

    // Create an instance of the card Element.
    var card = elements.create('card', {style: style});

    // Add an instance of the card Element into the `card-element` <div>.
    card.mount('#card-element');
    card.addEventListener('change', function(event) {
        var displayError = document.getElementById('card-errors');
        if (event.error) {
          displayError.textContent = event.error.message;
        } else {
          displayError.textContent = '';
        }
     });

  // Create a source or display an error when the form is submitted.
  var form = document.getElementById('payment-form');
  form.addEventListener('submit', function(event) {
    event.preventDefault();

    stripe.createSource(card).then(function(result) {
      if (result.error) {
        // Inform the user if there was an error
        var errorElement = document.getElementById('card-errors');
        errorElement.textContent = result.error.message;
      } else {
        // Send the source to your server
        stripeSourceHandler(result.source);
      }
    });
  });
  function stripeSourceHandler(source) {

      // Insert the source ID into the form so it gets submitted to the server
      var form = document.getElementById('payment-form');
      var hiddenInput = document.createElement('input');
      hiddenInput.setAttribute('type', 'hidden');
      hiddenInput.setAttribute('name', 'stripeSource');
      hiddenInput.setAttribute('value', source.id);
      form.appendChild(hiddenInput);

      // Submit the form
      form.submit();
    }
</script>

Я достаточно хорошо знаю PHP и хотел бы использовать его, если это возможно.

Спасибо!

1 Ответ

0 голосов
/ 25 июня 2018

Здесь есть полная документация по интеграции 3DS с Stripe: https://stripe.com/docs/sources/three-d-secure

Что касается вашего прямого вопроса, чтобы проверить, поддерживает ли источник 3DS или нет, вы должны проверить значение card.three_d_secure для источника.атрибут: https://stripe.com/docs/sources/three-d-secure#check-requirement

...