【问题标题】:Stripe checkout with custom form symfony使用自定义表单 symfony 进行条带结帐
【发布时间】:2015-04-11 16:53:45
【问题描述】:

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

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

我看到“用卡付款”按钮,如果我点击它,弹出窗口会显示输入信用卡详细信息

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

我在thisthis 示例中找到了该过程的一个紧密示例。有没有条纹的例子?任何帮助将不胜感激。

【问题讨论】:

    标签: php symfony stripe-payments payum


    【解决方案1】:

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

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

    • “直接”条纹。在 Omnipay 中实施并通过 Omnipay Bridge 使用
    • 你必须通过这样的omnipay信用卡(better way is not implemented yet):

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

      • 并使用$this->forward 而不是重定向。因为信用卡没有保存到数据库,你必须立即处理它们。 (example)

    【讨论】:

    • 谢谢,你是对的,我使用omnipay桥实现了条带
    【解决方案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

    【讨论】:

    • 谢谢,但问题与 sumfony payumBundle 不是自定义 php 和 js 有关
    猜你喜欢
    • 2023-03-18
    • 2013-12-01
    • 1970-01-01
    • 2019-01-18
    • 2017-12-31
    • 2021-01-08
    • 1970-01-01
    • 2017-10-09
    • 2017-09-13
    相关资源
    最近更新 更多