Post by a110y » Tue Sep 07, 2010 4:54 pm

Hi,
I need to implement a system where, upon payment by the customer I need to extract x % of the payment and transfer it to another account. Is it possible to do it without modifying the core? Are there any payment hooks that get called after the amount it paid? Do I have to create my own "Payment Gateway" that calls the hooks?
Thank you.

Newbie

Posts

Joined
Wed Sep 01, 2010 4:47 am

Post by Qphoria » Tue Sep 07, 2010 7:19 pm

There are no hooks yet, but we will keep this in mind as one of the hook events.

For now, you can simply add this type of event pretty easily to the existing system. When checking out, the main function is the catalog/model/checkout/order.php file in the "confirm" function.

That is where the actual order is confirmed and the final total is available there. From that point, you could simply insert a one line "include('path/to/your/mod');

Then in your file use the available variables from that function to get the order total and pass it to your automatic payout script

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by a110y » Tue Sep 07, 2010 8:26 pm

I see, if I understand you correctly, I will have to edit the file catalog/model/checkout/order.php and include my script which calculates x % of the payment made and makes a call to the payment gateway to transfer the fee from the source account to the destination account?

Newbie

Posts

Joined
Wed Sep 01, 2010 4:47 am

Post by Qphoria » Tue Sep 07, 2010 8:56 pm

Correct

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by a110y » Tue Sep 07, 2010 9:22 pm

A few more questions, if you don't mind. :)

How do I make this transfer transparently (i.e. without any user interaction), or is it even possible using the default payment drivers offered by opencart?

Newbie

Posts

Joined
Wed Sep 01, 2010 4:47 am

Post by Qphoria » Tue Sep 07, 2010 9:29 pm

a110y wrote:A few more questions, if you don't mind. :)

How do I make this transfer transparently (i.e. without any user interaction), or is it even possible using the default payment drivers offered by opencart?
It has nothing to do with the drivers. The code is completely up to you. The only change you need to make in opencart is a one-line insert to include your script. You would only need to pass in the total from opencart and your script would need all the information for your gateway and the connection information (e.g. curl)

So if you are accepting a payment from paypal for example, you get paid 100.00
OpenCart gets the confirm signal from the payment page. It runs that confirm() function in the checkout/order.php file

Then you include your file and reference the $order_info['total'] value of 100.00

You do the math of how much you want to send
$amount = x/100.00

and then using the API for that gateway you would send the amount and any other required data (merchant id, security codes) for that payment gateway in your script via curl. Then get the response.

But this is all in your include script. OpenCart only passes the amount to you. The rest is in your code

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 110 guests