Ok so I need to finalise an order but its not obvious how to do that (unless I've overlooked it in the docs?).
I've got products in the order, i've added shipping and billing properties, i've selected a shipping method and payment method.
Now I need to finalise the order so that 1) it is not returned by the call to VendrApi.Instance.GetCurrentOrder() and 2) it is returned when i call IOrderService.GetFinalizedOrdersForCustomer().
The next time you ask for GetCurrentOrder then it should recognize the current order has finalized and move it into the CurrentFinalized slot.
/Matt
Hmm, maybe we should look to just call InitializeTransaction from within Finalize if the transaction isn't already initialized. Would make this a bit simpler. 🤔
Ok, then maybe it's actually worth you outlining the exact process of what you are trying to achieve as I don't think I'm understanding enough to give you the right answer.
You may recall my previous query about CalculatePrice() throwing an exception, that is the Shipping Method in step 2.
The client insists they want the customers to stay on site to complete the transaction so the payment method will be api based. That is, the site will take all the cc details, communicate with the designated provider (tbd) via api calls and then update the order based on the outcome of the transaction, e.g. approved, error or rejected.
Essentially, you'd create a payment provider but when this provider generates it's form, instead of that form redirecting to the payment gateway, you have it redirect to payment page on your site. On that page you access the settings posted to it and display your payment page, then once it's complete you have you form post back to the payment provider to do it's final bits to actually finalize the order.
This is how I would probably do it.
Or I guess you could bypass the payment provider process entirely as I stated in my first post and call the finalize method from behind an API controller you post to once you've accepted payment.
Yup, so you would want to render the payment form on stage 2 and have the payment provider to redirect to the stage 3 page for where you render your payment form.
Saying this, the tricky think you might have here is that you need to render the PaymentForm only once the order is completely up to date and about to move to the payment phase. It all being on the one page means it won't be ready till the page is filled in so you may need to do some fun stuff to handle this.
The way I've done this in the past is to have stage 2 post to a hidden i frame which then updates the order and renders the payment form but uses js to auto submit it redirecting to the payment gateway.
Maybe given you are handling all the payment side, creating your own API controller might be more straight forward. Maybe just create an empty payment provider to assign payment to, but you manually call finalize setting the relevant captured amount / payment status etc.
I think calling Finalise on the order is what I need. I've just tried it and I received a confirmation email and now GetCurrentOrder(storeId) returns an empty order.
How to finalise an order
Hi Matt
Ok so I need to finalise an order but its not obvious how to do that (unless I've overlooked it in the docs?).
I've got products in the order, i've added shipping and billing properties, i've selected a shipping method and payment method.
Now I need to finalise the order so that 1) it is not returned by the call to VendrApi.Instance.GetCurrentOrder() and 2) it is returned when i call IOrderService.GetFinalizedOrdersForCustomer().
Thanks.
Hey Sean
If you are wanting to bypass the checkout process and move an order to be finalized without taking payment then you need to call
The next time you ask for
GetCurrentOrder
then it should recognize the current order has finalized and move it into theCurrentFinalized
slot./Matt
Hmm, maybe we should look to just call
InitializeTransaction
from withinFinalize
if the transaction isn't already initialized. Would make this a bit simpler. 🤔For anyone elses benefit.
This did not link the order to the member so I had to add this line..
I'm on the payment page (final page of checkout) so not bypassing checkout per se.
Ahh, ok, well then the payment providers should take care of that for you.
Rendering the payment form on your final review step as shown here https://github.com/vendrhub/vendr-demo-store/blob/main/src/Vendr.DemoStore.Web/Views/CheckoutReviewPage.cshtml#L9 will initialize the transaction for you and render the form for the payment providers redirect. The payment provider is then responsible for finalizing the order once you've gone through the payment gateway.
/Matt
I'll be implementing a custom payment provider that is api based rather than forms.
Ok, then maybe it's actually worth you outlining the exact process of what you are trying to achieve as I don't think I'm understanding enough to give you the right answer.
/Matt
Ok. Well the checkout process is more or less standard aside from the steps. Our designer has condensed this down to 3 steps (joy!).
1) Cart 2) Shipping + Billing + Shipping Method 3) Payment > Result
You may recall my previous query about CalculatePrice() throwing an exception, that is the Shipping Method in step 2.
The client insists they want the customers to stay on site to complete the transaction so the payment method will be api based. That is, the site will take all the cc details, communicate with the designated provider (tbd) via api calls and then update the order based on the outcome of the transaction, e.g. approved, error or rejected.
Ahh, ok, so you are wanting an inline checkout process.
In that case, I'd probably take a look at how this was done in TC for example, the old Stripe payment provider https://github.com/TeaCommerce/Tea-Commerce-Payment-Providers/blob/master/Source/TeaCommerce.PaymentProviders.Stripe/BaseStripeProvider.cs
Essentially, you'd create a payment provider but when this provider generates it's form, instead of that form redirecting to the payment gateway, you have it redirect to payment page on your site. On that page you access the settings posted to it and display your payment page, then once it's complete you have you form post back to the payment provider to do it's final bits to actually finalize the order.
This is how I would probably do it.
Or I guess you could bypass the payment provider process entirely as I stated in my first post and call the finalize method from behind an API controller you post to once you've accepted payment.
/Matt
hmm interesting, i'll have a look at that.
With the design i've got the payment page, step 3, is where the customer enters the cc details.
Thanks Matt.
Yup, so you would want to render the payment form on stage 2 and have the payment provider to redirect to the stage 3 page for where you render your payment form.
Saying this, the tricky think you might have here is that you need to render the PaymentForm only once the order is completely up to date and about to move to the payment phase. It all being on the one page means it won't be ready till the page is filled in so you may need to do some fun stuff to handle this.
The way I've done this in the past is to have stage 2 post to a hidden i frame which then updates the order and renders the payment form but uses js to auto submit it redirecting to the payment gateway.
Maybe given you are handling all the payment side, creating your own API controller might be more straight forward. Maybe just create an empty payment provider to assign payment to, but you manually call finalize setting the relevant captured amount / payment status etc.
/Matt
I think calling Finalise on the order is what I need. I've just tried it and I received a confirmation email and now GetCurrentOrder(storeId) returns an empty order.
is working on a reply...