Reusing the payment source
How to save the payment source into the customer wallet so that it can be reused
Problem
Solution
Example
1. Save the payment source into the customer wallet
curl -g -X PATCH \
'http://yourdomain.commercelayer.io/api/orders/qaMAhZkZvd?include=available_customer_payment_sources' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "orders",
"id": "qaMAhZkZvd",
"attributes": {
"_save_payment_source_to_customer_wallet": true
}
}
}'{
"data": {
"id": "qaMAhZkZvd",
"type": "orders",
"links": {
"self": "https://yourdomain.commercelayer.io/api/orders/qaMAhZkZvd"
},
"attributes": {...},
"relationships": {
"market": {
"links": {...}
},
"customer": {
"links": {...}
},
"shipping_address": {
"links": {...}
},
"billing_address": {
"links": {...}
},
"available_payment_methods": {
"links": {...}
},
"available_customer_payment_sources": {
"links": {...},
"data": [
{
"type": "customer_payment_sources",
"id": "QgDXpwsqDx"
}
]
},
"payment_method": {
"links": {...}
},
"payment_source": {
"links": {...}
},
"line_items": {
"links": {...}
},
"shipments": {
"links": {...}
}
},
"meta": {
"mode": "test"
}
},
"included": [
{
"id": "QgDXpwsqDx",
"type": "customer_payment_sources",
"links": {
"self": "https://yourdomain.commercelayer.io/api/customer_payment_sources/QgDXpwsqDx"
},
"attributes": {
"customer_token": "1",
"name": "XXXX-XXXX-XXXX-1111",
"payment_source_token": "7RxGd2HUyY1Yc2Tghw5N453piFs",
"created_at": "2018-01-01T12:00:00.000Z",
"updated_at": "2018-01-01T12:00:00.000Z",
"reference": null,
"metadata": {}
},
"relationships": {
"customer": {
"links": {...}
},
"payment_source": {
"links": {...}
}
},
"meta": {
"mode": "test"
}
}
]
}2. Reuse the payment source stored in the customer wallet
More to read
Last updated