1

I am using the Craft Commerce templates as a starter, haven't altered that much yet.

On the payment-method page, I have a gateway for credit card/Paypal, etc. via a plugin, which works fine.

I would like a second option, where the customer can make the order without paying, but will receive a physical invoice together with the post-package.

I guess this would mean, if the user clicks this additional option (on the payment-method page, the possible gateways are displayed as different radio options), they get redirected to a different payment.twig page, where they can finish the order without paying. (or alter the payment.twig page in some way)

I was searching, but could not find anything in this direction.

2

You want to look at Commerce's 'manual' gateway.

This is a gateway that let's you receive unpaid orders, which you can then process as you see fit, including manually 'capturing' the payment when it is ultimately made.

We use this to e.g. offer a mechanism for people to pay by direct bank deposit - we just leave the orders in a 'holding' status until the payment comes in, then we 'capture' the payment on the transaction tab in the order, and process as normal from there. But you could also process and send the order with an invoice of course.

Both the order processing flow and front end implementation are really entirely up to you, but the key is this gateway will accept the order without payment.

Here's our set up (in the Commerce -> System Settings -> Gateways area) as an example. Note the labelling here isn't great (where it says 'Credit Card Payment Type' can lead you to think you can only use this with cards, which is not the case at all...) - but it does what you want.

enter image description here

Note the documentation for this is here:

https://craftcms.com/docs/commerce/3.x/payment-gateways.html#manual-gateway

(...would be good to see that expanded with some practical examples, though)

2
  • Thanks for the hint. What i don't find is a way to access the gateway: this does not work: '{% if cart.gatewayId == 4 %}'. In my theory i would check which gateway and then redirect to another payment.twig without this {{ actionInput('commerce/payments/pay') }}. Or a second option inside payment.twig i check which gateway and then do not apply 'actionInput('commerce/payments/pay') }}'.
    – Henrik
    Jul 26 at 6:17
  • You still submit to commerce/payments/pay (with the gatewayId set to your configured manual gateway) - which will then complete/accept the order, but leave it as unpaid. Jul 27 at 10:40
0

This is working for me, there might be a better solution:

i get the id from the manual payment gateway (thanks jeremy), set it and if its this manual gateway i make the order without payment. https://craftcms.com/docs/commerce/3.x/making-payments.html#checkout-without-payment

otherwise go ahead with the normal process. i put this all in the payment.twig

 {% set id = 4 %}
 {% if id == cart.gatewayId %}            
   {{ hiddenInput('action', 'commerce/cart/complete') }}
   {{ redirectInput('/shop/customer/order?number='~cart.number~'&success=true') }}
 {% else %}
    {{ actionInput('commerce/payments/pay') }}
    {{ redirectInput(siteUrl('shop/customer/order', { number: cart.number, success: 'true' })) }}
    {{ hiddenInput('cancelUrl', siteUrl('shop/checkout/payment')|hash) }}
 {% endif %}

i also added a commerce.php file in the config folder and added this:

'allowCheckoutWithoutPayment' => true,
4
  • Not quite sure what is the point of your extra logic/config? If you just submit to the normal payment controller (which will allow an order without payment to be completed with the manual gateway anyway) ... there will be less logic to think about/maintain, and an identical result...(assuming this way doesn't mark the order as paid, which I infer from the docs it might...which strikes me as bad - surely you want the order to be completed but NOT marked paid, so that you know what's going on with the order in the back end when processing it? Jul 28 at 11:34
  • you are right. i tested it without my logic and it works. dont know, why it did not work in the first place. i will edit my answer. but i can use the if logic, to alter the text of the submit button (from "pay order", to "send order"). But 1 questions remains: what is then the config "allowCheckoutWithoutPayment" for?
    – Henrik
    Jul 28 at 15:46
  • I'm not 100% sure but my guess is that the config item allows for an order (without payment) to appear as completed AND paid, in the backend, whereas the approach I showed above makes the order complete but it is NOT paid (which is, I'd think, what most people want). But I could be wrong, I haven't tried the other way. Be easy for you to check though. Just look at the order status stuff in the control panel with each approach. Jul 28 at 22:09
  • (That's how I interpret the warning on the page If you enable order completion without payment, completed orders will have the same status as any others. Don’t forget to make sure store managers are aware of the change and prepared to confirm payment before fulfilling orders! - but it could be more explicit about what it actually means by same status... Jul 28 at 22:11

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.