Custom payment module integration - guidelines

81 views
Skip to first unread message

erob...@gmail.com

unread,
Sep 29, 2020, 4:55:12 PM9/29/20
to YesCart - pure eCommerce, platform with open source
Hi all, are there any guidelines to integrate custom payment module with YC?

Any tips where should I start in YC with custom payment module integration having payment API specification?

Yes Cart

unread,
Sep 30, 2020, 2:45:50 AM9/30/20
to YesCart - pure eCommerce, platform with open source
Hi,

Looking at the spec your blueprint should be https://github.com/inspire-software/yes-cart/tree/master/payment-modules/payment-module-paypal , specifically PayPal button implementation.

In very simple terms you need an implementation of "PaymentGatewayExternalForm" and "CallbackAware". External form will allow to generate hidden fields that spec refers to "data and sign" and render a submit button. Callback from paysera would be sent to callback filter implementation but you do not need to implement that one - filter from base module can be reused which will invoke "CallbackAware" methods on your PG implementation to decode the parameters from Base64 and should check the signature (by the looks of it ss1 is simplest approach). All the "private" parameters like "projectId", "password" and callback configurations would be PaymentGatewayParameters, so SQL should be added to put those parameter definitions. Lastly there would be some configuration properties work to allow togging this module on and off.

One strange thing about the API though is that it does not ever seem to send "payment rejected" result, which could present a challenge. 
From the docs:
Payment status:
  • 0 - payment has not been executed
  • 1 - payment successful
  • 2 - payment order accepted, but not yet executed (this status does not guarantee execution of the payment)
  • 3 - additional payment information
So if you get a callback anything other than 1 - what happens? That is probably a clarification that should be addressed to Paysera. Potentially it could be only few cases that return anything other than 1 but then if we receive 2 and accept the order and then the order payment is rejected on their end - how will we get notified?

It sounds like a mouthful but it is not that complicated to put together, just few bits on the integration behaviour to clarify and you are golden.

What we can suggest is that if you are willing to collaborate on this, we can put out a branch on github with skeleton module (that will cover all the configs and basic classes) but then we will be waiting for your pull request on the actual implementation. Also that would mean that your plugin would become part of the core project, which could mean easier upgrades going forward.

Hope this was helpful and let us know your thoughts on the collaboration.

Regards,
YC team

erob...@gmail.com

unread,
Oct 3, 2020, 2:21:54 PM10/3/20
to YesCart - pure eCommerce, platform with open source
Thanks, that's a lot of information.
I think that would be a great idea to let me contribute. Also, if I would succeed, I'd ask PaySera to promote YC in their website as additional integration library with their payment system. 
Plus, YC is Java based, what is very unique, as currently PaySera supports only php integrations.
Please let me know when the branch will be create. Oh, and it might take a while for me to implement it, but I'll try my best

Yes Cart

unread,
Oct 7, 2020, 9:12:56 AM10/7/20
to YesCart - pure eCommerce, platform with open source
Hi,

Hope you are well.

Your PaySera foundation code branch is ready: https://github.com/inspire-software/yes-cart/tree/dev-4.0.0-paysera
It has all the elements, including rendering the pay button and the callback filter setup. 
Please follow the TODOs in code to fill in the implementation details which should distill to working with payinitdata.sql (to add extra parameters) and PaySeraCheckoutPaymentGatewayImpl.java to finish off the implementation.

Hope this helps and we shall be waiting for pull request (PR) from you. Summit your PR when you are ready with implementation and we shall review and merge it.

Regards,
YC team

erob...@gmail.com

unread,
Oct 8, 2020, 2:07:31 AM10/8/20
to YesCart - pure eCommerce, platform with open source
HI again, thanks a lot for a branch, I'll try my best

erob...@gmail.com

unread,
Oct 22, 2020, 2:59:17 PM10/22/20
to YesCart - pure eCommerce, platform with open source
HI, I need some tips here.
I've implemented request and able to navigate to Payment gateway an pay for the items.
But after payment, PaySera redirects me to PSC_ACCEPTURL parameter and all I get is payment result page and message that order placed.
But, no callback is invoked in the backend (breakpoints does not stop on debug mode). Any ideas what I am doing wrong?

URL that PG redirects me after successful payment is:

erob...@gmail.com

unread,
Oct 22, 2020, 3:15:17 PM10/22/20
to YesCart - pure eCommerce, platform with open source
Forgot to mention, that I'm 100% sure, that callbackUrl is passed to PG as this:
callbackurl=http://localhost:8080/paymentpayseracheckout so it should be invoked. I'm out of ideas 

Yes Cart

unread,
Oct 22, 2020, 4:46:34 PM10/22/20
to YesCart - pure eCommerce, platform with open source
Hi,

Firstly it is good that you get to the payment result page - that means that PaySera is "happy" and from their end they hand over back to your site. This part works on local as it is a browser redirect from PaySera site to your site which is running on your local.

For callback it is different - here PaySera server will send the data directly to callback url, which is in your case "http://localhost:8080/paymentpayseracheckout", which means this localhost is on the PaySera server. This is expected - callbacks can only be tested for publicly resolvable domains so that PaySera server can find your machine.

