PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Form Payment API integration help?

  1. I am working on a donate form (http://www.avance.org/donate/) to integrate with pyrix API (http://code.google.com/p/piryx-api/wiki/Payments).

    On the form, under Contribution Amount, there are two donation amounts. 1. is a drop-down with set amounts, or if you click "Other", conditional logic will allow you to enter another amount instead. Right now I have it set only to pull ('Payment' => $entry['24'],). How do I write the code to make it pull 'Payment' => $entry['16'], if there is no amount selected in $entry['24']?

    <?php
    add_action('gform_after_submission_2', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
    
        $post_url = 'https://secure.piryx.com/api/accounts/iLE6xTsx/payments';
        $body = array(
            'CampaignCode' => $entry[''],
            'Amount' => $entry['15'],
    	'Payment' => $entry['24'],
            'Description' => $entry['21'],
            'CardNumber' => $entry['38'],
            'CardSecurityCode' => $entry['41'],
    	'CardExpirationMonth' => $entry['39'],
            'CardExpirationYear' => $entry['40'],
            'RoutingNumber' => $entry['25'],
            'AccountNumber' => $entry['26'],
    	'BillingAddress1' => $entry['31'],
            'BillingAddress2' => $entry['42'],
            'BillingCity' => $entry['32'],
            'BillingState' => $entry['33'],
    	'BillingZip' => $entry['34'],
            'BillingPeriod' => $entry['28'],
            'TotalPayments' => $entry['29'],
            'Email' => $entry['36'],
    	'FirstName' => $entry['2'],
            'MiddleName' => $entry['3'],
            'LastName' => $entry['4'],
            'Phone' => $entry['10'],
    	'WorkPhone' => $entry['11'],
            'MobilePhone' => $entry['13'],
            'FaxPhone' => $entry['12']
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    
    }
    ?>
    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  2. Before line 5, I would add this:

    [php]
    if (defined($entry['24'])) {
    	$payment= $entry['24'];
    }
    else {
    	$payment = $entry['16'];
    }

    Then on line 09, change it to use this new variable rather than the $entry['24']:

    [php]
    'Payment' => $payment,

    That will use field 24 if it is defined or if not, will use field 16.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink