Post by basson.vandermerwe » Mon Dec 19, 2016 3:20 pm

Hi All,

I have created a custom payment method the same as PP_Standard with curl requests and responses to the OpenCart 2.3.0.2 system and a external Payment Gate Way (also self developed ), And the responses works 100%, I get the totals and the order_id,order_info correct,customer info correctly and responded correctly to the call back URL and it works when I pay the full amount.
My issue comes in when I want to only pay let say 80% of the requested amount and return the callback URL and set the Order Total to the total - the amount Paid.
And then let the user use a Credit Card payment to pay the 20% outstanding on the order to complete the sale.

But for some reason I cannot get the getTotal() array correct to adjust the total. I have tried calling the extension/total/custom.php to adjust the order total and tried to change it in the extension/payment/custom.php. But no Luck at all.

Can someone please tell me what array or call function to use to adjust the order total from a payment extension and return it to the checkout url ?

Any help would really be appreciated, As am totally new to OpenCart development and my php know how is questionable.

Thank you in advance


Posts

Joined
Mon Dec 19, 2016 2:59 pm

Post by artcore » Tue Dec 20, 2016 12:47 am

Hallo,
If I understand correctly you want to send a partial total amount to the payment gateway and leave the remainder to be paid at a later time?
You can easily adjust the order total using a custom order totals module. See catalog/model/(extension)/total for examples. Leave out (extension) if not on OC 2.3+
You would have to write some more code to deal with the remaining balance though like record this amount somewhere so you can bill your clients later on.

User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by basson.vandermerwe » Tue Dec 20, 2016 12:58 am

Thank you for taking the time to answer my question artcore.

The system I have is a external Customer Portal Payment system (Clients deposit a monthly fee into the portal to use at the company)

The customer gets to the checkout and selects the Portal payment as a payment method.
Opencart then queries the external server and requests the customers balance.
If the balance is more than the requested order total then the system will complete the order.
This works

But if the customers has a balance less than the required amount. the balance has to be subtracted from the total amount. and the order should return to the checkout so the customer can select a different payment method to pay the outstanding balance.

Thus I need to change the Subtotal on the checkout page to the outstanding amount

Hope this explains it more cleary

Regards,


Posts

Joined
Mon Dec 19, 2016 2:59 pm

Post by artcore » Tue Dec 20, 2016 3:29 am

I understand. So you can stop the payment if leaving a negative balance - easiest, just tell them to add funds first - or enable other payment methods when it falls short. The hard part is to have the remainder paid using a secondary method. I assume you want to use up the current funds first and only after confirming at the last step. In that case writing a custom order totals module is still a good choice.

User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by basson.vandermerwe » Tue Dec 20, 2016 3:42 am

Hi artcore,

yes that is what I want. Unfortunately the hard part is the choice, as the customer will want to use their funds for the purchase. I tried the load module/extension/total/custom where i have written a short php code to getTotal() - $this->get->post['balance'] and then set the $total -=($total - $this->get->post['balance']) which does the correct calculations. But it does not update my cart outstanding balance. I maybe thought that I could do it via ajax or json. But even then the subtotal is still the full amount after the callback url pushes back to the checkout/checkout URL.

I was hoping to set the subTotal from the checkout page without including and total extension as that would be a lot more sufficient than redirecting and callback on callback and curl all over the place


Posts

Joined
Mon Dec 19, 2016 2:59 pm

Post by artcore » Tue Dec 20, 2016 5:51 am

If you add the balance to the order total once they logged in, the cart will update even during checkout. Put the sort order of the custom order total just before the total. Possibly with some condition when their balance is higher than the checkout total = 0.

User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by basson.vandermerwe » Tue Dec 20, 2016 1:40 pm

Thanks artcore,

Will try as suggested and revert back.
Hopefully all these hours will not be in vain.

Regards,


Posts

Joined
Mon Dec 19, 2016 2:59 pm
Who is online

Users browsing this forum: No registered users and 14 guests