For development you need "manual intervention". Basically you need to get the example callback parameters+payload and then post it (e.g. using postman) to http://localhost:8080/paymentpayseracheckout  to simulate the "real flow". Not sure if you can trace this in PaySera sandbox console, or potentially you can setup basic server with public domain and trace the callback from there.

Hope this helps,
YC team

erob...@gmail.com

unread,
Oct 22, 2020, 5:36:22 PM10/22/20
to YesCart - pure eCommerce, platform with open source
That explains everything, thanks a lot.
I'll get back when changes are ready for review on git

erob...@gmail.com

unread,
Dec 28, 2020, 9:34:38 AM12/28/20
to YesCart - pure eCommerce, platform with open source
Hi again, finally I got back to this integration. I was stuck with SS2 validation, so I gave up and now validate only SS1 as it's much simpler, but not so safe. 
I will try to work on SS2 validation on final stage, when integration is complete, otherwise it will never be completed :).
So now I I able to pay on Paysera sandbox and I am getting a callback from Paysera when it's navigating back to shop after successful purchase. 
convertToCallback is invoked, I do validation and then BasicCallbackInfoImpl is returned with CallbackOperation.PAYMENT value.
But, after that I check the orders and it still says  "Pending payment" for that order. Also I noticed, that getExternalCallbackResult is never invoked, thats might be the issue, but I do not understand whether I should invoke it manually or it should be invoked by the system? I do understand, that this will have to return OK to make payment successful, but the method is not invoked. 

Yes Cart

unread,
Dec 28, 2020, 3:03:51 PM12/28/20
to YesCart - pure eCommerce, platform with open source
Hi,

When you mentioned "I am getting a callback from Paysera when it's navigating back to shop after successful purchase"
- do you mean you are receiving a callback on the "paySeraCheckoutCheckoutFilter" (i.e. BasePaymentGatewayCallBackFilter) which is mapped to "/paymentpayseracheckout"  in config file ( https://github.com/inspire-software/yes-cart/blob/dev-4.0.0-paysera/env/maven/dev-idea/config-module-paysera-on.properties )? 

Because this is where transition of the order from pending to "in progress" will happen. BasePaymentGatewayCallBackFilter converts the HTTP callback as "PaymentGatewayCallback" object and then invokes "paymentCallBackHandlerFacade.handlePaymentCallback(callback, false);". During this call transition occurs if the payment was recognised/validated (payment processor will invoke getExternalCallbackResult on its own and you do NOT need to call that manually from anywhere). If the callback is validated the order will transition to either "in progress" if the payment was accepted, or "cancelled" if the payment was not accepted by PaySera but it will transition in any case. 

It is strange as from what you are describing no transition happens and it sounds like you get a redirect to success page from PaySera but not the callback. Note that these are different. Redirect in browser to success page is for info only (as redirects in browser cannot be trusted) so no transition would happen. Callbacks are server to server comms which are more trusworthy and it is at this point that transitions of orders happen.

General note - as far as we reviewed the documentation from PaySera you do not need to invoke anything manually and base filter implementation should take care of the flow. All you need to do is the implementation of the PaySeraCheckoutPaymentGatewayImpl ( https://github.com/inspire-software/yes-cart/blob/dev-4.0.0-paysera/payment-modules/payment-module-paysera/src/main/java/org/yes/cart/payment/impl/PaySeraCheckoutPaymentGatewayImpl.java ) and make sure that callback is sent to /paymentpayseracheckout .

Regards,
YC team

P.S. Would be good if you commit your code to https://github.com/inspire-software/yes-cart/tree/dev-4.0.0-paysera as we may get a better understanding of the issue described.

erob...@gmail.com

unread,
Dec 28, 2020, 5:47:37 PM12/28/20
to YesCart - pure eCommerce, platform with open source
I posted a pull request here: https://github.com/inspire-software/yes-cart/pull/79/files

Yes, I mean I receive a callback and method convertToCallback is invoked with callback parameters provided.
But that is it, it constructs BasicCallbackInfoImpl and returns it.
I will try to debug handlePaymentCallback tomorrow and will get with more details

Yes Cart

unread,
Dec 28, 2020, 6:33:26 PM12/28/20
to YesCart - pure eCommerce, platform with open source
Would it be possible to send us (or create for us) a test user for PaySera and send it via contact form https://www.yes-cart.org/#contact together with instructions for setting up key payment gateway parameters. 

If you can, we might have someone from core team having a deep dive into it this week.

Regards,
YC team

erob...@gmail.com

unread,
Dec 29, 2020, 5:18:37 AM12/29/20
to YesCart - pure eCommerce, platform with open source
Details provided over email, let me know if you will need more details

erob...@gmail.com

unread,
Dec 30, 2020, 3:19:09 AM12/30/20
to YesCart - pure eCommerce, platform with open source
Replied over email, it works fine now with your updates, please proceed with merging to master. Paysera is supported by YesCart
Thank you

Yes Cart

unread,
Dec 30, 2020, 6:00:33 AM12/30/20
to YesCart - pure eCommerce, platform with open source
You are welcome, Happy New Year!

P.S. We will hold off merging to master for now and give a "2 week grace" period in case you find any bugs or problems. If you do find anything please let us know.

Reply all
Reply to author
Forward
0 new messages