Test Tokenization
Test saving and reusing payment methods
Test Tokenization
Test storing payment methods for repeat customers.
Save a payment method
# Step 1: Create a customer
curl -X POST https://api.plexypay.com/v2/customers \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "name": "Test Customer"}'# Step 2: Create a payment method
curl -X POST https://api.plexypay.com/v2/payment-methods \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "card",
"card": {
"number": "4242424242424242",
"exp_month": 12,
"exp_year": 2030,
"cvc": "123"
}
}'# Step 3: Attach the payment method to the customer
curl -X POST https://api.plexypay.com/v2/payment-methods/pm_abc123/attach \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"customer": "cus_abc123"}'Charge a saved payment method
curl -X POST https://api.plexypay.com/v2/payments \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000,
"currency": "USD",
"customer": "cus_abc123",
"payment_method": "pm_abc123",
"off_session": true
}'Test card update scenarios
Simulate card updates (e.g., new expiry date):
| Card Number | Scenario |
|---|---|
4000002500001001 | Card will be updated |
4000002760001001 | Card update fails |
Test recurring payments
# First payment — save the payment method for future use
curl -X POST https://api.plexypay.com/v2/payments \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000,
"currency": "USD",
"payment_method": {"type": "card", "card": {"number": "4242424242424242", "exp_month": 12, "exp_year": 2030, "cvc": "123"}},
"setup_future_usage": "off_session"
}'# Subsequent off-session payment using the saved payment method
curl -X POST https://api.plexypay.com/v2/payments \
-H "x-api-key: YOUR_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000,
"currency": "USD",
"customer": "cus_abc123",
"payment_method": "pm_abc123",
"off_session": true
}'Verify token storage
After saving, verify the token:
- List customer's payment methods
- Check card fingerprint matches
- Verify last4 and brand are correct
curl -X GET "https://api.plexypay.com/v2/payment-methods?customer=cus_abc123&type=card" \
-H "x-api-key: YOUR_TEST_API_KEY"The response includes card.last4 ("4242") and card.brand ("visa") for verification.
See also
- Tokenization Guide - Implementation details
- Test Cards - Test card numbers