-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[payum][paypal] add suppor of instant notifactions. #725
Conversation
@makasim I was working on another payment that also needs IPN, and I found a bug where payment token is removed by PurchasStep when cart is abandoned. This will result in following error:
I will test this PayPal branch soon when I complete mine, thanks! |
That's expected Behavior. Token has to be deleted. For IPN you have to Pay attention that not all payments allow define notify url per payment.
|
@makasim Thank you for your quick reply, I will have a look at the token factory. In my case my payment gateway doesn't allow me to define notify url for each payment, but it does pass the token in POST request, so I overrided the default HttpRequestVerifier to read the token. Thank you again! |
Oh I think I knows what you mean. I can define route in the notify token. Interesting. |
We should avoid customizing |
@makasim Right. Maybe an action for throwing For now I am doing everything in a custom route / controller to avoid modifying |
you can do it right now. Just throw ResponseInteractiveRequest with needed response set inside your notify action. |
@makasim You are right, forgot about interactive request. One more thing, I think we should compare the IPN transaction amount against Sylius' order amount. Because if someone use https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-info-outside |
that's not required for paypal. since we define new notify token for each new payment. User dont see as the notify url passed directly to paypal server from our. But in case of be2bill for example this THE MUST. Be2bill If you can relly on |
This branch is outdated, @makasim will you have time to update this pull request? Thanks. |
@kayue rebased |
@stloyd fixed |
|
||
$status = new StatusRequest($order); | ||
$this->payment->execute($status); | ||
$payment->setState($status->getStatus()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done between the 2 dispatched events (pre and post), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually not, The pre and post events expect to get new state from payment object where the previous one passed as an event parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant: what is the point of dispatching 2 events with exact same parameters? (the $order and $previousState variables don't vary)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it mean 'just to be compatible". Pre event means before we actually saved anything to db, so you can change state to another one, post event means we cannot change anything in payment object.
Since the save will be done later (when we return from this action) we cannot do save between pre and post without injecting extra dependency. To keep things simple I decided to dispatch events so you can change state in post event too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe just dispatch the "pre" event then, to avoid any confusion
Le 15 janv. 2014 15:58, "Maksim Kotlyar" notifications@github.com a écrit
:
In src/Sylius/Bundle/PayumBundle/Payum/Paypal/Action/NotifyOrderAction.php:
- {
/*\* @var $request SecuredNotifyRequest */
if (!$this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
/*\* @var OrderInterface $order */
$order = $request->getModel();
$payment = $order->getPayment();
$previousState = $payment->getState();
$this->payment->execute(new SyncRequest($order));
$status = new StatusRequest($order);
$this->payment->execute($status);
$payment->setState($status->getStatus());
here it mean 'just to be compatible". Pre event means before we actually
saved anything to db, so you can change state to another one, post event
means we cannot change anything in payment object.Since the save will be done later (when we return from this action) we
cannot do save between pre and post without injecting extra dependency. To
keep things simple I decided to dispatch events so you can change state in
post event too.—
Reply to this email directly or view it on GitHubhttps://github.com//pull/725/files#r8888660
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@winzou I dont think its a good idea, One can have a listener subscribed to post event (let's say it sends an email to admin) and he would be surprised to see its not working. IMO it is better to dispatch both.
@makasim Testing in Sandbox mode, the notify controller returning
|
@makasim will you have time to work on this pull request? I think I can help you with fixing the exception and test it, but I don't know how to write php specs and make it standalone. Do you must have them before merge? Thanks! |
@kayue have you added notify action in actions:
- sylius.payum.paypal.action.notify_order |
@makasim I did. I guess PaymentDetailsSyncAction supposed to be executed, but it doesn't support Order. public function supports($request)
{
if (false == $request instanceof SyncRequest) {
return false;
}
$model = $request->getModel();
if (false == $model instanceof \ArrayAccess) {
return false;
}
return isset($model['PAYMENTREQUEST_0_AMT']) && null !== $model['PAYMENTREQUEST_0_AMT'];
} Maybe we need another ExecuteSameRequestWithPaymentDetailsAction to transform Order to Payment. public function supports($request)
{
if (false == $request instanceof SyncRequest) {
return false;
}
$model = $request->getModel();
if (false == $model instanceof \ArrayAccess) {
return false;
}
return isset($model['PAYMENTREQUEST_0_AMT']) && null !== $model['PAYMENTREQUEST_0_AMT'];
} |
@kayue I hope I fixed SyncRequest not supported issue with last commit (formapro-forks@3b2750d) |
@makasim Working now 👍 |
cool, I would try to add specs on coming weekend. |
specs added, ready for final review and merge! |
Thank you so much @makasim ! 👍 |
@makasim Looks good to me. Awesome work. Green light from my side so when the build turns green as well, go ahead and merge it. Thank you! |
[payum][paypal] add suppor of instant notifactions.
👍 |
[payum][paypal] add suppor of instant notifactions.
This address #457 RFC. I haven't able to test it in real life but pretty sure it has to work. Any one willing to test it?
TODO: