Home / Admin / WP Simple Pay: Stripe Checkout – Subscription Confirmation
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Stripe Checkout – Subscription Confirmation

Ensure Customer Subscriptions are available in the payment confirmation data.

Code Preview
php
<?php
<?php
/**
 * Ensure Customer Subscriptions are available in the payment confirmation data.
 */
add_filter(
	'simpay_payment_confirmation_data',
	function( $payment_confirmation_data ) {
		$subscriptions = \SimplePay\Core\API\Subscriptions\all(
			array(
				'customer' => $payment_confirmation_data['customer']->id,
				'limit'    => 1,
				'status'   => 'all',
				'expand'   => array(
					'data.latest_invoice',
					'data.latest_invoice.payment_intent',
				),
			),
			$payment_confirmation_data['form']->get_api_request_args()
		);
		$payment_confirmation_data['subscriptions'] = $subscriptions->data;
		return $payment_confirmation_data;
	}
);

Comments

Add a Comment