X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Popup custom payment module is posting and redirecting (https://forum.x-cart.com/showthread.php?t=74142)

akinyeleolubodun 06-29-2016 09:11 PM

Popup custom payment module is posting and redirecting
 
Hi,

I am developing a custom payment plugin that is meant to work like Stripe.8)

I have in my payment.js, the below code

Code:

core.bind(
  'checkout.main.initialize',
function() {

    core.bind(
      'checkout.common.ready',
function(event, state) {

        $( "#kpay-pay_trigger" ).click();
state.state = false;
}
    );
}
);


This shows the popup fine but I have a challenge with it posting and redirecting. It doesn't make the popup state well enough for the user to perform payment action.

Please I need an urgent help on this.

Regards.

qualiteam 06-29-2016 10:29 PM

Re: Popup custom payment module is posting and redirecting
 
Hello,

SimplifyCommerce and PayPal are two other modules that behave like Stripe module and use a similar way to hack into the flow. So, you may check the source code of these modules too.

Please can you explain the issue with more details? As far as I see you use a different JS code than Stripe module, so it may be the cause.
What is the desired flow, and what in the flow goes wrong at the moment?

akinyeleolubodun 06-30-2016 12:26 AM

Re: Popup custom payment module is posting and redirecting
 
Thanks for your reply qualiteam. I have gone through the source codes and code not really make headway.

Here is the flow...

1. I add the payment plugin js to the checkout page (Working)
2. Build some data on the template (Working, find below sample code)
Code:

<div id="kpay-pay-component" style="display: none;"></div>
<script src="{getScriptInstance()}"></script>
<script>
new KongaPay({
    merchantId: "{getMerchantId()}",
merchantName: "{getMerchantName()}",
callBack: "{getCallbackUrl()}",
amount: "{getItemsTotal()}",
transactionReference: "{getTransactionReference()}",
buttonSize: 300,
description : "{getDescription()}"
});
</script>


3. When the payment gateway loads the JS, it displays a button to be clicked in
Quote:

<div id="kpay-pay-component" style="display: none;"></div>

4. I hide the element so that when the user clicks the "Place Order" button on checkout, it clicks the button displayed by the payment gateway dynamically. (Worked well)

5. When the payment gateway popup comes up, it doesn't stay...other process happens and the page is being redirected.

Quote:

As far as I see you use a different JS code than Stripe module, so it may be the cause.

Yes it is not Stripe's code, I strip it down to the barest minimum because it contains code that are not conforming to my payment gateway flow.

I suppose the
Code:

state.state = false;
in the JS would stop the page from reloading but I was wrong. Maybe I am not initiating the right bind event.:(

akinyeleolubodun 07-01-2016 01:28 AM

Re: Popup custom payment module is posting and redirecting
 
Please help ^^^^

qualiteam 07-05-2016 01:19 AM

Re: Popup custom payment module is posting and redirecting
 
state.state determines whether the order can be placed, or not. If you set it to false the order will never be placed.
Stripe module sets this property to false if the module is enabled, but the token from Stripe is empty.

The recommended way to initialize the JS part of your integration is hooking to the checkout.paymentTpl.postprocess event (like Stripe does).

Where does the redirect happens to? Does it submit to the payment gateway's server? If so, you should either put that into an IFRAME, or use the standard flow for web-redirect based integrations (without any background checks).


All times are GMT -8. The time now is 11:57 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.