curl --request POST \
--url https://sandbox.birrpay.io/v2/payment-method-sessions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
}
'import requests
url = "https://sandbox.birrpay.io/v2/payment-method-sessions"
payload = { "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: '12345_cus_abcdefghijklmnopqrstuvwxyz'})
};
fetch('https://sandbox.birrpay.io/v2/payment-method-sessions', 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.birrpay.io/v2/payment-method-sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '12345_cus_abcdefghijklmnopqrstuvwxyz'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.birrpay.io/v2/payment-method-sessions"
payload := strings.NewReader("{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.birrpay.io/v2/payment-method-sessions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.birrpay.io/v2/payment-method-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}"
response = http.request(request)
puts response.read_body{
"id": "12345_pms_01926c58bc6e77c09e809964e72af8c8",
"expires_at": "2023-01-18T11:04:09.922Z",
"client_secret": "cs_9wcXDRVkfEtLEsSnYKgQ",
"customer_id": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"billing": {
"address": {
"city": "New York",
"country": "AF",
"line1": "123, King Street",
"line2": "Powelson Avenue",
"line3": "Bridgewater",
"zip": "08807",
"state": "New York",
"first_name": "John",
"last_name": "Doe",
"origin_zip": "08807"
},
"phone": {
"number": "9123456789",
"country_code": "+1"
},
"email": "<string>"
},
"psp_tokenization": {
"tokenization_type": "single_use",
"connector_id": "mca_28a7367sad8239s67"
},
"network_tokenization": {
"enable": "Enable"
},
"tokenization_data": "<unknown>",
"return_url": "https://merchant-website.com/return",
"next_action": {
"redirect_to_url": "https://example.com/redirect",
"type": "redirect_to_url"
},
"authentication_details": {
"status": "succeeded",
"error": {
"code": "card_declined",
"message": "The card was declined.",
"reason": "The card was declined.",
"unified_code": "card_declined",
"unified_message": "The card was declined.",
"network_advice_code": "01",
"network_decline_code": "05",
"network_error_message": "Do not retry"
}
},
"associated_payment_methods": [
{
"payment_method_token": {
"type": "payment_method_session_token",
"data": "token_9wcXDRVkfEtLEsSnYKgQ"
}
}
],
"associated_token_id": "12345_tok_01926c58bc6e77c09e809964e72af8c8",
"storage_type": "volatile",
"card_cvc_token_storage": {
"is_stored": true,
"expires_at": "2024-02-24T11:04:09.922Z"
}
}Payment Method Session - Create
Create a payment method session for a customer This is used to list the saved payment methods for the customer The customer can also add a new payment method using this session
curl --request POST \
--url https://sandbox.birrpay.io/v2/payment-method-sessions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz"
}
'import requests
url = "https://sandbox.birrpay.io/v2/payment-method-sessions"
payload = { "customer_id": "12345_cus_abcdefghijklmnopqrstuvwxyz" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer_id: '12345_cus_abcdefghijklmnopqrstuvwxyz'})
};
fetch('https://sandbox.birrpay.io/v2/payment-method-sessions', 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.birrpay.io/v2/payment-method-sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '12345_cus_abcdefghijklmnopqrstuvwxyz'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.birrpay.io/v2/payment-method-sessions"
payload := strings.NewReader("{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
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.birrpay.io/v2/payment-method-sessions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.birrpay.io/v2/payment-method-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"12345_cus_abcdefghijklmnopqrstuvwxyz\"\n}"
response = http.request(request)
puts response.read_body{
"id": "12345_pms_01926c58bc6e77c09e809964e72af8c8",
"expires_at": "2023-01-18T11:04:09.922Z",
"client_secret": "cs_9wcXDRVkfEtLEsSnYKgQ",
"customer_id": "12345_cus_01926c58bc6e77c09e809964e72af8c8",
"billing": {
"address": {
"city": "New York",
"country": "AF",
"line1": "123, King Street",
"line2": "Powelson Avenue",
"line3": "Bridgewater",
"zip": "08807",
"state": "New York",
"first_name": "John",
"last_name": "Doe",
"origin_zip": "08807"
},
"phone": {
"number": "9123456789",
"country_code": "+1"
},
"email": "<string>"
},
"psp_tokenization": {
"tokenization_type": "single_use",
"connector_id": "mca_28a7367sad8239s67"
},
"network_tokenization": {
"enable": "Enable"
},
"tokenization_data": "<unknown>",
"return_url": "https://merchant-website.com/return",
"next_action": {
"redirect_to_url": "https://example.com/redirect",
"type": "redirect_to_url"
},
"authentication_details": {
"status": "succeeded",
"error": {
"code": "card_declined",
"message": "The card was declined.",
"reason": "The card was declined.",
"unified_code": "card_declined",
"unified_message": "The card was declined.",
"network_advice_code": "01",
"network_decline_code": "05",
"network_error_message": "Do not retry"
}
},
"associated_payment_methods": [
{
"payment_method_token": {
"type": "payment_method_session_token",
"data": "token_9wcXDRVkfEtLEsSnYKgQ"
}
}
],
"associated_token_id": "12345_tok_01926c58bc6e77c09e809964e72af8c8",
"storage_type": "volatile",
"card_cvc_token_storage": {
"is_stored": true,
"expires_at": "2024-02-24T11:04:09.922Z"
}
}Authorizations
Format: api-key=<api_key>
Use the API key created under your merchant account from the HyperSwitch dashboard. API key is used to authenticate API requests from your merchant server only. Don't expose this key on a website or embed it in a mobile application.
Body
The customer id for which the payment methods session is to be created
"cus_y3oqhf46pyzuxjbcn2giaqnb44"
Show child attributes
Show child attributes
The return url to which the customer should be redirected to after adding the payment method
The Payment Service Provider Configuration for payment methods that are created using the payment method session
Show child attributes
Show child attributes
The network tokenization configuration for creating the payment method session
Show child attributes
Show child attributes
The time (seconds ) when the session will expire If not provided, the session will expire in 15 minutes
x >= 0900
Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data
Response
Create the payment method session
"12345_pms_01926c58bc6e77c09e809964e72af8c8"
The iso timestamp when the session will expire Trying to retrieve the session or any operations on the session after this time will result in an error
"2023-01-18T11:04:09.922Z"
Client Secret
"cs_9wcXDRVkfEtLEsSnYKgQ"
The customer id for which the payment methods session is to be created
"12345_cus_01926c58bc6e77c09e809964e72af8c8"
Show child attributes
Show child attributes
The Payment Service Provider Configuration for payment methods that are created using the payment method session
Show child attributes
Show child attributes
The network tokenization configuration for creating the payment method session
Show child attributes
Show child attributes
Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data
The return url to which the user should be redirected to
"https://merchant-website.com/return"
Contains the url for redirection flow
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
Show child attributes
Show child attributes
Show child attributes
Show child attributes
The payment method that was created using this payment method session
Show child attributes
Show child attributes
The token-id created if there is tokenization_data present
"12345_tok_01926c58bc6e77c09e809964e72af8c8"
volatile, persistent Show child attributes
Show child attributes