cURL
curl -X PUT \
/customers/{customerId}/payment-method \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"paymentMethodId": ""
}'import requests
url = "https://coreapi.io/customers/{customerId}/payment-method"
payload = { "paymentMethodId": "c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({paymentMethodId: 'c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b'})
};
fetch('https://coreapi.io/customers/{customerId}/payment-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/customers/{customerId}/payment-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'paymentMethodId' => 'c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b",
"customer": "ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a",
"gatewayName": "stripe",
"type": "card",
"referenceId": "pm_1J5J2n2eZvKYlo2C",
"default": true,
"status": "active",
"source": "api",
"enabled": true,
"name": "Visa (4242)",
"data": [],
"creationDate": "2024-01-15T10:30:00+00:00",
"expirationDate": "2026-12-31T23:59:59+00:00",
"expirationInDays": 1082,
"sepaMandate": null,
"card": {
"brand": "Visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2026,
"cardHolder": "Max Mustermann"
},
"sepaDebit": null,
"paypal": null
}Set default payment method
Set the default payment method for a customer
Required permissions:payment-method:write, customer:payment-method:changePUT
/
customers
/
{customerId}
/
payment-method
cURL
curl -X PUT \
/customers/{customerId}/payment-method \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"paymentMethodId": ""
}'import requests
url = "https://coreapi.io/customers/{customerId}/payment-method"
payload = { "paymentMethodId": "c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({paymentMethodId: 'c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b'})
};
fetch('https://coreapi.io/customers/{customerId}/payment-method', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/customers/{customerId}/payment-method",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'paymentMethodId' => 'c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "c1a2b3c4-d5e6-4f7a-8b9b-0c1d2e3f4a5b",
"customer": "ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a",
"gatewayName": "stripe",
"type": "card",
"referenceId": "pm_1J5J2n2eZvKYlo2C",
"default": true,
"status": "active",
"source": "api",
"enabled": true,
"name": "Visa (4242)",
"data": [],
"creationDate": "2024-01-15T10:30:00+00:00",
"expirationDate": "2026-12-31T23:59:59+00:00",
"expirationInDays": 1082,
"sepaMandate": null,
"card": {
"brand": "Visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2026,
"cardHolder": "Max Mustermann"
},
"sepaDebit": null,
"paypal": null
}Autorisierungen
Body
application/jsontext/html
The updated PaymentMethod resource
Antwort
PaymentMethod resource updated
Payment method details returned when reading a payment method.
War diese Seite hilfreich?