Developer forum

Forum » Development » Add new custom Payment provider.

Add new custom Payment provider.

Dmitrij Jazel
Reply

Hello guys,

Wanted to know how should I add add my Custom Payment provider. One like here: http://screencast.com/t/I6qswVpq

So at the checkout - the user should be able to choose whether pay with Credit card / "Giro kort" / or the method I want to create.

If user checks this particular method - it should simply make some calculations and calls elsware etc...

Now I have this: http://developer.dynamicweb-cms.com/documentation/for-developers/ecommerce/checkout-handlers.aspx

And in DW Visual studio templates I can see Checkout provider, and Gateway provider, but I can't really see "the correct way" how to approach it.

And I don't really see a way of adding it do already existing methods in the system.

 

Was hoping to get some Tips to get me started on this one...

Thanks for help!

 

Dmitrij


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Dmitrij,

It is probably not labeled clearly, but GatewayProviders are used with Shopping Cart v1 (CartV1) and CheckoutHandlers are used with Shopping Cart v2 (CartV2). There are still a few solutions using CartV1, but all new solutions can only use CartV2. Therefore, I assume it is a CheckoutHandler implementation you need.

You can download the source code for all current CheckoutHandlers (as of December 2013) here: http://developer.dynamicweb-cms.com/downloads/source-code.aspx, and the documentation for CheckoutHandlers, that you link to, also contains examples and important notes.

However. You say that the CheckoutHandler should do some calculations and calls elsewhere. What exactly do you mean? It sounds to me like you want to change something on the order, maybe even add orderlines to it. This is not what CheckoutHandlers were designed for. They have a singular purpose in transitioning carts to orders. Be that through some validation, through a payment gateway or some other way. They should not manipulate the state of the order in any way, except, perhaps, for adding transaction information and marking the order as complete. If you need to manipulate an order, you should consider either a notification subscriber or a price provider.

- Jeppe

Votes for this answer: 1
 
Dmitrij Jazel
Reply

Hej Jeppe,

Thand thanks for quick response! :)

Well, in this case, I do not need to manipulate an order in any way. Simmilarly how DIBS or any other gateway, I wanted to know how I can add my own "Checkout handler", so that (if chosen by end user) it would invoke the extensibility that I want to add. This extensebility would be some Servie calls and probably some string manipulation most likely... Eventually if they choose this payment, a small fee should be added to successful order. 

My understanding so far was:

1) to add database entry with Checkout handler

2) And implement a Checkout Handler template from Visual studio DW templates.

 

It would also be really nice it I could have a possibility to have a textfield in administration (simmilar when setting up Payment method) where I could provide my own secret and other (with this custom payment related) things...

 

Hope that brings better light over what I am trying to make here... :-)

 

/Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> It would also be really nice it I could have a possibility to have a textfield in administration (simmilar when setting up Payment method)

You can. The built-in handlers are built around the same base classes as you use for your extensibility code. TThis means you can provide configuratiin options in the backend to. It's easy to do; just decorate public properties with some UI editors and Dynamiocweb will handle loading and saving the data for you. Check out the code for the existing providers to see how it's done.

Cheers,

Imar

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

In the documentation, take a look at the sections "Creating a checkout handler", "AddIn parameters" and "Advanced example".

As you can see in the first and third sections, there's no need to add anything to the database. Simply create a class with the attributes "AddInName" and "AddInDescription" that inherits from CheckoutHandler and place the assembly in the bin folder of the solution. This will cause your checkout handler to appear in the list.

In the second section, you can see how to add editable fields to your handler. You can also see the source code for the built-in handlers for more in-depth implementations. I would recommend either the Quickpay handler or the Dibs handler.

You mention a fee should be added. When you create a payment method on which you attach your checkout handler, you can specify a fee that is applied to the order. If this is not sufficient, you can subscribe to the Dynamicweb.Notifications.eCommerce.Order.BeforePaymentFeeCalculation and provide your own payment fee. The payment fee should not be set in the checkout handler code.

- Jeppe

 
Dmitrij Jazel
Reply

Hi Jeppe,

Nice! Thanks for information :) that is exactly what I needed!

First time you wrote your post (maybe it was just me) but I haven't seen the reference you made to the existing checkout handlers in the source-code section. But after I read Imars post, and looked at the sourcecodes, it all became very clear to me. And it was soo awesome, that I instantly went into it, and did not write back.

But this is extreemely usefull info you posted in the last post aswell.

So I must thank you Jeppe, and Imar for clearing this one out! :-)

I will let you guys know if I come across any issues along the way.

 

Cheers,

Dmitrij

 

You must be logged in to post in the forum