I'm using a custom payment provider for Stripe payments. In my checkout flow, I authorise the payment midway through the process and then I capture the payment on the final step. All of this works fine apart from two orders are created in Merchello. Everything in Stripe is fine, the initial auth is captured (no duplicates) but in Merchello I get a new order and therefore the order IDs that I have are out of sync between Merchello and Stripe.
Anybody had anything similar, anything to look out for?
It makes sense that two orders were created if you were calling Authorize and then AuthorizeCapture.
An invoice is saved with both the Authorize and the AuthorizeCapture (which is returned in the IPaymentResult even if the result itself is not successful).
The use case:
Customer attempts to authorize a payment used credit card 1 - which fails.
You can then grab the invoice from the payment result and authorize again using a second credit using the invoice created during the first operation on the retry. IInvoice has as set of extension methods to handle payments as well.
Likewise you can capture the payment directly from the invoice.
When calling AuthorizeCapture, the payment provider generally tries to perform both operations at the same time (as a single operation - like a credit card charge) - but it still returns an invoice in the IPaymentResult.
So in the event of AuthorizeCapture attempt Success == false you can then grab the invoice from the first result and then capture the payment via the invoice returned as a retry ...
Make sense?
Alternatively, like in the PayPalExpressProvider where we have to authorize and then capture (due to the redirects), on a retry, we have to delete the first invoice and then allow the second authorize to create another one for the capture. If I remember correctly, there are some code comments around this in that provider and possibly a TODO to see if it can be refactored since the bump in invoice number sequence is not optimal - but it works well and accomplishes what it needs to.
The CheckoutManager associates the notes when it prepares the invoice. If you need to add a note after the invoice has been prepared, add it to the invoice directly and resave the invoice.
This is how the notes are added when the invoice is created:
Merchello - Duplicate orders when doing authorize before capture
Hi,
I'm using a custom payment provider for Stripe payments. In my checkout flow, I authorise the payment midway through the process and then I capture the payment on the final step. All of this works fine apart from two orders are created in Merchello. Everything in Stripe is fine, the initial auth is captured (no duplicates) but in Merchello I get a new order and therefore the order IDs that I have are out of sync between Merchello and Stripe.
Anybody had anything similar, anything to look out for?
Thanks
Ben
Think I've found a way round this for anybody else who comes across it.
Previously I was using:
checkoutManager.Payment.AuthorizeCapturePayment
which was creating another order, so I've changed this to:
paymentMethod.CapturePayment
and it works correctly now
Thanks
Hey Ben,
It makes sense that two orders were created if you were calling Authorize and then AuthorizeCapture.
An invoice is saved with both the Authorize and the AuthorizeCapture (which is returned in the IPaymentResult even if the result itself is not successful).
The use case:
Customer attempts to authorize a payment used credit card 1 - which fails.
You can then grab the invoice from the payment result and authorize again using a second credit using the invoice created during the first operation on the retry.
IInvoice
has as set of extension methods to handle payments as well.Likewise you can capture the payment directly from the invoice.
When calling AuthorizeCapture, the payment provider generally tries to perform both operations at the same time (as a single operation - like a credit card charge) - but it still returns an invoice in the IPaymentResult.
So in the event of AuthorizeCapture attempt Success == false you can then grab the invoice from the first result and then capture the payment via the invoice returned as a retry ...
Make sense?
Alternatively, like in the PayPalExpressProvider where we have to authorize and then capture (due to the redirects), on a retry, we have to delete the first invoice and then allow the second authorize to create another one for the capture. If I remember correctly, there are some code comments around this in that provider and possibly a TODO to see if it can be refactored since the bump in invoice number sequence is not optimal - but it works well and accomplishes what it needs to.
Hi Rusty,
Now that I have implemented this, my GetCheckoutManager no longer seems to be getting saved.
The flow of my checkout is
Previously, when I was doing an authroziecapture at the end it was adding my note but its no longer doing this.
Am I missing something?
Thanks
The CheckoutManager associates the notes when it prepares the invoice. If you need to add a note after the invoice has been prepared, add it to the invoice directly and resave the invoice.
This is how the notes are added when the invoice is created:
https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Web/Workflow/InvoiceCreation/CheckoutManager/AddNotesToInvoiceTask.cs
Thanks Rusty, that makes sense.
I've done it with paymentMethod.Capture for now
is working on a reply...