# Preference Endpoints (api/Preference)

### **General Definitions**

<table border="1" id="bkmrk-parameter-descriptio" style="height: 113px; width: 87.037%;"><tbody><tr><td style="width: 49.9291%;">**Parameter**</td><td style="width: 49.9291%;">**Description**</td></tr><tr><td style="width: 49.9291%;">baseurl</td><td style="width: 49.9291%;">Sandbox - [https://test.xprizo.com/api](https://test.xprizo.com/api)

Live- [https://wallet.xprizo.com/api](https://wallet.xprizo.com/api)

</td></tr><tr><td style="width: 49.9291%;">apiversion</td><td style="width: 49.9291%;">1.0</td></tr><tr><td style="width: 49.9291%;">apikey</td><td style="width: 49.9291%;">API key For authentication</td></tr></tbody></table>

### **Update Approval Webhook**

<p class="callout info">**Approval Webhook is triggered when a new pending transaction is created or when this pending transaction is approved, canceled, or rejected.**</p>

<div class="pointer-container" id="bkmrk-%C2%A0-0"><div class="pointer anim is-page-editable"><svg class="svg-icon" data-icon="link" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg><div class="input-group inline block"> <button class="button outline icon" data-clipboard-target="#pointer-url" title="Copy Link" type="button"><svg class="svg-icon" data-icon="copy" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></button></div><svg class="svg-icon" data-icon="edit" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></div></div><p class="callout info">**Request**</p>

```bash
curl --location --request PUT '{baseurl}/Preference/SetApprovalWebhook?url={url}' \
--header 'Accept: text/plain; x-api-version=1.0' \
--header 'x-api-version: {apiversion}' \
--header 'x-api-key: {apikey}'
```

<table border="1" id="bkmrk-parameter-descriptio-0" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 49.9383%;">**Parameter**</td><td style="width: 49.9383%;">**Description**</td></tr><tr><td style="width: 49.9383%;">url</td><td style="width: 49.9383%;">Url to receive callbacks</td></tr></tbody></table>

<p class="callout success">**Response (200)**</p>

<p class="callout warning">**Your callback URL must respond with JSON object {'status': 'success' } and HTTP code 200 to Xprizo.**</p>

### **Test Approval Webhook**

<p class="callout info">**You can test your callback URL's response by using this endpoint**</p>

<div class="pointer-container" id="bkmrk-%C2%A0-2"><div class="pointer anim is-page-editable"><svg class="svg-icon" data-icon="link" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg><div class="input-group inline block"> <button class="button outline icon" data-clipboard-target="#pointer-url" title="Copy Link" type="button"><svg class="svg-icon" data-icon="copy" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></button></div><svg class="svg-icon" data-icon="edit" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></div></div><p class="callout info">**Request**</p>

```bash
curl --location --request GET '{baseurl}/Preference/TestApprovalWebhook' \
--header 'Accept: text/plain; x-api-version=1.0' \
--header 'x-api-version: {apiversion}' \
--header 'x-api-key: {apikey}'
```

<p class="callout success">**Response (200)**</p>

<p class="callout warning">**Your callback URL must respond with JSON object {'status': 'success' } and HTTP code 200 to Xprizo.**</p>

###   


### **Approval Webhook Responses**

<p class="callout success">**Created Transaction &amp; Approved Transaction Response on Webhook (Sample)**</p>

```bash
# Created Transaction
{
  "statusType": 1,
  "status": "New",
  "description": null,
  "actionedById": 724,
  "affectedContactIds": [
    723,
    2
  ],
  "transaction": {
    "id": 0,
    "createdById": 724,
    "type": "UCD",
    "date": "2024-02-07T03:41:59.823195+00:00",
    "reference": "652-1706532591283",
    "currencyCode": "USD",
    "amount": 5
  }
}

# Approved Transaction
{
  "statusType": 2,
  "status": "Accepted",
  "description": null,
  "affectedContactIds": [
    723,
    2
  ],
  "transaction": {
    "id": 3169,
    "createdById": 724,
    "type": "UCD",
    "date": "2024-02-07T03:43:50.9186754+00:00",
    "reference": "652-1706532591283",
    "currencyCode": "USD",
    "amount": 5
  }
}
```

<table border="1" id="bkmrk-parameter-descriptio-9" style="border-collapse: collapse; width: 86.9136%; height: 344.563px;"><tbody><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">**Parameter**</td><td style="width: 50.0618%; height: 29.7969px;">**Description**</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">statusType</td><td style="width: 50.0618%; height: 29.7969px;">This is the status 2 = Accepted</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">status</td><td style="width: 50.0618%; height: 29.7969px;">Text version of the status "Accepted"</td></tr><tr style="height: 46.5938px;"><td style="width: 50.0618%; height: 46.5938px;">affectedContactIds</td><td style="width: 50.0618%; height: 46.5938px;">A list of the contact IDs that were involved in this transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">Transaction </td><td style="width: 50.0618%; height: 29.7969px;">Transaction that was created</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">id</td><td style="width: 50.0618%; height: 29.7969px;">The unique Id of the transaction provided by Xprizo</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">createdById</td><td style="width: 50.0618%; height: 29.7969px;">Id of the person who creates the transaction

</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">type</td><td style="width: 50.0618%; height: 29.7969px;">The type of transaction (UCD = Card Deposit) </td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">date</td><td style="width: 50.0618%; height: 29.7969px;">The date of the transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">reference</td><td style="width: 50.0618%; height: 29.7969px;">Recipient's unique transaction identifier for this transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">currencyCode</td><td style="width: 50.0618%; height: 29.7969px;">The currency of this transaction</td></tr><tr><td style="width: 50.0618%;">amount</td><td style="width: 50.0618%;">The amount of this transaction</td></tr></tbody></table>

<p class="callout info">Rejected Transaction Response on Webhook (Sample)</p>

```bash
{
 "statusType":3,
 "status":"Rejected",
 "description":"Reason for rejection",
 "actionedById":1,
 "affectedContactIds":[]
 "transaction": {
   "id":0,
   "createdById":2,
   "type":"UCD",
   "date":"2021-04-20T20:34:00.7606173+02:00",
   "reference":234234234,
   "currencyCode":"USD",
   "amount":100.00
 }
}

```

<p class="callout info">The following is a list of approval status codes that could be returned</p>

- 0 = None - Used for testing
- 1 = New - A new pending transaction has been created
- 2 = Accepted- The transaction was approved and processed
- 3 = Rejected - The transaction was rejected by the acquirer
- 4 = Cancelled - The transaction was canceled by the creator

### **Update Payment Webhook**

<p class="callout info">**Payment Webhook is triggered when a payment transaction with an action set to 2 (callback) is created.   
Callbacks are only sent to the profile that created the transaction.  
Callbacks will keep sending requests to the platform for 24 hours or until it gets a response.  
If a 200 (success) response is received then the transaction will be processed.  
If any other response (except a timeout) is received then the transaction will be voided.**</p>

<div class="pointer-container" id="bkmrk-%C2%A0-4"><div class="pointer anim is-page-editable"><svg class="svg-icon" data-icon="link" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg><div class="input-group inline block"> <button class="button outline icon" data-clipboard-target="#pointer-url" title="Copy Link" type="button"><svg class="svg-icon" data-icon="copy" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></button></div><svg class="svg-icon" data-icon="edit" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></div></div><p class="callout info">**Request**</p>

```bash
curl --location --request PUT '{baseurl}/Preference/SetPaymentWebhook?url={url}' \
--header 'Accept: text/plain; x-api-version=1.0' \
--header 'x-api-version: {apiversion}' \
--header 'x-api-key: {apikey}'
```

<table border="1" id="bkmrk-parameter-descriptio-1" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 49.9383%;">**Parameter**</td><td style="width: 49.9383%;">**Description**</td></tr><tr><td style="width: 49.9383%;">url</td><td style="width: 49.9383%;">Url to receive callbacks</td></tr></tbody></table>

<p class="callout success">**Response (200)**</p>

###   


### **Payment Webhook Responses**

<p class="callout success">**This will triggered when the send payment is initiated in Callback mode, Based on the response of this webhook by the Recipient, Xprizo will approve or void the transaction.** </p>

```bash
{
  "id": 3291,
  "currencyCode": "INR",
  "amount": 10,
  "reference": "652-1706532591321",
  "status": "Success"
}
```

<table border="1" id="bkmrk-parameter-descriptio-14" style="border-collapse: collapse; width: 86.9136%; height: 195.578px;"><tbody><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">**Parameter**</td><td style="width: 50.0618%; height: 29.7969px;">**Description**</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">status</td><td style="width: 50.0618%; height: 29.7969px;">Status of transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">id</td><td style="width: 50.0618%; height: 29.7969px;">The unique ID of the transaction provided by Xprizo</td></tr><tr style="height: 46.5938px;"><td style="width: 50.0618%; height: 46.5938px;">reference</td><td style="width: 50.0618%; height: 46.5938px;">Recipient's unique transaction identifier for this transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">currencyCode</td><td style="width: 50.0618%; height: 29.7969px;">The currency of this transaction</td></tr><tr style="height: 29.7969px;"><td style="width: 50.0618%; height: 29.7969px;">amount</td><td style="width: 50.0618%; height: 29.7969px;">The amount of this transaction</td></tr></tbody></table>

<p class="callout info">**Recipient will use this response and check for transactions having the same reference in their system and if everything is fine then they will respond with HTTP status code 200 else they will provide another HTTP status code (excluding timeout).**</p>

<p class="callout info">**If the Status code is 200 then this transaction will be marked as Completed in the Xprizo system else it will be VOID (excluding timeout).**</p>