This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

reynierpm
reynierpm

I don't know if this is possible or if it's a complete madness but I'm trying to execute a PHP method from AJAX call using Ajax Framework since I don't know how to fit this in a component code or in a plugin code and get it working with page lifecycle but is not working because I never get redirect to PayPal site as should be. The code below uses Omnipay library to redirect users outside OctoberCMS and execute a purchase method on PayPal page. I should say this is not the payment method at all, is some kind of confirmation, so when users click "Ok" or "Cancel" in both cases it will be redirected back to OctoberCMS site so I can process the flow in any case. The PHP code I'm trying to get working is this one:

public function onExecutePurchaseMethod()
{
    echo Session::get('amountToReload');
    $params = [
        'username'  => $this->username,
        'password'  => $this->password,
        'signature' => $this->signature,
        'testMode'  => $this->sandboxMode,
        'amount'    => Session::get('amountToReload'),
        'cancelUrl' => url( 'payment/step4', "", $secure = null ),
        'returnUrl' => url( 'payment/step2', "", $secure = null ),
        'currency'  => 'USD'
    ];

    $response = Omnipay::purchase($params)->send();

    if ($response->isSuccessful()) {
        var_dump($response);
    } else {
        var_dump($response->getMessage());
    }
}

What is happening is none redirection to PayPal is executed and page is getting stuck many times forcing me to close the browser and reopen again, no method is executed, no visible errors, no redirection to PayPal site. It's possible to do what I'm trying to do? Is not a madness? If it's possible where is my error?

Last updated

andrew
andrew

I think you'll want to do two things. Submit the form as normal, then process it and the redirect.

http://stackoverflow.com/questions/20756067/omnipay-paypal-integration-with-laravel-4

Then after successful paypal auth, move on to step 2.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.