The gform_paypalpaymentspro_api_before_send filter allows the API information to be modified before sending to PayPal Payments Pro.
Usage
add_filter('gform_paypalpaymentspro_api_before_send', 'your_function_name', 10, 2);
Parameters
- $api_info (array): The API information: API_Endpoint, API_UserName, API_Password, Vendor, Partner.
- $form_id (int): The current form id.
More information
See Gravity Forms Docs: gform_paypalpaymentspro_api_before_send
Examples
Change PayPal Endpoint
This example changes the PayPal API endpoint to the sandbox URL.
add_filter('gform_paypalpaymentspro_api_before_send', 'change_paypal_endpoint', 10, 2); function change_paypal_endpoint($api_info, $form_id) { $api_info['API_Endpoint'] = 'https://pilot-payflowpro.paypal.com'; return $api_info; }
Modify API Username
This example modifies the PayPal API username based on the form ID.
add_filter('gform_paypalpaymentspro_api_before_send', 'modify_api_username', 10, 2); function modify_api_username($api_info, $form_id) { if ($form_id == 1) { $api_info['API_UserName'] = 'new_username'; } return $api_info; }
Modify API Password
This example modifies the PayPal API password based on the form ID.
add_filter('gform_paypalpaymentspro_api_before_send', 'modify_api_password', 10, 2); function modify_api_password($api_info, $form_id) { if ($form_id == 2) { $api_info['API_Password'] = 'new_password'; } return $api_info; }
Modify Vendor and Partner
This example modifies the PayPal Vendor and Partner information based on the form ID.
add_filter('gform_paypalpaymentspro_api_before_send', 'modify_vendor_partner', 10, 2); function modify_vendor_partner($api_info, $form_id) { if ($form_id == 3) { $api_info['Vendor'] = 'new_vendor'; $api_info['Partner'] = 'new_partner'; } return $api_info; }
Reset API Info
This example resets all the API information for a specific form ID.
add_filter('gform_paypalpaymentspro_api_before_send', 'reset_api_info', 10, 2); function reset_api_info($api_info, $form_id) { if ($form_id == 4) { $api_info = array( 'API_Endpoint' => 'https://api.paypal.com', 'API_UserName' => 'default_username', 'API_Password' => 'default_password', 'Vendor' => 'default_vendor', 'Partner' => 'default_partner' ); } return $api_info; }