eventespresso / event-espresso-core

Event Espresso 4 Core for WordPress: Build an Event Ticketing Website Today!
https://eventespresso.com
GNU General Public License v3.0
121 stars 87 forks source link

Gateway payment update callback #228

Closed s3rgiosan closed 7 years ago

s3rgiosan commented 7 years ago

Is this a bug report?

Hi,

I'm implementing an onsite payment method for a gateway that generates ATM payment references, and I need to provide a callback URL for the gateway handle the payment update.

How can I do something like this using the plugin API?

Regards

mnelson4 commented 7 years ago

hi @s3rgiosan! Have you already read over https://github.com/eventespresso/event-espresso-core/tree/master/docs/L--Payment-Methods-and-Gateways ?

s3rgiosan commented 7 years ago

Hi @mnelson4,

Thanks in advance for your support.

Yes, I did and I've used the addon skeleton to generate most of the base files of the plugin.

But I have some doubts/questions that I can not clarify even reading your documentation, or where I can "fit" my case. For instance:

s3rgiosan commented 7 years ago

Hi @mnelson4

I've decided to implement an offsite payment method since it is the only one that allows you to process payments via callback / IPN. Right?

Is there a way to redirect directly to the thank-you page, since this gateway does not have a page for offsite payment?

mnelson4 commented 7 years ago

, The payment method generates a reference (using an external lib) for payment on the site itself and then the customer uses that reference to pay in an ATM. Is the payment method on-site, off-site or offline?

interesting! I've never heard of anything like that. That has elements of "offline", seeing how the payment is actually happening later at an ATM somewhere; but it also has elements of "offsite" seeing how it's sending an IPN.

I've decided to implement an offsite payment method since it is the only one that allows you to process payments via callback / IPN. Right?

Yes, it's the only one that handles them. You could make another payment method handle an IPN, but you'd basically need to write the code that detects the IPN yourself.

Is there a way to redirect directly to the thank-you page, since this gateway does not have a page for offsite payment? Yes, inside your gateway class' set_redirection_info method, set the payment's redirect_url to the provided $return_url. ie $payment->set_redirect_url($return_url);. I haven't tested that but it should work

s3rgiosan commented 7 years ago

@mnelson4 many thanks for your answers and support. Realy appreciate it.

Yes, inside your gateway class' set_redirection_info method, set the payment's redirect_url to the provided $return_url. ie $payment->set_redirect_url($return_url);. I haven't tested that but it should work

It worked, thanks! But before showing the "thank you" page, it shows a redirect info "Forwarding to secure payment provider". Is there any way of bypassing or customizing this? The text or the 10 seconds timeout?

mnelson4 commented 7 years ago

@s3rgiosan do you have any other offsite payment methods active or do you plan it? If not, you can change the translation of Forwarding to Secure Payment Provider. (from modules/single_page_checkout/reg_steps/payment_options/EE_SPCO_Payment_Options.class.php).

s3rgiosan commented 7 years ago

Hi @mnelson4,

Once again many thanks for your answers and support.

For future reference for other developers, I'm going to leave here my approach to this problem.

Problem

Integrate a payment method that behaves like an Offline payment method, in the sense that generates a specific ATM reference for a transaction, needs an IPN callback (only available on Offsite gateways) URL to process the payment but does not have support to a redirect to page like typically an Offsite gateway has (see PayPal, for instance).

Solution (simplified version)

s3rgiosan commented 7 years ago

@mnelson4 by using an EE_Onsite_Gateway I was able to avoid the, unnecessary, redirect screen.

mnelson4 commented 7 years ago

ah good idea there @s3rgiosan. Yeah if you use the onsite gateway it won't show the redirection popup. Thanks for posting your solution