# Payment Request

## Create A New Invoice

<mark style="color:green;">`POST`</mark> `https://shop.rexdigital.group/api/v1/payment-request`

#### Request Body

| Name            | Type   | Description                                                                                                                           |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| custom          | string | Any parameter that would be useful to receive back in webhook messages.                                                               |
| currency        | string | <p>The currency the invoice should be, in a three-letter ISO format:<br><https://www.iso.org/iso-4217-currency-codes.html></p>        |
| payment\_method | array  | <p>The payment method the customer will pay with.<br>(See 'Payment Methods' for a full supported list). Leave empty to allow all.</p> |
| transaction\_id | string | An unique identifier for the transaction.                                                                                             |
| amount          | number | Your calculated amount of the total price of the lines. (See 'Line Object' below, for the math).                                      |
| lines           | array  | An array of line object(s) (see 'Line Object' below).                                                                                 |
| api\_key        | string | Your api key which can be found by going to your store. Clicking on the cogwheel and navigating to the developer tab.                 |
| api\_signature  | string | Your unique signature (see 'Signing Requests' below).                                                                                 |
| sales\_tax      | number | A float of sales tax amount to be added on top.                                                                                       |
| customer        | object | A billing address object (see 'Billing Address' below).                                                                               |
| shipping        | object | A shipping address object (see 'Shipping Address' below).                                                                             |
| return\_url     | string | The url to return customer to when they have finished the checkout flow (Do not use this to confirm payment).                         |
| webhook\_url    | string | The url you wish to receive instant updates about the payment for the invoice (See 'Webhook Url' below).                              |

{% tabs %}
{% tab title="200 Creating a successful invoice returns the redirect url which you should then redirect the customer to." %}

```javascript
{
    "redirect_url": "https://shop.rexdigital.group/pay-by-link/TRANSACTIONID/checkout"
}
```

{% endtab %}
{% endtabs %}

## Payment Methods

For a full list of supported payment methods please visit: [Payment Methods](/entities/payment-methods.md)

## Line Object

| Name        | Type    | Description                                       | Example           |
| ----------- | ------- | ------------------------------------------------- | ----------------- |
| title       | String  | The name of the line, this is shown to customers. | Imposter Disguise |
| unit\_price | Float   | The price per unit.                               | 15.33             |
| units       | Integer | The amount of units the customer is buying.       | 2                 |
| discount    | Float   | The discount amount applied to the invoice.       | 0.65              |

$$
total = unit\_price \* units - discount
$$

The total price for Imposter Disguise would be 30.01

## Billing Address

An object to automatically fill out the customer billing information. If you do this for them they will automatically skip the step.\
See the structure here: [Billing Address](/entities/billing-address.md)

## Shipping Address

An object to automatically fill out the customer's shipping information. If you do not fill this we will assume shipping is the same address as the billing address above. You can also ignore it if no shipping is required.

See the structure here: [Shipping Address](/entities/shipping-address.md)

## Webhook URL

Webhook URL's is the only way to confirm the status of a transaction. You will receive information instantly once a change to the transaction occurs.\
To see how to implement it please visit [Webhooks](/getting-started/webhooks.md#setup-your-url)

## Signing Requests

```php
<?php 

function sign_webhook($invoiceDetails, $secret) {
    return hash_hmac('sha256', implode('', [
        $invoiceDetails['api_key'],
        $invoiceDetails['payment_method'],
        $invoiceDetails['amount'],
        $invoiceDetails['currency'],
        $invoiceDetails['transaction_id']
    ]), $secret);
}
```


---

# 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-shop.rexdigital.group/getting-started/payment-request.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.
