Easy Digital Downloads
[resolved] hook for successful paypal purchase (6 posts)

  1. ChichipioWilson
    Posted 3 years ago #

    Hello, bear with me for a brief paragraph describing my situation. I promise there's a question after that.

    I'm using Zapier, a service that let's you hook some actions in one application and trigger some reaction in others. For example, they have a "subscribe user to mailchimp list on successful paypal transaction" and it works great. They provide you with a url that you can use as your IPN listener... and there's the problem. I want EDD to process the IPNs for obvious reasons.

    The only solution I found was to add a bit of extra code at the end of the edd_process_paypal_ipn() function (the file is paypal-standard.php. Down there, I still have access to $encoded_data_array and can use it to form a custom $remote_post_vars and send it to zapier's url. It works. EDD gets to process the IPN and zapier gets to have its own copy in case the transaction was successful.

    Here's the thing, though. That's the only place I found to make the change, so after every update I have to go back and re-apply the change. It would be great if I can have my little bit of code separately (as a plugin or in functions.php) that hooks an action on a successful transaction.

    Would this be possible? Or maybe it already is and I'm missing something?

    BTW, this was the solution that first came to mind, but I accept opinions on whether there are better options that don't require this little modification.



  2. Pippin Williamson
    Pippin's Plugins and Plugin Reviewer
    Plugin Author

    Posted 3 years ago #

    You will want to hook into the edd_update_payment_status hook, like this:

    function demo_edd_completed_purchase( $payment_id, $new_status, $old_status ) {
    	if ( $old_status == 'publish' || $old_status == 'complete' )
    		return; // Make sure that payments are only completed once
    	// Make sure the payment completion is only processed when new status is complete
    	if ( $new_status != 'publish' && $new_status != 'complete' )
    add_action( 'edd_update_payment_status', 'demo_edd_completed_purchase', 100, 3 );
  3. ChichipioWilson
    Posted 3 years ago #

    Thanks, Pippin. Much appreciated.

  4. db9429
    Posted 3 years ago #

    Hi ChichipioWilson

    I'm trying to do EXACTLY what you are doing.

    Did you have any luck in the end?

    Zapier seems to pick up transactions that don't go through EDD, so I suspected it was the notification_url that was hard coded into the EDD button, perhaps.

    Although seeing your post, I might have been wrong.

    I don't really understand what you did to fix it above, and I'm not quite sure about hacking around in the core EDD files.

    If you have any pointers, I would greatly appreciate it!


  5. Pippin Williamson
    Pippin's Plugins and Plugin Reviewer
    Plugin Author

    Posted 3 years ago #

    @db9429 Can you tell me exactly what you're trying to do? Is it an integration with Zappier?

  6. db9429
    Posted 3 years ago #

    Hey Pippin,

    I've actually opened a thread on the EDD forum too:


    I think that outlines what I'm trying to achieve :)


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Easy Digital Downloads
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic