Home / Admin / WP Simple Pay: Use Custom Field Value as Stripe Payment Description
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Use Custom Field Value as Stripe Payment Description

Use the value of a custom field as the description for the Stripe payment record.

Code Preview
php
<?php
/**
 * @link https://library.wpcode.com/snippet/e5wnp95d/
 */
add_filter(
	'simpay_get_paymentintent_args_from_payment_form_request',
	/**
	 * @param array $paymentintent_args Arguments for PaymentIntent.
	 * @param SimplePay\Core\Abstracts\Form $form Form instance.
	 * @param array $form_data Form data generated by the client.
	 * @param array $form_values Values of named fields in the payment form.
	 * @return $args
	 */
	function( $args, $form, $form_data, $form_values ) {
		// BEGIN UPDATES.
		$stripe_metadata_label = 'Custom Field';
		// END UPDATES.
		
		if ( ! isset( $form_values['simpay_field'][ $stripe_metadata_label ] ) ) {
			return $args;
		}
		$args['description'] = $form_values['simpay_field'][ $stripe_metadata_label ];
		return $args;
	},
	10,
	4
);

Comments

Add a Comment