首页 文章

使用自定义表单symfony进行条带检出

提问于
浏览
2

我有一个结帐表单,我用来将购物车的详细信息发送到不同的支付网关,如Paypal使用Symfony和Payum .

现在我正在尝试将付款详细信息发送到条带,以防用户选择条带结帐选项 . 目前与条带的集成工作正常,我可以发送付款并从条带获得响应,但为了将信用卡详细信息发送到条带我被重定向到 capture

enter image description here

我看到“用卡支付”按钮,如果我点击它,弹出窗口似乎输入信用卡详细信息

enter image description here

我想做的是允许用户在我有的结账表单上添加信用卡详细信息,而不是在弹出窗口中看到的表单 . 是否有可能实现这一目标?如何使用我自己的表单将数据发送到条带而不是使用条带弹出?

我在thisthis示例中找到了该过程的近似示例 . 条纹有什么例子吗?任何帮助将不胜感激 .

2 回答

  • 2

    Stripe Checkout就是这样设计的 . 你看到按钮点击它,填写所有必需的信息,就是这样 .

    如果您想提前填写信用卡详细信息,可以这样做,但在这种情况下您必须使用

    $ order-> setDetails(array('card'=> new CreditCard($ data),));

    • 并使用 $this->forward 而不是重定向 . 由于信用卡未保存到数据库,因此您必须立即处理它们 . (example
  • 2

    这是条带在Javascript中的示例:

    包括Stripe.js

    <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
    

    设置您的可发布密钥:

    Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');
    

    发送数据:

    Stripe.card.createToken({
          number: $('.card-number').val(),
          cvc: $('.card-cvc').val(),
          exp_month: $('.card-expiry-month').val(),
          exp_year: $('.card-expiry-year').val()
        }, stripeResponseHandler);
    

    回应:

    function stripeResponseHandler(status, response) {
      var $form = $('#payment-form');
    
      if (response.error) {
        // Show the errors on the form
        $form.find('.payment-errors').text(response.error.message);
        $form.find('button').prop('disabled', false);
      } else {
        // response contains id and card, which contains additional card details
        var token = response.id;
        // Insert the token into the form so it gets submitted to the server
        $form.append($('<input type="hidden" name="stripeToken" />').val(token));
        // and submit
        $form.get(0).submit();
      }
    }
    

    有关更多详细信息,请查看此链接https://stripe.com/docs/stripe.js

相关问题