For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integration Setup

...

Code Snippets

PINGPOD Shop - SSO Redirect

<?php
add_action('mo_oauth_logged_in_user_token', 'pp_oauth_logged_in_user_token' , 10, 2);                
function pp_oauth_logged_in_user_token( $user, $token ){                	
	$woocommerce_stripe_settings = get_option( 'woocommerce_stripe_settings', array() );
	$mode = ( 'yes' === $woocommerce_stripe_settings['testmode'] ) ? 'test' : 'live';
	$access_token = $token['access_token'];
	$args = array(
		'headers' => array(
			'Authorization' => "Bearer $access_token"
		)
	);
	$response =	wp_remote_get(
		$mode == 'live'
			? 'https://app.pingpod.com/apis/v2/users/current/payment-method'
			: 'https://app-staging.pingpod.com/apis/v2/users/current/payment-method'
		, $args);
	$json = json_decode( $response['body'] );
	$stripe_cus_id = $json->stripe->userId;
	
	if ($stripe_cus_id) {
		wc_stripe_save_customer( $stripe_cus_id, $user->ID, $mode );
		WC_Stripe_Customer_Manager::instance()->sync_payment_methods( $stripe_cus_id, $user->ID, $mode );
	}
}

PINGPOD Shop - OAuth2.0 Stripe Customer Importer

Last updated

Was this helpful?