TestingPrivate preview
Learn how to test processing Shared Payment Tokens.
After you create a granted SharedPaymentToken object using a PaymentMethod, you can test the functionality of Shared Payment Tokens in an agent by using the token to create a PaymentIntent.
Create a Shared Payment Token
To grant your account a Shared Payment Token using a PaymentMethod, you can collect payment details directly from the buyer or use a test PaymentMethod. The following code example demonstrates an agent issuing a Shared Payment Token and sharing it with you.
curl https://api.stripe.com/v1/test_helpers/shared_payment/granted_tokens \ -u "sk:" \ -d payment_method=pm_card_visa \ -d "usage_limits[currency]"=usd \ -d "usage_limits[max_amount]"=10000 \ -d "usage_limits[expires_at]"=time_in_future \ -d "seller_details[network_id]"=stripe_test_platform \ -d "seller_details[external_id]"=stripe_test_merchant
Create and confirm a PaymentIntent
Next, create a PaymentIntent using the SharedPaymentToken object. The following code example demonstrates how you, as the seller, use the SharedPaymentToken to create a payment.
curl https://api.stripe.com/v1/payment_intents \ -u "sk:" \ -d amount=10000 \ -d currency=usd \ -d confirm=true \ -d "payment_method_types[]"=card \ -d shared_payment_token=spt_123
Listen for webhook events
As the seller, you can listen for usage events related to the SharedPaymentToken to track its use during transactions. The following event notifies you when the SharedPaymentToken has been used.
shared_payment.granted_token.used