curl --request POST \
--url https://api.example.com/api/v1/purchase/cancel \
--header 'Content-Type: application/json' \
--header 'x-stash-hmac-signature: <api-key>' \
--data '
{
"playerId": "<string>",
"transactionId": "<string>",
"currency": "<string>",
"decimalPlaces": 123,
"items": [
{
"guid": "<string>",
"productId": "<string>",
"quantity": 123,
"cents": 123,
"purchasePackId": "<string>",
"metadata": {}
}
],
"checkoutLinkId": "<string>",
"shopId": "<string>",
"environment": "PAYMENT_ENVIRONMENT_UNSPECIFIED"
}
'import requests
url = "https://api.example.com/api/v1/purchase/cancel"
payload = {
"playerId": "<string>",
"transactionId": "<string>",
"currency": "<string>",
"decimalPlaces": 123,
"items": [
{
"guid": "<string>",
"productId": "<string>",
"quantity": 123,
"cents": 123,
"purchasePackId": "<string>",
"metadata": {}
}
],
"checkoutLinkId": "<string>",
"shopId": "<string>",
"environment": "PAYMENT_ENVIRONMENT_UNSPECIFIED"
}
headers = {
"x-stash-hmac-signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-stash-hmac-signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
playerId: '<string>',
transactionId: '<string>',
currency: '<string>',
decimalPlaces: 123,
items: [
{
guid: '<string>',
productId: '<string>',
quantity: 123,
cents: 123,
purchasePackId: '<string>',
metadata: {}
}
],
checkoutLinkId: '<string>',
shopId: '<string>',
environment: 'PAYMENT_ENVIRONMENT_UNSPECIFIED'
})
};
fetch('https://api.example.com/api/v1/purchase/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.example.com/api/v1/purchase/cancel",
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([
'playerId' => '<string>',
'transactionId' => '<string>',
'currency' => '<string>',
'decimalPlaces' => 123,
'items' => [
[
'guid' => '<string>',
'productId' => '<string>',
'quantity' => 123,
'cents' => 123,
'purchasePackId' => '<string>',
'metadata' => [
]
]
],
'checkoutLinkId' => '<string>',
'shopId' => '<string>',
'environment' => 'PAYMENT_ENVIRONMENT_UNSPECIFIED'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-stash-hmac-signature: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/purchase/cancel"
payload := strings.NewReader("{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-stash-hmac-signature", "<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.example.com/api/v1/purchase/cancel")
.header("x-stash-hmac-signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/purchase/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-stash-hmac-signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}"
response = http.request(request)
puts response.read_body{
"status": "PURCHASE_CANCELLATION_STATUS_UNSPECIFIED",
"message": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Cancel pending payment
Step 2B: Cancels a pending purchase that was previously registered. IMPORTANT: Always expects HTTP 200 OK response with inline error codes in the body.
curl --request POST \
--url https://api.example.com/api/v1/purchase/cancel \
--header 'Content-Type: application/json' \
--header 'x-stash-hmac-signature: <api-key>' \
--data '
{
"playerId": "<string>",
"transactionId": "<string>",
"currency": "<string>",
"decimalPlaces": 123,
"items": [
{
"guid": "<string>",
"productId": "<string>",
"quantity": 123,
"cents": 123,
"purchasePackId": "<string>",
"metadata": {}
}
],
"checkoutLinkId": "<string>",
"shopId": "<string>",
"environment": "PAYMENT_ENVIRONMENT_UNSPECIFIED"
}
'import requests
url = "https://api.example.com/api/v1/purchase/cancel"
payload = {
"playerId": "<string>",
"transactionId": "<string>",
"currency": "<string>",
"decimalPlaces": 123,
"items": [
{
"guid": "<string>",
"productId": "<string>",
"quantity": 123,
"cents": 123,
"purchasePackId": "<string>",
"metadata": {}
}
],
"checkoutLinkId": "<string>",
"shopId": "<string>",
"environment": "PAYMENT_ENVIRONMENT_UNSPECIFIED"
}
headers = {
"x-stash-hmac-signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-stash-hmac-signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
playerId: '<string>',
transactionId: '<string>',
currency: '<string>',
decimalPlaces: 123,
items: [
{
guid: '<string>',
productId: '<string>',
quantity: 123,
cents: 123,
purchasePackId: '<string>',
metadata: {}
}
],
checkoutLinkId: '<string>',
shopId: '<string>',
environment: 'PAYMENT_ENVIRONMENT_UNSPECIFIED'
})
};
fetch('https://api.example.com/api/v1/purchase/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.example.com/api/v1/purchase/cancel",
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([
'playerId' => '<string>',
'transactionId' => '<string>',
'currency' => '<string>',
'decimalPlaces' => 123,
'items' => [
[
'guid' => '<string>',
'productId' => '<string>',
'quantity' => 123,
'cents' => 123,
'purchasePackId' => '<string>',
'metadata' => [
]
]
],
'checkoutLinkId' => '<string>',
'shopId' => '<string>',
'environment' => 'PAYMENT_ENVIRONMENT_UNSPECIFIED'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-stash-hmac-signature: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/purchase/cancel"
payload := strings.NewReader("{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-stash-hmac-signature", "<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.example.com/api/v1/purchase/cancel")
.header("x-stash-hmac-signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/purchase/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-stash-hmac-signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"playerId\": \"<string>\",\n \"transactionId\": \"<string>\",\n \"currency\": \"<string>\",\n \"decimalPlaces\": 123,\n \"items\": [\n {\n \"guid\": \"<string>\",\n \"productId\": \"<string>\",\n \"quantity\": 123,\n \"cents\": 123,\n \"purchasePackId\": \"<string>\",\n \"metadata\": {}\n }\n ],\n \"checkoutLinkId\": \"<string>\",\n \"shopId\": \"<string>\",\n \"environment\": \"PAYMENT_ENVIRONMENT_UNSPECIFIED\"\n}"
response = http.request(request)
puts response.read_body{
"status": "PURCHASE_CANCELLATION_STATUS_UNSPECIFIED",
"message": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Authorizations
Versioned HMAC-SHA256 signature for server-to-server communication between game backends and Stash services. Recommended over the deprecated legacyHmac scheme for the best security. Header format: v1;{shopId};{unixMillisTimestamp};{base64Signature} (semicolon-delimited). {base64Signature} is the base64-encoded HMAC-SHA256 of the string {unixMillisTimestamp}.{requestBody} signed with your Egress API key, where {requestBody} is the compact request JSON. The timestamp must be within 5 minutes of Stash server time. Your shopId is your immutable shop identifier; it and your Egress API key are available in Stash Studio under Project Settings > API Secrets.
Body
Request to cancel a pending purchase that was previously registered.
Request to cancel a pending purchase that was previously registered.
Number of decimal places in this request's line-item cents values for this ISO 4217 currency, under the minor-unit standard configured for your shop: Unicode CLDR release 32 by default. See cents in GetCatalog for the standards a shop can use and their sources. Always sent, including the literal 0 for zero-decimal currencies (e.g. JPY, KRW).
Response
A successful response.
Expected response format for the CancelPayment endpoint from the game backend (response body includes status indicating success or failure).
Represents the status of a purchase cancellation
PURCHASE_CANCELLATION_STATUS_UNSPECIFIED, PURCHASE_CANCELLATION_STATUS_SUCCESS_CANCELLED, PURCHASE_CANCELLATION_STATUS_FAILED_TRANSACTION_NOT_FOUND, PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_COMPLETED, PURCHASE_CANCELLATION_STATUS_FAILED_ALREADY_CANCELLED