Skip to content

Cancel Payment

Request URL

POST /public/merchant/payment/cancel

Description

After authenticating the merchant through your existing front-end merchant portal UI and requesting a merchant JSON Web Token through the `/payment-link/merchant/get-token` endpoint, you may make a call to this endpoint in order to allow the merchant corresponding to the provided 'x-connectfi-jwtoken' header to cancel an existing payment link, specified by the "cFiTransactionId" property. The specified payment link must have a status of "Initiated", "Sent", or "Processing" in order to be successfully cancelled. This action can also be facilitated through the Payment Link Iframe script when embedded into your existing front-end merchant portal UI.

Schema

Property table for public/merchant/payment/cancel

Property Description Required Schema
cFiTransactionId The transaction ID in the connectFi system Yes {
  "type": "string",
  "pattern": "^[0-9a-zA-Z_]+$",
  "minLength": 1,
  "maxLength": 36,
  "$id": "common-id"
}

Request Body

{
     "cFiTransactionId": "FvuOBABxhupaLH4x2hn33"
}

Snippet Examples

javascript

const axios = require('axios');
const data = {
     "cFiTransactionId": "FvuOBABxhupaLH4x2hn33"
};
const config = {
  method: 'POST',
  url: '${CONNECTFI_BASE_URL}/public/merchant/payment/cancel',
  headers: {
    'Content-Type': "application/json",
    'x-connectfi-jwtoken': "A long random string token received from /payment-link/merchant/get-token request"
  },
  data
};

let result;
try {
  result = await axios.request(config);
  if (result.status === 200) {
    console.log(JSON.stringify(result.data));
  }
} catch (err) {
  console.log({
    errCode: err.code,
    responseStatus: err.response && err.response.status,
    data: err.response && JSON.stringify(err.response.data)
  });
}

cURL

curl --location "CONNECTFI_BASE_URL/public/merchant/payment/cancel" --data "{     \"cFiTransactionId\":\"FvuOBABxhupaLH4x2hn33\"}" --header "Content-Type: application/json" --header "x-connectfi-jwtoken: A long random string token received from /payment-link/merchant/get-token request" 

Successful Response Examples

200 SUCCESSFUL RESPONSE

HEADERS

Header Value
Content-Type application/json
x-connectfi-jwtoken A long random string token received from /payment-link/merchant/get-token request

REQUEST BODY

{
     "cFiTransactionId": "FvuOBABxhupaLH4x2hn33"
}

RESPONSE BODY

{
    "code": "0",
    "data": {
        "cFiTransactionId": "FvuOBABxhupaLH4x2hn33",
        "cFiAggregatorId": "CLIENTID",
        "cFiMerchantId": "2Bc0QW0VYJe7VhTyXXEYNQ",
        "payerName": "Doe John",
        "cFiMerchantRef": "1",
        "invoiceNumber": "11123",
        "amount": 22.5,
        "currency": "USD",
        "dueDate": "2024-07-29",
        "description": "test description",
        "status": "Cancelled",
        "fields": [
            {
                "index": 1,
                "code": "firstName",
                "label": "First Name",
                "value": "John"
            },
            {
                "index": 2,
                "code": "lastName",
                "label": "Last Name",
                "value": "Doe"
            },
            {
                "index": 3,
                "code": "email",
                "label": "Email",
                "value": "customer_email@email.test"
            },
            {
                "index": 4,
                "code": "phone",
                "label": "Phone",
                "value": "15556667777"
            }
        ],
        "availablePaymentType": [
            "card",
            "ach"
        ],
        "statusChangeHistory": [
            {
                "initiatorId": "2Bc0QW0VYJe7VhTyXXEYNQ",
                "initiatorType": "merchant",
                "status": "Initiated",
                "dtsCreatedAt": "2024-07-30T16:30:51.807Z",
                "dtsUpdatedAt": "2024-07-30T16:30:51.807Z"
            },
            {
                "initiatorId": "2Bc0QW0VYJe7VhTyXXEYNQ",
                "initiatorType": "merchant",
                "status": "Cancelled",
                "dtsCreatedAt": "2024-07-30T17:53:28.165Z",
                "dtsUpdatedAt": "2024-07-30T17:53:28.165Z"
            }
        ],
        "dtsCreatedAt": "2024-07-30T16:30:51.807Z"
    },
    "requestId": "a035f4904e9c11ef92543a54d404e711"
}