> For the complete documentation index, see [llms.txt](https://docs.orangepill.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orangepill.cloud/smartapps/accept-blockchain-payments.md).

# Accept Blockchain Payments

Use Apps.Deposit.Payment to forward crypto deposit for specific payment to virtual account.

To simplify acceptance of digital assets you can use Payment SmartApp. Payment SmartApp will orchestrate automatic forwarding of deposit to related Virtual account.

<figure><img src="https://3218614644-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoAQr9l0l72LlC4cHtGP0%2Fuploads%2FM1dQ4ZEjyZDQBKmSivRg%2FSmartApp_Payment.png?alt=media&amp;token=5beaad63-7414-4fcf-819f-2a9ba73da82a" alt=""><figcaption></figcaption></figure>

Amount received to Virtual account will be diminished for the amount of blockchain fee paid for automatic withdrawal from Deposit account to Ramp account.

## Create Payment

Use `seal` object to store immutable data about the payment.

Use `data` object to store variable data about the payment.

{% hint style="info" %}
Source Deposit account is automatically created.
{% endhint %}

{% hint style="info" %}
Target Virtual account must have related Ramp account assigned.
{% endhint %}

To create Payment you must provide target Virtual account address or alias.

Provide expected `amount` of deposit transaction to be able to track if it is paid in full.

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

<pre class="language-shell"><code class="lang-shell"><strong>echo 'Create payment request for 0.03 BTC'
</strong>
curl --location --request POST 'https://api.orangepill.cloud/v1/apps/deposit/payment' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933dffabb' \
--header 'Content-Type: application/json' \
--data-raw '{
    "destination": {
        "account": "6340be52dffbdb56217f6a7b"
    },
    "amount": 0.03,
    "asset": "BTC",
    "original_amount": 120.40,
    "original_currency": "USD",
    "valid_until": 1671242779881,
    "external": "INV12345",
    "seal": {
        "my_signature_field": "my_signature_value"
    },
    "data": {
        "description": "Payment 0.03 BTC",
        "invoice": "INV12345"
    }
}'
</code></pre>

{% endtab %}
{% endtabs %}

In response we get new `payment` with status `PENDING` if validation was succeful. Notice that Deposit account is automatically created for `source`.

```json
{
    "id": "639d2416cd7325b35f409452",
    "source": {
        "account": "634b56217f6a7b0be52dffbd",
        "deposit_address": "bc1q7pna7w7462uruh8m54tcnzspva8xd98wmc546u",
        "owner": "639675ab191e9023f356dfa6"
    },
    "destination": {
        "account": "6340be52dffbdb56217f6a7b",
        "owner": "639675ab191e9023f356dfa6"
    },
    "amount": "0.03",
    "asset": "ETH",
    "original_amount": 120.40,
    "original_currency": "USD",    
    "valid_until": 1671242779881,
    "external": "INV12345",    
    "seal": {
        "my_signature_field": "my_signature_value"
    },
    "data": {
        "description": "Payment 0.03 BTC",
        "invoice": "INV12345"
    },
    "owner": "639675ab191e9023f356dfa6",
    "created_at": 1671242774572,
    "status": "PENDING",
    "error": null
}
```

### Payment status

<table><thead><tr><th width="161">Status</th><th>Description</th></tr></thead><tbody><tr><td><code>PENDING</code></td><td>Awaiting for deposit.</td></tr><tr><td><code>PROCESSING</code></td><td>Deposit received, withdrawal and forwarding in process.</td></tr><tr><td><code>DONE</code></td><td>Payment processing was successful.</td></tr><tr><td><code>INCOMPLETE</code></td><td>Payment is on time but amount received is not full.</td></tr><tr><td><code>OVERPAID</code></td><td>Payment is on time but amount received is overpaid.</td></tr><tr><td><code>LATE</code></td><td>Payment was received in full but after valid time.</td></tr><tr><td><code>FAILED</code></td><td>Payment creation or processing has failed.</td></tr><tr><td><code>REFUND</code></td><td>Payment is ready for refund to source.</td></tr><tr><td><code>REFUNDED</code></td><td>Payment has been refunded to source payer.</td></tr></tbody></table>

## List payments

You can apply filters to get list of payments.

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

<pre class="language-shell"><code class="lang-shell"><strong>echo 'list payments with status PENDING'
</strong>
curl --location --request GET 'https://api.orangepill.cloud/v1/apps/deposit/payment?query={"status":"PENDING"}' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'Content-Type: application/json'
</code></pre>

{% endtab %}
{% endtabs %}

In response we get array of `payment` objects.&#x20;

```json
[{
    "id": "639d2416cd7325b35f409452",
    "source": {
        "account": "634b56217f6a7b0be52dffbd",
        "deposit_address": "bc1q7pna7w7462uruh8m54tcnzspva8xd98wmc546u",        
        "owner": "639675ab191e9023f356dfa6"
    },
    "destination": {
        "account": "6340be52dffbdb56217f6a7b",
        "owner": "639675ab191e9023f356dfa6"
    },
    "amount": "0.03",
    "asset": "BTC",
    "original_amount": 120.40,
    "original_currency": "USD",    
    "valid_until": 1671242779881,
    "external": "INV12345",        
    "seal": {
        "my_signature_field": "my_signature_value"
    },
    "data": {
        "description": "Payment 0.03 Bitcoin",
        "invoice": "INV12345"
    },
    "owner": "639675ab191e9023f356dfa6",
    "created_at": 1671242774572,
    "status": "PENDING",
    "error": null
}]
```
