2
votes

I have a checkout form that I am using to send shopping cart details to different payment gateways like paypal using Symfony and Payum.

Now I am trying to send payment details to stripe in case user selects stripe checkout option. At the moment the integration with stripe is working fine, i can send the payment and get the response from stripe however in order to send credit card details to stripe i get redirected to capture

enter image description here

where i see the "pay with card" button and if i click on it the popup appears to enter credit card details

enter image description here

What I would like to do is allow user to add credit card details on checkout form that I have rather than the form you see on popup. Is it possible to achieve this? How can i use my own form to send data to stripe rather than using stripe popup?

I found a close example of the process in this and this example. Is there any example for stripe? Any help will be greatly appreciated.

2

2 Answers

2
votes

This is an example for stripe In Javascript:

Including Stripe.js

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

Setting your publishable key :

Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');

send data :

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

response :

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();
  }
}

for more detail check this link https://stripe.com/docs/stripe.js

2
votes

Stripe Checkout is designed this way. You see the button click it, fill all the required info and that's it.

If you want to fill credit card details earlier you can do that, but in that case you have to use

  • Stripe "direct". Implemented in Omnipay and used via Omnipay Bridge
  • You have to pass omnipay credit cards like this (better way is not implemented yet):

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

    • and use $this->forward instead of redirect. Because credit card is not saved to database you have to process them immediately. (example)