# Invoice Webhook Notification

### Webhook notification

{% hint style="danger" %}
There are three transaction statuses in the webhook notification under the field name “pay\_status”. CCPayment will credit assets if the pay\_status is “success”, which is ***the one and only status you should consider as the confirmation of the transaction***. The other two pay\_status, “pending” and “processing”, can not be regarded as the confirmation of the transaction.
{% endhint %}

{% tabs %}
{% tab title="Header" %}

<table><thead><tr><th width="134">Name</th><th width="188">Value</th><th width="104" align="center">Required</th><th width="82">Type</th><th width="299">Description</th></tr></thead><tbody><tr><td>Content-Type</td><td></td><td align="center">Y</td><td>string</td><td>application/json; charset=utf-8</td></tr><tr><td>Appid</td><td>202302010636261620672405236006912</td><td align="center">Y</td><td>string</td><td>Merchant's unique credential. Find it on the Developer page.</td></tr><tr><td>Timestamp</td><td>1677152490</td><td align="center">Y</td><td>string</td><td>Timestamp in seconds (10-digit). The request is valid for two minutes.</td></tr><tr><td>Sign</td><td>871f0223c66ea72435208d03603a0cb00b90f6ac4a4ba725d00164d967e291f6</td><td align="center">Y</td><td>string</td><td>SHA-256 (appId + appSecret + timestamp+<mark style="color:red;"><strong>body (json string)</strong></mark>)</td></tr></tbody></table>
{% endtab %}

{% tab title="Body" %}

<pre><code><strong>```json
</strong>{
  "pay_status": "success",
  "order_type": "Invoice",
  "record_id": "202307311012021***477271900160",
  "order_id": "202307310956071***952473421795328",
  "product_price": "18",
  "order_amount": "0.009637573687282151",
  "fiat_rate": "1",
  "denominated_currency": "USD",
  "paid_amount": "10",
  "credit_amount": "",
  "token_rate": "1867.69",
  "chain": "ETH",
  "contract": "0xdAC17F***206206994597C13D831ec7",
  "crypto": "USDT",
  "txid": "",
  "network_fee": "0",
  "service_fee": "0.003",
  "memo": "",
  "extend": {
    "invoice_id": "2023073109560***3384046592",
    "user_email": "b***ly@gmail.com"
  }
}
```
</code></pre>

{% endtab %}

{% tab title="Parameters" %}

<table><thead><tr><th width="155.33333333333331">Name</th><th width="88">Type</th><th>Description</th></tr></thead><tbody><tr><td>pay_status</td><td>string</td><td>Payment status: pending, processing, success, failed<br>pending: The transaction started, it is waiting to be sent out to the blockchain.<br>processing: It’s being processed on the blockchain.</td></tr><tr><td>order_type</td><td>string</td><td>Invocie</td></tr><tr><td>record_id</td><td>string</td><td>Trading record: one transaction generates one unique record_id which can be used to distinguish multiple transactions under one merchant_order_id</td></tr><tr><td>order_id</td><td>string</td><td>CCPayment order ID</td></tr><tr><td>product_price</td><td>string</td><td>Initial pricing (price submitted by merchant or invoice). </td></tr><tr><td>denominated_ currency</td><td>string</td><td>Currency unit of the product price.<br>Call <a href="../resources-document/list-of-denominated-currency-for-api-payment">the interface</a> to get all denominated_ currency.</td></tr><tr><td>order_amount</td><td>string</td><td>If the denominated currency is crypto currency, order_amount = product_price; <br>when the denominated currency is fiat currency, order_amount=product_price/fiat_rate/token_rate</td></tr><tr><td>paid_amount</td><td>string</td><td>Token amount actually paid</td></tr><tr><td>fiat_rate</td><td>string</td><td>Fiat tax rate (in USD by default)</td></tr><tr><td>token_rate</td><td>string</td><td>Token price (in USDT by default); Token value in USD = token_rate*paid_amount</td></tr><tr><td>chain</td><td>string</td><td>Used to record the blockchain from which the user deposits.</td></tr><tr><td>contract</td><td>string</td><td>Contract</td></tr><tr><td>crypto</td><td>string</td><td>crypto symbol</td></tr><tr><td>extend</td><td>object</td><td></td></tr><tr><td>extend.merchant_order_id</td><td>string</td><td>Merchant order ID, order_type is the Api type</td></tr><tr><td>custom_value</td><td>string</td><td>Merchant custom field - This custom value field will be returned in the transaction status notification.</td></tr></tbody></table>
{% endtab %}

{% tab title="Remarks" %}
Return Appid, Sign, Timestamp in the header of the response.  The signature method SHA-256 (appid+appSecret+Timestamp+body).

Please use the data with caution if the signature verification fails. It indicates that the data has been tampered with.
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Once the merchant has processed the order, please return {http code: 200} and include a “success” string in the HTTP response body.&#x20;

If CCPayment does not receive “success” as a response from the merchant, CCPayment will keep pushing the notification up to 6 times. Any response other than “success” will be regarded as a failure, and CCPayment will keep sending the notification.

{% endhint %}

**Example**

{% tabs %}
{% tab title="PHP" %}

```php
$this->response->setString("success")
```

{% endtab %}

{% tab title="Java" %}

```java
this.response.setString("success");
```

{% endtab %}

{% tab title="Golong" %}

```go
this.response.SetString("success")
```

{% endtab %}

{% tab title="Python" %}

```python
self.response.set_string("success")
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
this.response.setString("success");
```

{% endtab %}
{% endtabs %}

<figure><img src="https://760693906-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKH8CbFKQ8Cydt24cgg2C%2Fuploads%2FZBy5dGy78dZaMoIzia08%2Fimage.png?alt=media&#x26;token=21b0c951-0d67-41a4-aa3c-d04b54fa0946" alt=""><figcaption><p>Response Example</p></figcaption></figure>
