TestingPrivate preview
Learn how to test the processing of shared payment tokens (SPTs).
After you create a granted SharedPaymentToken object using a PaymentMethod, you can test the functionality of SPTs in an agent by using the token to create a PaymentIntent.
Create a Shared Payment Token
To grant your account an SPT 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 an SPT and sharing it with you.
Command Line
curl https://api.stripe.com/v1/test_helpers/shared_payment/granted_tokens \ -u\ -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}}"sk_test_BQokikJOvBiI2HlWgH4olfQ2"
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 object to create a payment.
Command Line
curl https://api.stripe.com/v1/payment_intents \ -u\ -d amount=10000 \ -d currency=usd \ -d confirm=true \ -d "payment_method_types[]"=card \ -d shared_payment_granted_token=spt_123"sk_test_BQokikJOvBiI2HlWgH4olfQ2"
Listen for webhook events
As the seller, you can listen for usage events related to the SPT to track its use during transactions. The following event notifies you when the SPT has been used.
shared_payment.granted_token.used