Giter Site home page Giter Site logo

Comments (5)

kharanenka avatar kharanenka commented on June 12, 2024

Hi!
Method in MakeOrder component returns only URL for redirect. $.request() method redirects to this URL. You can change redirect logic in success function of $.request() method.

from oc-omnipay-shopaholic-plugin.

jpenaroche avatar jpenaroche commented on June 12, 2024

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.

bcwaretx avatar bcwaretx commented on June 12, 2024

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.

alex-mokkas avatar alex-mokkas commented on June 12, 2024

@bcwaretx Can you provide the code for this logic?

from oc-omnipay-shopaholic-plugin.

bcwaretx avatar bcwaretx commented on June 12, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.