Skip to content
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

Instant Payment Notifications (IPN) #56

Open
psrpinto opened this issue Jan 13, 2013 · 3 comments
Open

Instant Payment Notifications (IPN) #56

psrpinto opened this issue Jan 13, 2013 · 3 comments

Comments

@psrpinto
Copy link
Collaborator

AFAICT there is no clean way of handling payment notifications with the JMSPayment bundles. The current architecture assumes that any change in a Payment's state will be originated by the bundle itself. However, this is not always true: for instance, in the case of Paypal, a Refund will arguably almost always be done in Paypal's own web interface.

I should be able to easily tell the bundle that a certain payment was refunded as opposed to asking it to Refund it. There is a subtle but important difference. A concrete example of what I mean follows.

If I call

$ppc->credit($credit, $amount)

there will always be an external API call that will ask Paypal for a refund. However, what I need is something functionally equivalent to

$ppc->creditEvent($credit, $amount)

that will only update the local model and make no external API calls.

Is something like this part of the future plans for this bundle?

@psrpinto
Copy link
Collaborator Author

@schmittjoh After struggling for a few days, I've finally been able to integrate paypal's IPN with this bundle. I have updated this issue's description to reflect the problems I had and I'm reopening it.

For whoever is interested, I created a Service that you can drop into your application and automagically have IPN notifications handled for you. With this Service, you simply do:

<?php namespace Acme\SomeBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller

class OrdersController extends Controller
{ 
    public function paypalIpnAction ()
    {
        $notification = $this->getRequest()->request->all();
        $ipnHandler = $this->get('acme.paypal_ipn.handler');

        // This will trigger calls to the correct JMSPaymentCore methods 
        // according to the type of notification. After this call, the 
        // JMSPaymentCore DB tables will have been updated.
        $ipnHandler->process($notification);
    }
}

It uses two dirty hacks to workaround the current architecture but it's functional.

You can get it here: https://gist.github.com/4600319

@psrpinto psrpinto reopened this Jan 23, 2013
@neoshadybeat
Copy link

@regularjack why you don't do a pull request with that changes?

@psrpinto
Copy link
Collaborator Author

psrpinto commented Feb 3, 2013

@CayetanoSoriano Because this is not a clean solution for the problem. The correct way is for the bundle to expose an API for payment notifications.

ruudk pushed a commit to ruudk/JMSPaymentPaypalBundle that referenced this issue Apr 10, 2014
Add a default_method option to the Choose form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants