curl --request POST \
--url https://api.example.com/api/cards/default \
--header 'Content-Type: application/json' \
--data '
{
"userId": "<string>",
"default_source": "<string>"
}
'{
"status": true,
"message": "<string>",
"data": {
"id": "<string>",
"default_source": "<string>",
"email": "<string>",
"name": "<string>",
"sources": {}
}
}Set a card as the default payment method for a customer
curl --request POST \
--url https://api.example.com/api/cards/default \
--header 'Content-Type: application/json' \
--data '
{
"userId": "<string>",
"default_source": "<string>"
}
'{
"status": true,
"message": "<string>",
"data": {
"id": "<string>",
"default_source": "<string>",
"email": "<string>",
"name": "<string>",
"sources": {}
}
}Sets a specific card as the default payment source for a customer. This card will be used for automatic payments unless otherwise specified.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/peLuis123/Stripe_Back/llms.txt
Use this file to discover all available pages before exploring further.
cus_.Example: "cus_QRs9eKZ4xUzN2TP9"card_ or src_.This must be a card that’s already attached to the customer. Use Assign Card first if needed.Example: "card_1QRs9eKZ4xUzN2TPabcdefgh"true) or failed (false)."Método de pago actualizado con éxito"curl -X POST https://your-api.com/api/cards/default \
-H "Content-Type: application/json" \
-d '{
"userId": "cus_QRs9eKZ4xUzN2TP9",
"default_source": "card_1QRs9eKZ4xUzN2TPabcdefgh"
}'
{
"status": true,
"message": "Método de pago actualizado con éxito",
"data": {
"id": "cus_QRs9eKZ4xUzN2TP9",
"object": "customer",
"email": "[email protected]",
"name": "John Doe",
"phone": "+1234567890",
"default_source": "card_1QRs9eKZ4xUzN2TPabcdefgh",
"created": 1710259200,
"sources": {
"object": "list",
"data": [
{
"id": "card_1QRs9eKZ4xUzN2TPabcdefgh",
"object": "card",
"brand": "Visa",
"last4": "4242",
"exp_month": 12,
"exp_year": 2026
}
]
}
}
}
// First, assign the card
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: 'tok_1QRs9eKZ4xUzN2TP9vQqWXYZ'
})
});
const assignData = await assignResponse.json();
// Then set it as default
const defaultResponse = await fetch('https://your-api.com/api/cards/default', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userId: 'cus_QRs9eKZ4xUzN2TP9',
default_source: assignData.data.cardId
})
});
const defaultData = await defaultResponse.json();
console.log('Default card set:', defaultData);
// Get the customer's cards first
const cardsResponse = await fetch('https://your-api.com/api/cards/cus_QRs9eKZ4xUzN2TP9');
const cardsData = await cardsResponse.json();
// User selects a different card
const selectedCardId = cardsData.data[1].id; // Second card
// Update default
const response = await fetch('https://your-api.com/api/cards/default', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userId: 'cus_QRs9eKZ4xUzN2TP9',
default_source: selectedCardId
})
});