Abort a payment attempt
curl --request POST \
--url https://api.sandbox.primer.io/payment-attempts/{id}/abort \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-VERSION: <x-api-version>' \
--data '
{
"reason": "fraud-check-failed"
}
'import requests
url = "https://api.sandbox.primer.io/payment-attempts/{id}/abort"
payload = { "reason": "fraud-check-failed" }
headers = {
"X-API-VERSION": "<x-api-version>",
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-VERSION': '<x-api-version>',
'X-API-KEY': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({reason: 'fraud-check-failed'})
};
fetch('https://api.sandbox.primer.io/payment-attempts/{id}/abort', 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.sandbox.primer.io/payment-attempts/{id}/abort",
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([
'reason' => 'fraud-check-failed'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-VERSION: <x-api-version>"
],
]);
$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://api.sandbox.primer.io/payment-attempts/{id}/abort"
payload := strings.NewReader("{\n \"reason\": \"fraud-check-failed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-VERSION", "<x-api-version>")
req.Header.Add("X-API-KEY", "<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://api.sandbox.primer.io/payment-attempts/{id}/abort")
.header("X-API-VERSION", "<x-api-version>")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"fraud-check-failed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payment-attempts/{id}/abort")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-VERSION"] = '<x-api-version>'
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"fraud-check-failed\"\n}"
response = http.request(request)
puts response.read_body{
"paymentAttemptId": "6c5d3a30-3c2e-4f55-9d8e-5b3d5e3a5c7f"
}Abort a payment attempt
Abort a payment attempt that is awaiting merchant approval. No payment is created. The tokenised payment instrument associated with the attempt is invalidated.
Call this endpoint when, after tokenisation, a business decision is made that the payment should not proceed (e.g. a merchant-side fraud check flagged the transaction, the customer cancelled on the merchant’s own UI, or an inventory check failed between tokenisation and approval).
POST
/
payment-attempts
/
{id}
/
abort
Abort a payment attempt
curl --request POST \
--url https://api.sandbox.primer.io/payment-attempts/{id}/abort \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-VERSION: <x-api-version>' \
--data '
{
"reason": "fraud-check-failed"
}
'import requests
url = "https://api.sandbox.primer.io/payment-attempts/{id}/abort"
payload = { "reason": "fraud-check-failed" }
headers = {
"X-API-VERSION": "<x-api-version>",
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-VERSION': '<x-api-version>',
'X-API-KEY': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({reason: 'fraud-check-failed'})
};
fetch('https://api.sandbox.primer.io/payment-attempts/{id}/abort', 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.sandbox.primer.io/payment-attempts/{id}/abort",
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([
'reason' => 'fraud-check-failed'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-VERSION: <x-api-version>"
],
]);
$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://api.sandbox.primer.io/payment-attempts/{id}/abort"
payload := strings.NewReader("{\n \"reason\": \"fraud-check-failed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-VERSION", "<x-api-version>")
req.Header.Add("X-API-KEY", "<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://api.sandbox.primer.io/payment-attempts/{id}/abort")
.header("X-API-VERSION", "<x-api-version>")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"fraud-check-failed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.primer.io/payment-attempts/{id}/abort")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-VERSION"] = '<x-api-version>'
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"fraud-check-failed\"\n}"
response = http.request(request)
puts response.read_body{
"paymentAttemptId": "6c5d3a30-3c2e-4f55-9d8e-5b3d5e3a5c7f"
}Headers
Body
application/json