Submit a payment action
curl --request POST \
--url https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"action_data": {
"reference": "<string>",
"otp": "<string>"
}
}
'import requests
url = "https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action"
payload = { "action_data": {
"reference": "<string>",
"otp": "<string>"
} }
headers = {
"Authorization": "<authorization>",
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'X-Api-Key': '<x-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({action_data: {reference: '<string>', otp: '<string>'}})
};
fetch('https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action', 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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action",
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([
'action_data' => [
'reference' => '<string>',
'otp' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"X-Api-Key: <x-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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action"
payload := strings.NewReader("{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("X-Api-Key", "<x-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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action")
.header("Authorization", "<authorization>")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"response": {
"success": true,
"payment_id": "<string>",
"transaction_id": "<string>",
"status": "<string>",
"next_action": "redirect",
"redirect_url": "<string>",
"provider": "<string>",
"message": "<string>",
"payment_data": {
"amount": 123,
"currency": "<string>",
"target_amount": 123,
"target_currency": "<string>",
"metadata": {}
}
}
}{
"message": "<string>",
"status": "error"
}{
"message": "<string>",
"status": "error"
}{
"error": "<string>",
"message": "Payment not found",
"code": "PAYMENT_NOT_FOUND"
}{
"error": "<string>",
"message": "Payment is not awaiting action",
"code": "INVALID_STATE_TRANSITION"
}Payment Initiation
Submit a payment action
Continue a pending payment that is awaiting a customer action — for example when the initiation response returned next_action: collect_otp. Supported actions are submit_otp, verify, and cancel. The payment must be in pending status.
POST
/
payments-init
/
{payment_id}
/
action
Submit a payment action
curl --request POST \
--url https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"action_data": {
"reference": "<string>",
"otp": "<string>"
}
}
'import requests
url = "https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action"
payload = { "action_data": {
"reference": "<string>",
"otp": "<string>"
} }
headers = {
"Authorization": "<authorization>",
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'X-Api-Key': '<x-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({action_data: {reference: '<string>', otp: '<string>'}})
};
fetch('https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action', 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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action",
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([
'action_data' => [
'reference' => '<string>',
'otp' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"X-Api-Key: <x-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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action"
payload := strings.NewReader("{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("X-Api-Key", "<x-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://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action")
.header("Authorization", "<authorization>")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod-api.pcxpay.com/v1/payments-init/{payment_id}/action")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action_data\": {\n \"reference\": \"<string>\",\n \"otp\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 200,
"response": {
"success": true,
"payment_id": "<string>",
"transaction_id": "<string>",
"status": "<string>",
"next_action": "redirect",
"redirect_url": "<string>",
"provider": "<string>",
"message": "<string>",
"payment_data": {
"amount": 123,
"currency": "<string>",
"target_amount": 123,
"target_currency": "<string>",
"metadata": {}
}
}
}{
"message": "<string>",
"status": "error"
}{
"message": "<string>",
"status": "error"
}{
"error": "<string>",
"message": "Payment not found",
"code": "PAYMENT_NOT_FOUND"
}{
"error": "<string>",
"message": "Payment is not awaiting action",
"code": "INVALID_STATE_TRANSITION"
}Headers
Bearer JWT for user-facing flows (Bearer eyJraWQ...), or the literal string NONE when authenticating via API key.
Example:
"Bearer eyJraWQ..."
API key for server-to-server flows, or the literal string NONE when authenticating via JWT.
Example:
"pcx_abc123_xxxx"
Path Parameters
ID of the payment awaiting action.
Body
application/json