• Resolved michwii

    (@michwii)


    Hi community,

    I am creating a custom payment gateway that will integrate with a POS system.
    Here is the code : https://github.com/michwii/POC-GIVE-TPE-GATEWAY

    The flow :
    GivePlugin –> My Custom Gateway –> The POS system –> GivePlugin

    Inside the following method :
    add_action( ‘give_gateway_lane3000’, ‘lane3000_for_give_process_lane3000TPE_donation’ );
    I am redirectng to the POS system.

    My problem now is how to redirect from the POS system to the give plugin in order to validate the donation.
    While I am redirecting to the give plugin (https://mywebsite/donations/donation-form/)
    I am getting the initial form and not the confirmation of the payment.

    What are the parameters that I should give to the plugin in order to validate the donation ?

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    Hello @michwii,

    It seems that you have already found the How to Build a Gateway Add-on for GiveWP article – so you are off to a good start!

    For an Offsite Gateway, meaning a payment gateway that redirects offsite to complete the donation, you will want to redirect back to the Donation Receipt / Success Page. Below is a code sample for determining that URL:

    function getSuccessPageURL() {
            $url = get_permalink(absint(give_get_option('success_page')));
            return str_replace( ['http:', 'https:'], '', $url );
        }
    

    This will display the donation as pending. From there, the offsite gateway, in this case the POS system, would most likely send a webhook to the WordPress site notifying the Give plugin that the donation/payment has been completed.

    Currently, this webhook needs to be created for each offsite gateway. This could simply be a wp_ajax_nopriv_{$action} call that updates the status of the donation.

    If you are interested, we are working on a new Gateway API that provides more of this functionality out-of-the-box. You can contact me at [email protected] for additional details.

    Thread Starter michwii

    (@michwii)

    Hi Kyle,

    I’ve contacted you also by email.

    According to your method, the callback url is always : mysite.com/confirmation-de-don/

    It does not seems too secure…

    Let me explain :
    What if a malicious person abort the payment process in the offsite gateway and redirect himself to mysite.com/confirmation-de-don/

    The Give platform will consider that the payment has been completed while is not.

    How can we solve this issue ?

    Regards

    Regards,`

    A valid PayPal call includes a transaction key as a parameter. You are correct that the URL is publicly available, however, the key provides the security.

    Thread Starter michwii

    (@michwii)

    Thank you Oregondean for your answer.

    Is anyone know how :
    To generate this transaction key and Where ?
    How to validate it during callback and where ?

    Thank you for your help.

    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    The endpoint/url is public, yes, but does not itself complete the payment. Rather, the donation confirmation / receipt will use the last donation in the session and display the status of that donation, which is most likely processing. The public URL does not itself update the payment.

    Instead, your gateway will need to redirect to a custom URL, complete the donation, and then redirect to the public confirmation. Alternatively, your gatweway can redirect directly to the confirmation and use a webhook to later complete the donation (this is how Stripe works).

    Thread Starter michwii

    (@michwii)

    Thank you Kyle for your response.

    Could you please give me more details because I can’t find on the official documentation how to create a specific wp give endpoint that will update the payment ?

    Or the other method : How can I create a webhook to complete the donation ?

    Plugin Contributor Kyle B. Johnson

    (@kbjohnson90)

    There isn’t a specific way to create an endpoint for GiveWP, rather it is custom WordPress code, so you’ll have to hook into the request with an action, like init, and check for a custom query string. There is currently no enforced convention.

    Also, I should mention that at this point I am unable to support custom code. We do have documentation where we can and are continuing to improve the developer experience. Also, I would suggest looking at the Stripe and PayPal gateways included in GiveWP as example of gateways.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Payment Gateway Redirect to success page’ is closed to new replies.