cURL
curl --request POST \ --url https://api.example.com/api/cards/assign \ --header 'Content-Type: application/json' \ --data ' { "userId": "<string>", "source": "<string>" } '
{ "status": true, "message": "<string>", "data": { "cardId": "<string>", "brand": "<string>", "last4": "<string>" } }
Attach a tokenized card to a Stripe customer
cus_
"cus_QRs9eKZ4xUzN2TP9"
tok_
"tok_1QRs9eKZ4xUzN2TP9vQqWXYZ"
true
false
"Tarjeta añadida con éxito"
Show Card Assignment Object
card_
"card_1QRs9eKZ4xUzN2TPabcdefgh"
"Visa"
"4242"
curl -X POST https://your-api.com/api/cards/assign \ -H "Content-Type: application/json" \ -d '{ "userId": "cus_QRs9eKZ4xUzN2TP9", "source": "tok_1QRs9eKZ4xUzN2TP9vQqWXYZ" }'
{ "status": true, "message": "Tarjeta añadida con éxito", "data": { "cardId": "card_1QRs9eKZ4xUzN2TPabcdefgh", "brand": "Visa", "last4": "4242" } }
// Step 1: Create card token const tokenResponse = await fetch('https://your-api.com/api/cards/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ number: '4242424242424242', exp_month: '12', exp_year: '2026', cvc: '123' }) }); const tokenData = await tokenResponse.json(); // Step 2: Assign token to customer const assignResponse = await fetch('https://your-api.com/api/cards/assign', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ userId: 'cus_QRs9eKZ4xUzN2TP9', source: tokenData.data.token_id }) }); const assignData = await assignResponse.json(); console.log('Card assigned:', assignData);