3

Instead of taking payment via the Omnipay/Stripe Payment Method, what I'm trying to do is just create a new Customer and Credit Card on Stripe during Checkout, no payment taken at all at this stage.

Looking through the Stripe code it looks as though that functionality already exists. On the Stripe Gateway, this looks like it should do what I want.

public function createCard(array $parameters = array())
{
    return $this->createRequest('\Omnipay\Stripe\Message\CreateCardRequest', $parameters);
}

What I'm struggling with is how/where to call this and finish up the Order by turning the Cart into an Order.

The Checkout / Payment page submits to the following Controller:

Commerce_PaymentsController->actionPay()

I could just duplicate the functionality in here swapping out what I don't need, but this feels really hacky/wrong!

Has anyone any suggestions for a more sensible approach?

1

A no one has come forward and told me it's a bad idea, I've ploughed on and done the following:

  1. Created my own Controller action in my plugin to bypass the payment side of things altogether. I didn't use Omnipay to create my Customer on Stripe in the end. I went with using Stripes own API directly as documented here.

  2. To complete the Order (as-in convert a Cart into a full-blown Order, it was as simple as calling the following Commerce method:

    craft()->commerce_orders->completeOrder($cart);

| improve this answer | |
  • Hi Steve, are you still using this method in production? Have you run into any issues or things you had to do differently since implementing the above? – Luke Pearce Oct 2 '17 at 19:29
  • 1
    @LukePearce It's still in use as far as I'm aware, it's not an active project for me any more. I didn't run into any issues at the time, so what's above is still accurate, unless there's a newer better way. – Steve Holland Oct 3 '17 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.