php - wordpress Gravity forms bank account payment

40

I am trying to make a page with gravityforms to make a transaction with a bank account payment.

I need to send data to iDevAffiliate database.

The response with the support and google searching has led me to just work with this function

add_action( 'gform_post_payment_completed', my_function,  10, 2 );

i don't understand what is this function my_function that probably i need to make on my own and what are these last two parameters 10 and 2 ?

In some examples i find$entry and$action ascotiative arrays that i don't understand how to put data in them.Do they get filled in automatically or i need to fill them in ?

I don't understand anything from the documentation here: https://www.gravityhelp.com/documentation/article/gform_post_payment_completed/

and i found a github example that i don't understand eighter. https://gist.github.com/NikV/7b7ec046df69b1f390bf.

If there is someone that uses these forms or has a working example i would want to see it.Or get a more clear explanation about that function and parameters that i need to pass in.

232

Answer

Solution:

The add_action call

Theadd_action call is part of Wordpress, not of the gravityforms component, as you can find here.

  • The first parameter contains the function to be called (in your case "gform_post_payment_completed").

  • The second contains the so-called "callback function", a function that is triggered as soon as the first function has been executed completely.

  • The third parameter is an internal priority flag for Wordpress

  • the last parameter tells Wordpress how many parameters are going to be transmitted to the initial function, in case of the given function two parameters ($entry and$action) are sent to the initial function.

As soon as the call has finished, the callback function is invoked that could i.e. tells a visitor that the payment has been accepted or to redirect him to a download page or whatever your business case is.

The $entry and $action parameters

The$entry parameter contains all information about the subscription that is currently handled, the may help you understand more about it and here's the documentation for it.

The$action contains information about the currently executed command (i.e. change subscription, execute payment), just search for "$action" on the documentation page for GFPaymentAddon.

I haven't used Gravity Forms but I hope you'll find the necessary details on the documentation pages.

Sending part of the data to an external page via curl

As mentioned before, I haven't used the Gravity Forms component and can't test it, but it should work similar to this:

function gfroms_after_payment_complete( $entry, $action ) {

    // for more info, check https://www.gravityhelp.com/documentation/article/entry-object/

    $orderNo= $entry['id']; // not sure if this would be the order number but it should be a unique payment ID
    $ipAddress= $entry['ip'];
    $amount= $entry['payment_amount'];

    curl_setopt($ch, CURLOPT_URL, "fund.abarila-foundation.org/…Summe:{$amount}&idev_ordernum={$orderNo}&ip_address={$ipAddress}");
}
// Tells the notification to be sent only when this hook is found and to include the arguments ($entry and $action)
add_action( 'gform_post_payment_completed', 'gfroms_after_payment_complete',  10, 2 );

People are also looking for solutions to the problem: HTML form action with php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.