The gform_square_payment_data filter allows you to modify the payment data before it is sent to Square in version 1.0 of the Square add-on.
Usage
add_filter('gform_square_payment_data', 'your_function_name', 10, 5);
Parameters
- $payment_data (array) – An array containing payment properties and their values as documented in Square Payments API.
- $feed (array) – The feed object currently being processed.
- $submission_data (array) – The customer and transaction data.
- $form (Form Object) – The form object currently being processed.
- $entry (Entry Object) – The entry object currently being processed.
More information
See Gravity Forms Docs: gform_square_payment_data
Examples
Add a custom note to the payment data
add_filter('gform_square_payment_data', 'change_payment_data', 10, 5); function change_payment_data($payment_data, $feed, $submission_data, $form, $entry) { $payment_data['note'] = 'Custom note'; return $payment_data; }
What it does: This code adds a custom note to the payment data before it’s sent to Square.
Add a custom metadata to the payment data
add_filter('gform_square_payment_data', 'add_custom_metadata', 10, 5); function add_custom_metadata($payment_data, $feed, $submission_data, $form, $entry) { $payment_data['metadata'] = array( 'custom_key' => 'custom_value' ); return $payment_data; }
What it does: This code adds custom metadata to the payment data before it’s sent to Square.
Set a custom customer ID for the payment
add_filter('gform_square_payment_data', 'set_custom_customer_id', 10, 5); function set_custom_customer_id($payment_data, $feed, $submission_data, $form, $entry) { $payment_data['customer_id'] = 'your_custom_customer_id'; return $payment_data; }
What it does: This code sets a custom customer ID for the payment data before it’s sent to Square.
Set a custom location ID for the payment
add_filter('gform_square_payment_data', 'set_custom_location_id', 10, 5); function set_custom_location_id($payment_data, $feed, $submission_data, $form, $entry) { $payment_data['location_id'] = 'your_custom_location_id'; return $payment_data; }
What it does: This code sets a custom location ID for the payment data before it’s sent to Square.
Add a custom billing address to the payment data
add_filter('gform_square_payment_data', 'add_custom_billing_address', 10, 5); function add_custom_billing_address($payment_data, $feed, $submission_data, $form, $entry) { $payment_data['billing_address'] = array( 'address_line_1' => '123 Main St', 'locality' => 'New York', 'administrative_district_level_1' => 'NY', 'postal_code' => '10001', 'country' => 'US' ); return $payment_data; }