nette-paypal icon indicating copy to clipboard operation
nette-paypal copied to clipboard

Callbacks in onSuccessPayment[] never gets called

Open JanMikes opened this issue 8 years ago • 3 comments

I have done everything exactly according to documentation, but unfortunately script is not working for me. When i click on button, i get redirected to paypal, which is ok, after sandbox payment (have tested without sandbox mode as well) i get redirected back, callback onConfirmation() is invoked and nothing happens afterwards - no balance is transfered as well.

Last thing that happens is calling component handler handleConfirmation() nette action looks like Video:User:orderDetail paypalButton-confirmation!

As i checked code, there is function confirmExpressCheckout() which is NEVER called and i think there is something wrong with it, as well it contains onSuccessPayment() which should invoke callbacks.

JanMikes avatar Mar 09 '16 10:03 JanMikes

Working workaround:

$control->onConfirmation[] = function($data) use ($control) {
    $this->confirmOrder($control, $data);
};
public function confirmOrder($control, $data)
{
    $control->confirmExpressCheckout();
}

Though i dont know it is supposed to work like this or there is nicer way. Using this solution as well balance is changed on both accounts affected.

JanMikes avatar Mar 09 '16 11:03 JanMikes

@Lexinek That's the way it's supossed to work. You should have control over payment confirmation, you may want to run some checks (i.e. order status in DB) before accepting the payment.

Current docs are unclear about that. Would you mind creating a PR? :)

fmasa avatar Mar 18 '16 23:03 fmasa

The question is whether we need separate onSuccessPayment event. Do we?

fmasa avatar Mar 21 '16 15:03 fmasa