Post by jprustv » Mon Jul 16, 2018 8:24 pm


Trying to create an extension where I need to redirect the user (merchant) to a third party payment website where he will log in and give authorization (OAuth 2.0) to handle payments. Once he does that, he will be redirected to the REDIRECT_URI I supplied.
Currently, I'm supplying REDIRECT_URI with my extension edit page url followed by his current user_token.. something like this: ... 6Def789Ghi
The third party payment website appends an authorization code to my REDIRECT_URI, making it something like: ... =123456789
(Note the '?' before authorization code).

Here is the problem:
When the new formed URL is loaded, it asks the user for Login again because user_token is '123Abc456Def789Ghi?authorization_code=123456789' (?auth.. is appended to user token).

I was able to fix it by editing the admin/controller/common/header.php file and 'fixing' the query parameters. All is working fine buuuut... Since I want this to be an extension, I need to find another way of doing this that doesn't require me to edit anything outside of my extension files.

Since it uses OAuth 2.0 I'm pretty sure someone has already came up with this problem and was hoping they could tell me how they solved it :D



Wed Jul 11, 2018 12:42 am

Post by straightlight » Sat Jul 21, 2018 3:54 am

As a new forum user, please follow the forum rules, No OC version posted.

However, there are plenty of examples that can be seen regarding callback methods in your catalog/controller/extension/payment folder. However, since your extension is about handling payments, it is best practice to create a local API with the api token rather than the user token in this case since Opencart can already handle all payments, shipping and order totals via the already implemented API solutions these days. Also considering event files would also be ideal to achieve this.

Based on the provided analogy for editing the admin header controller, this strategy is not needed in order to gather results via APIs anymore compared to prior OC versions.

You can also see API examples from your catalog/controller/api folder.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Legendary Member


Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 12 guests