Comments (5)
Hi!
Method in MakeOrder component returns only URL for redirect.
from oc-omnipay-shopaholic-plugin.
Ok, well i wondered if there is a functionality built-in to get redirect method directly from getRedirectMethod of Omnipay and make the redirection on $.request() using the previous fetched method from Omnipay, but, well i suppose i have to write it :) Thanks a lot for your answer 👍
from oc-omnipay-shopaholic-plugin.
We hacked the MakeOrder component in order to expose the native Omnipay function that will build the form and auto-redirect with a POST to the gateway. It works for our specific implementation but I'm not sure about the repercussions for any others so we had not files as a Bug or PR.
from oc-omnipay-shopaholic-plugin.
@bcwaretx Can you provide the code for this logic?
from oc-omnipay-shopaholic-plugin.
@bcwaretx Can you provide the code for this logic?
Our solution calls OrderPage::onPurchase() from the PHP code rather than an AJAX request, though it should work with either since original component had redirect, but only did a URL redirect.
Change is to OrderPage component in Orders for Shopaholic:
Original onPurchase() (starting at line 95)
if ($obPaymentGateway->isRedirect()) {
$sRedirectURL = $obPaymentGateway->getRedirectURL(); // <-- Returns only the URL
return Redirect::to($sRedirectURL);
} else {
if ($obPaymentGateway->isSuccessful()) {
Result::setTrue($obPaymentGateway->getResponse());
} else {
Result::setFalse($obPaymentGateway->getResponse());
}
}
Modified onPurchase, returning the native redirect action object from Omnipay:
if ($obPaymentGateway->isRedirect()) {
return $obPaymentGateway->getRedirectAction(); // <-- Native redirect action from Omnipay Gateway class
} else if ($obPaymentGateway->isSuccessful()) {
Result::setTrue($obPaymentGateway->getResponse());
} else {
Result::setFalse($obPaymentGateway->getResponse());
}
return Result::setMessage($obPaymentGateway->getMessage())->get();
You will also need to modify the PaymentGateway helper in this plugin to support the method. We added this getRedirectAction() method after getRedirectURL() in
plugins/lovata/omnipayshopaholic/classes/helper/PaymentGateway.php
/**
* Get redirect Action
* @return string
*/
public function getRedirectAction()
{
if (empty($this->obResponse)) {
return '';
}
return $this->obResponse->redirect();
}
I have not submitted to Orders plugin since I do not know how this would behave without the Omnipay plugin present, but I'm sure there is a way to support both. HTH!
from oc-omnipay-shopaholic-plugin.
Related Issues (13)
- Incorrect plugin meta information HOT 1
- Omnipay\Omnipay class doesn't exist HOT 1
- Documentation HOT 6
- Choosing the composer.json way to install HOT 16
- Upgrade to Omnipay 3.x HOT 6
- Add Stripe Payment Processing Component HOT 3
- No longer working with octobercms laravel 6 +
- Omnipay bug HOT 8
- Using order secret to pay the order HOT 2
- PayPal REST Gateway token generation HOT 3
- Error since last updates
- Can't see Settings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oc-omnipay-shopaholic-plugin.