# Handling Partial Payments

There is a possibility of shoppers making a partial payment when paying using a crypto wallet. We do update the shoppers to complete the partial payment. However, some merchants are okay with whatever the shopper has paid and want to issue goods/services as per the payment amount. In this case, merchants may close the partial payment so that they can give the goods/service for the amount paid by the shopper, and we can settle the partial payments to the merchants. This API will help the merchants to mark a partial payment as closed.

{% hint style="info" %}
It is advised to merchants that they should give shoppers up to 24 hours to pay the remaining amount before marking the transaction as closed.
{% endhint %}

{% hint style="info" %}
The merchants are requested to mark the transaction closed within two weeks of the partial payment by the shopper. After two weeks, the transaction cannot be marked closed.
{% endhint %}

<mark style="color:green;">`POST`</mark> `/closePartialTx`

#### Headers

| Name                                             | Type   | Description        |
| ------------------------------------------------ | ------ | ------------------ |
| "Content-Type"<mark style="color:red;">\*</mark> | String | "application/json" |

#### Request Body

| Name                                           | Type   | Description                                  |
| ---------------------------------------------- | ------ | -------------------------------------------- |
| clientId<mark style="color:red;">\*</mark>     | String | Merchant Client Id                           |
| encryptedReq<mark style="color:red;">\*</mark> | String | Encrypted string of offerId by client secret |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "ok": true,
    "result": {
        "success": true
    }
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "ok": false,
    "statusCode": 400,
    "data": {},
    "message": "No partial transaction found"
}
```

{% endtab %}
{% endtabs %}

```
// Example
 
offerId: "d21c44a5-9ff7-44d6-9dbc-158753184d5d"
clientSecret: "8e6e7524-202d-424d-b2a2-431ff1117e27" 

Then encrypt this offerId (JSON format) with clientSecret:
i.e, Encrypt JSON {"offerId":"d21c44a5-9ff7-44d6-9dbc-158753184d5d"} with "8e6e7524-202d-424d-b2a2-431ff1117e27"

And its output will be encryptedReq param 

For above offerId and clientSecret, encryptedReq is "U2FsdGVkX1+T1BocXOZHJA2paoYtiFC1GIl99jjtPQEWuxF2ikm8VT8eaenS5TDc67idkKfwFqBBd9dli/Ssdd28aXp6SKaBEtkkytTAtiA="
```

**Below is the sample postman Request**

Copy the following to the Pre-script

```
var CryptoJS = require('crypto-js');
var data = CryptoJS.AES.encrypt(JSON.stringify({
 offerId: '<<TRANSACTION_ORDER_ID>>'
}), '<<MERCHANT_CLIENT_SECRET>>').toString();
pm.variables.set("encryptedPartialPayload", data);
```

**Sample Curl Request**

```
curl --location 'https://app.rocketfuelblockchain.com/api/closePartialTx' \
--header 'Content-Type: application/json' \
--data '{
"clientId":"<<MERCHANT_CLIENT_ID>>",
"encryptedReq":"{{encryptedPartialPayload}}",
"forceUpdate": false
}'
```

forceUpdate is an optional parameter and its default value is true. If passed will value false, it will not close partial transaction if there is a refund request on the transaction


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rocketfuel.inc/developer-guides/api-reference/payins/rocketfuel-ui-integration/handling-partial-payments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
