curl --request POST \
--url https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel', 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://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "payment_method_session",
"id": "pms_test_7Hs2kQ9mL1pXv4cR8tWzAbCd",
"status": "requires_payment_method",
"customer": null,
"payment_method_types": [
"card"
],
"amount": null,
"currency": null,
"livemode": false,
"expires_at": "2026-09-17T18:30:00.000Z",
"canceled_at": null,
"succeeded_at": null,
"card": null,
"us_bank_account": null,
"ach_authorization": null,
"payment_method": null,
"created_at": "2026-09-17T18:00:00.000Z"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Cancel a payment method session
Stops a session that is still collecting. The browser can no longer open it with its client secret.
curl --request POST \
--url https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel', 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://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$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://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dashboard.payra.com/v1/payment-method-sessions/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "payment_method_session",
"id": "pms_test_7Hs2kQ9mL1pXv4cR8tWzAbCd",
"status": "requires_payment_method",
"customer": null,
"payment_method_types": [
"card"
],
"amount": null,
"currency": null,
"livemode": false,
"expires_at": "2026-09-17T18:30:00.000Z",
"canceled_at": null,
"succeeded_at": null,
"card": null,
"us_bank_account": null,
"ach_authorization": null,
"payment_method": null,
"created_at": "2026-09-17T18:00:00.000Z"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Authorizations
A secret key, sk_test_... or sk_live_...; a publishable key (pk_...) on the browser routes only
Path Parameters
1 - 64Response
The canceled session
payment_method_session "pms_test_7Hs2kQ9mL1pXv4cR8tWzAbCd"
requires_payment_method, succeeded, canceled, expired "requires_payment_method"
null
card, us_bank_account ["card"]
What a one-time bank debit will authorize, in the smallest unit of currency. Null on a card session and when a bank account is being saved.
null
USD null
false
"2026-09-17T18:30:00.000Z"
null
null
Set once the browser confirmed a card.
Show child attributes
Show child attributes
null
Set once the browser confirmed a bank account.
Show child attributes
Show child attributes
null
On a us_bank_account session: the authorization shown to the account holder, and when they accepted it.
Show child attributes
Show child attributes
null
The payment method your server created from this session, once it did.
null
"2026-09-17T18:00:00.000Z"