Your implementation will be similar to the PayPal provider. We're actually moving that into the Core in the next couple weeks, so you can watch how that goes if you get stuck.
Payment Providers follow the same pattern as the other GatewayProviders in Merchello - there is a decent write up of a notification provider in the docs to get familiar with the pattern.
In a nutshell, You will create a Provider that manages one or more payment methods. The provider is the connection to Merchello, the method contains the actual logic for dealing with whatever API (or some local operation).
So in your case, you will have a provider and a method that will handle the initial transaction (which is really already done internally in Merchello and exposed to your method via a base class) and then you will redirect to your provider. You will need to create a handler for the return.
Conceptually what will happen:
1) Customer places an order in Merchello and proceeds through the checkout and selects your new payment method (the method offered from your provider).
2) You collect whatever information you need from the customer (if any) and submit it to a controller method that works with your method.
3) In the controller method, you will "Authorize" a payment which will save the invoice in the back office of Merchello and return an IPaymentResult (which contains the IInvoice and the IPayment that was authorized). This will both have Guid keys.
4) Using these keys you can redirect to the external site to accept the payment.
5) On successful payment, you query the InvoiceService by the invoice key to get the invoice and the authorized Payment that was created so that you can "Capture" the payment.
6) Once the payment is captured you can redirect to a receipt page.
You may also want to checkout the PayPal provider and the SagePay providers that are out there open source in the community ... they do basically the same thing you are trying to do.
Thank you for taking the time to write a really comprehensive anwser!
I get the stuff about adding a provider with one ore more payment methods.
After my initial requst to the payment provider I actually get a form-code (complete form
) that http-posts to the payment providers hosted page - the idea is that the webshop clients browser should post this form to complete the payment.
When I look at the source code of the examples I don't find where they are posting a form like this to a provider - In the SagePay-provider they do a redirect in the success-method of the SagePayApiController but I don't really get if thats where I should put my form?
I guess I'm getting stuck inbetween step 2-4 in your example here in the text. Could you point me to any reading about this? Would be very much appreciated.
My issue was how to handle the front end and I found the PaymentMethodUiController-base class that I can use to send back my form with the RenderForm-action.
After fiddeling for a couple of hours I think I get the workflow now =D
Hi Rushty i want to use Klarna Payment Provider in Merchello bazaar and i really try to create One Consol Application like paypal and create "KlarnaPaymentGatewayMethod" and "KlarnaPaymentGatewayProvider" which is same as paypal. Then i don't what is next step because when i click on checkout button than how we catch order to payment provider because in other payment provider redirect to their own site but klarna give one snippet(html code with contain of form and etc) and just replace in our code and than we fill all details like card no, date and etc. and when we fill all details then redirect to Klarna site. So can you please give steps or any code because i do too much rnd behind this.
1) So there is need to create custom package for Klarna payment provider for Merchello?
2) i also add klarna in merchPaymentMethod and merchGatewayProviderSettings with ref also but didn't seems in dropdown in checkoutconfirm page and when i debug only one paymentmethod in a list and it is a cash method i also activate in Gateway in umbraco backoffice.
3) I just put dll of a project for Klarna in umbraco and not create a package So it is happen?
4) How can i server call for Klarna api which was mention in your lasr mail?
Payment providers are what Merchello uses to manage Payment Methods. The way it works ->
When requesting which payment methods are available, Merchello queries for all payment methods, by asking each resolved and "activated" payment provider what methods they have to offer.
The method itself is essentially a wrapper for the logic that needs to happen for a specific Payment Gateway (in your case Klarna) in order to facilitate a payment operation (authorize, authorize capture, void and refund).
I'd think you would reference the Klarna dll in you payment method. You will have to read through the Klarna docs to figure out how to post and retrieve information from from their system - but what typically happens is your front end will post info to a local controller which is responsible for collecting your payment information and passing it again to the payment method. The payment method then interacts with the gateway (Klarna) and receives the response passing that back to the controller.
For redirecting providers, you will often need to provide an endpoint for the gateway to redirect back to ... the PayPal provider is a good example of this.
As I mentioned earlier you basically need 3 classes:
A PaymentGatewayProvider class: This will be responsible for registering Klarna as a Payment Gateway Provider, as well as managing the lifetime of payment gateway methods.
A PaymentGatewayMethod class: This will be responsible for handling the actual payment actions such as authorizing and capturing payments.
A PaymentMethodUiController class: This is the controller that Rusty mentioned in his reply above. For Klarna Checkout you will need to have 3 endpoints:
Checkout: render the checkout form
Confirm: render the confirmation form
Push: Klarna will make an HTTP POST request to this endpoint when the order has been acknowledged, meaning that you can go ahead and create the order in Merchello. You can do this by calling CheckoutManagerBase.Payment.AuthorizePayment(...). Note that there are some intricacies due to the fact that a new cookie is created during the Klarna request, which means that a new anonymous customer will be created. To get around this, you need to persist the customer ID and get the checkout manager again (see Rusty's answer here). Otherwise the payment authorization will fail.
To access the Klarna libraries you can just download them through NuGet.
Hey Gopal - I don't think I understand the question ... There is a post back in the mix here to submit the payment information and get the payment result.
Getting quite confused looking at the existing payment providers to see how they work.
Any chance a skeleton payment provider can be created which just automatically approves all payments with a comment to indicate where code needs to be inserted? Something like Merchello.Plugin.Payments.Free.
There is a pending blog post that is coming out on Skrift very few that discusses the implementation of the PO Number provider we just moved into the Merchello.Core project with version 2.3.0.
Custom payment gateway with form post
Hi!
Great package! Love this project!
I'm looking at how to write a payment provider for the package and I can't really figure it out.
Must of the payment gateways here in sweden requires us to post a form in the browser and redirect the user to the payment provides page.
I've looked at over 5-6 examples of provider implementaitons but I can't seem to figure out how this can be done?
The specific provider that I'm implementing against right now has a process that looks something like this:
How would I implement this with Merchello? Is there any hits, reading or examples out here?
Thanks for the help!
Hey there Markus - thanks for the Kudos!
Your implementation will be similar to the PayPal provider. We're actually moving that into the Core in the next couple weeks, so you can watch how that goes if you get stuck.
Payment Providers follow the same pattern as the other GatewayProviders in Merchello - there is a decent write up of a notification provider in the docs to get familiar with the pattern.
In a nutshell, You will create a Provider that manages one or more payment methods. The provider is the connection to Merchello, the method contains the actual logic for dealing with whatever API (or some local operation).
So in your case, you will have a provider and a method that will handle the initial transaction (which is really already done internally in Merchello and exposed to your method via a base class) and then you will redirect to your provider. You will need to create a handler for the return.
Conceptually what will happen:
1) Customer places an order in Merchello and proceeds through the checkout and selects your new payment method (the method offered from your provider).
2) You collect whatever information you need from the customer (if any) and submit it to a controller method that works with your method.
3) In the controller method, you will "Authorize" a payment which will save the invoice in the back office of Merchello and return an IPaymentResult (which contains the IInvoice and the IPayment that was authorized). This will both have Guid keys.
4) Using these keys you can redirect to the external site to accept the payment.
5) On successful payment, you query the InvoiceService by the invoice key to get the invoice and the authorized Payment that was created so that you can "Capture" the payment.
6) Once the payment is captured you can redirect to a receipt page.
You may also want to checkout the PayPal provider and the SagePay providers that are out there open source in the community ... they do basically the same thing you are trying to do.
Hi Rusty!
Thank you for taking the time to write a really comprehensive anwser!
I get the stuff about adding a provider with one ore more payment methods.
After my initial requst to the payment provider I actually get a form-code (complete form
) that http-posts to the payment providers hosted page - the idea is that the webshop clients browser should post this form to complete the payment.When I look at the source code of the examples I don't find where they are posting a form like this to a provider - In the SagePay-provider they do a redirect in the success-method of the SagePayApiController but I don't really get if thats where I should put my form?
https://github.com/BarryFogarty/Merchello.Plugins.SagePay/blob/master/src/Merchello.Plugin.Payments.SagePay/Controllers/SagePayApiController.cs#L156s
I guess I'm getting stuck inbetween step 2-4 in your example here in the text. Could you point me to any reading about this? Would be very much appreciated.
Cheers!
Hi again!
My issue was how to handle the front end and I found the PaymentMethodUiController-base class that I can use to send back my form with the RenderForm-action.
After fiddeling for a couple of hours I think I get the workflow now =D
// m
Hi Rushty i want to use Klarna Payment Provider in Merchello bazaar and i really try to create One Consol Application like paypal and create "KlarnaPaymentGatewayMethod" and "KlarnaPaymentGatewayProvider" which is same as paypal. Then i don't what is next step because when i click on checkout button than how we catch order to payment provider because in other payment provider redirect to their own site but klarna give one snippet(html code with contain of form and etc) and just replace in our code and than we fill all details like card no, date and etc. and when we fill all details then redirect to Klarna site. So can you please give steps or any code because i do too much rnd behind this.
Klarna order generate is like this Klarna checkout
It looks like you are going to need to wrap some of their stuff to make some API calls server side.
https://developers.klarna.com/en/us/kco-v3/checkout/2-render-the-checkout
1) So there is need to create custom package for Klarna payment provider for Merchello?
2) i also add klarna in merchPaymentMethod and merchGatewayProviderSettings with ref also but didn't seems in dropdown in checkoutconfirm page and when i debug only one paymentmethod in a list and it is a cash method i also activate in Gateway in umbraco backoffice.
3) I just put dll of a project for Klarna in umbraco and not create a package So it is happen?
4) How can i server call for Klarna api which was mention in your lasr mail?
Hey Gopal,
Payment providers are what Merchello uses to manage Payment Methods. The way it works ->
When requesting which payment methods are available, Merchello queries for all payment methods, by asking each resolved and "activated" payment provider what methods they have to offer.
The method itself is essentially a wrapper for the logic that needs to happen for a specific Payment Gateway (in your case Klarna) in order to facilitate a payment operation (authorize, authorize capture, void and refund).
I'd think you would reference the Klarna dll in you payment method. You will have to read through the Klarna docs to figure out how to post and retrieve information from from their system - but what typically happens is your front end will post info to a local controller which is responsible for collecting your payment information and passing it again to the payment method. The payment method then interacts with the gateway (Klarna) and receives the response passing that back to the controller.
For redirecting providers, you will often need to provide an endpoint for the gateway to redirect back to ... the PayPal provider is a good example of this.
Hi Gopal,
As I mentioned earlier you basically need 3 classes:
CheckoutManagerBase.Payment.AuthorizePayment(...)
. Note that there are some intricacies due to the fact that a new cookie is created during the Klarna request, which means that a new anonymous customer will be created. To get around this, you need to persist the customer ID and get the checkout manager again (see Rusty's answer here). Otherwise the payment authorization will fail.To access the Klarna libraries you can just download them through NuGet.
Thank you very much to Rushty and William for quick response.
Let me check and try to develop as per your instruction and if i fail then again i will defiantly ask for more help
Thank you again
Hi Rusty
It is possible to checkout and checkoutconfirm view in single view? and how?
Because when i try ThemedPartial need model and two model in single view not support So can you help me.
Hey Gopal - I don't think I understand the question ... There is a post back in the mix here to submit the payment information and get the payment result.
I mean i want to do CheckoutaddressFrom and CheckoutConfirmationForm in single view or single form or unit.
Getting quite confused looking at the existing payment providers to see how they work.
Any chance a skeleton payment provider can be created which just automatically approves all payments with a comment to indicate where code needs to be inserted? Something like Merchello.Plugin.Payments.Free.
Hey Ryan,
There is a pending blog post that is coming out on Skrift very few that discusses the implementation of the PO Number provider we just moved into the Merchello.Core project with version 2.3.0.
It is a very simple provider - checkout the source here: https://github.com/Merchello/Merchello/tree/merchello-dev/src/Merchello.Providers/Payment/PurchaseOrder
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.