Skip to main content
POST
/
{customer_id}
/
payment_methods
/
{payment_method_id}
/
default
Payment Method - Set Default Payment Method for Customer
curl --request POST \
  --url https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default \
  --header 'api-key: <api-key>'
import requests

url = "https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default"

headers = {"api-key": "<api-key>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {'api-key': '<api-key>'}};

fetch('https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default', 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://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default")
.header("api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.hyperswitch.io/{customer_id}/payment_methods/{payment_method_id}/default")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "customer_id": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
  "default_payment_method_id": "card_rGK4Vi5iSW70MY7J2mIg"
}

Authorizations

api-key
string
header
required

Ephemeral keys provide temporary access to singular data, such as access to a single customer object for a short period of time.

Path Parameters

customer_id
string
required

The unique identifier for the Customer

payment_method_id
string
required

The unique identifier for the Payment Method

Response

Payment Method has been set as default

customer_id
string
required

The unique identifier of the customer.

Required string length: 1 - 64
Example:

"cus_y3oqhf46pyzuxjbcn2giaqnb44"

payment_method
enum<string>
required

Indicates the type of payment method. Eg: 'card', 'wallet', etc.

Available options:
card,
card_redirect,
pay_later,
wallet,
bank_redirect,
bank_transfer,
crypto,
bank_debit,
reward,
real_time_payment,
upi,
voucher,
gift_card,
open_banking,
mobile_payment,
network_token
default_payment_method_id
string | null

The unique identifier of the Payment method

Example:

"card_rGK4Vi5iSW70MY7J2mIg"

payment_method_type
enum<string> | null

Indicates the sub type of payment method. Eg: 'google_pay' & 'apple_pay' for wallets.

Available options:
ach,
affirm,
afterpay_clearpay,
alfamart,
ali_pay,
ali_pay_hk,
alma,
amazon_pay,
paysera,
apple_pay,
atome,
bacs,
bancontact_card,
becs,
benefit,
bizum,
blik,
bluecode,
boleto,
bca_bank_transfer,
bni_va,
breadpay,
bri_va,
bhn_card_network,
card_redirect,
cimb_va,
classic,
credit,
crypto_currency,
cashapp,
dana,
danamon_va,
debit,
duit_now,
efecty,
eft,
eft_debit_order,
eps,
flexiti,
fps,
evoucher,
giropay,
givex,
google_pay,
go_pay,
gcash,
ideal,
interac,
indomaret,
klarna,
kakao_pay,
local_bank_redirect,
mandiri_va,
knet,
mb_way,
mobile_pay,
momo,
momo_atm,
multibanco,
online_banking_thailand,
online_banking_czech_republic,
online_banking_finland,
online_banking_fpx,
online_banking_poland,
online_banking_slovakia,
oxxo,
pago_efectivo,
permata_bank_transfer,
open_banking_uk,
pay_bright,
payjustnow,
paypal,
paze,
pix,
pix_key,
pix_emv,
pix_qr,
pix_automatico_qr,
pix_automatico_push,
pay_safe_card,
przelewy24,
prompt_pay,
pse,
qris,
red_compra,
red_pagos,
samsung_pay,
sepa,
sepa_bank_transfer,
sepa_guarenteed_debit,
skrill,
sofort,
swish,
touch_n_go,
trustly,
twint,
upi_collect,
upi_intent,
upi_qr,
vipps,
viet_qr,
venmo,
walley,
we_chat_pay,
seven_eleven,
lawson,
mini_stop,
family_mart,
seicomart,
pay_easy,
local_bank_transfer,
mifinity,
open_banking_pis,
direct_carrier_billing,
instant_bank_transfer,
instant_bank_transfer_finland,
instant_bank_transfer_poland,
revolut_pay,
indonesian_bank_transfer,
open_banking,
network_token