Customizing Stripe payment parameters

Posts in the developer's cookbook category describe topics that require technical knowledge. Be warned and use the techniques at your own risk. Unless you are an experienced developer, you are strongly advised to ask a professional for support.

Stripe‘s payment parameters, such as the currency or the amount of money, are decided by the [stripe] form-tag placed in the form template. You might want to customize the parameters by changing them dynamically based on the user’s selection or some sort of calculation.

You can do it by using the wpcf7_stripe_payment_intent_parameters filter hook like in the following coding example:


	function ( $params ) {

		// Get the WPCF7_Submission object
		$submission = WPCF7_Submission::get_instance();

		// Retrieve the currency from the 'your-currency' field value
		$currency = (array) $submission->get_posted_data( 'your-currency' );
		$currency = (string) array_shift( $currency );
		$params['currency'] = strtolower( $currency );

		// Calculate the amount
		$amount = 1000 * SOME_CONSTANT;
		$params['amount'] = $amount;

		// Retrieve the buyer's email from the 'email-123' field value
		$receipt_email = $submission->get_posted_data( 'email-123' );

		if ( is_email( $receipt_email ) ) {
			$params['receipt_email'] = $receipt_email;

		// See
		// for the full list of available parameters

		return $params;

	10, 1