> For the complete documentation index, see [llms.txt](https://xact.gitbook.io/xact/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xact.gitbook.io/xact/sdk/php/pay.md).

# Send Hbar

The following sample will show you how to make a payment. We will first generate a request for the end user with details informations about the transaction. Once validated, you will get notified about transaction's status.

## Prerequisites: <a href="#pre-requisites" id="pre-requisites"></a>

{% content-ref url="/pages/-Mg5U-5eb4UqoAhffuDM" %}
[Getting started](/xact/sdk/php/getting-started.md)
{% endcontent-ref %}

## Step 1: Get Xact Fees

Before initializing the payment, you probably need to get the fees from our service. For that matter, we will simply need to specify the amount of the transaction

```php
/* Set your Amount in Hbar */
$hbarAmount = 10; 
/* Get the service fees */
$fees = $client->getXactFeesPayment($hbarAmount);
```

{% hint style="info" %}
The amount must be specified in Hbar
{% endhint %}

## Step 2:  Initialize a Payment

When initializing a payment, a request is sent to the end user for authorization. A Webhook must be defined as a second parameter and will be called every time a new payment is successful.

### 1.1 From an account to an account

```php
/* Hbar to transfer */
$hbarAmount = 10;
/* AccountId that send the Hbar */
$fromAccountId = '';
/* AccountId that received the Hbar */
$toAccountId = '';
/* Add a memo */
$memo = '';
/* Custom uniq ID */
$uniqId = '';
/* Define a Webhook */
$webhook = '';

/* Request for payment */
$client->pay([
    $hbarAmount,
    $fromAccountId,
    $toAccountId,
    $memo,
    $uniqId
],$webhook);
```

### 1.2 From an account to an account and to a middleman

You can also add **middleman account to pay** throughout the process. Middleman take fees, those fees can be a fixed amount of HBAR (`MiddleManFeesType.HBAR`) or a percent (`MiddleManFeesType.PERCENT`) of the `hbarAmount`, the type is defined in the `middleManTypeOfFees` property.

{% hint style="info" %}
Payer account `fromAccountId` will pay Hedera Hashgraph network fees for each transaction. If there is three middlemen and one recipient, payer will pay four transactions fees.&#x20;
{% endhint %}

```php
/* Hbar to transfer */
$hbarAmount = 10;
/* AccountId that send the Hbar */
$fromAccountId = '';
/* AccountId that received the Hbar */
$toAccountId = '';
/* add a memo */
$memo = '';
/* Add 3rd-party payment */
$middleMen = [
    [
        'middleManAccountId' => '0.0...',
        'middleManTypeOfFees' => 'hbar',
        'middleManFees' => 10
    ],
    [
        'middleManAccountId2' => '0.0...',
        'middleManTypeOfFees' => 'percent',
        'middleManFees' => 2
    ],

];

/* Define a Webhook */
$webhook = '';

/* Request for payment */
$client->pay([
    $hbarAmount,
    $fromAccountId,
    $toAccountId,
    $middleMen,
    $memo
],$webhook);
```

On each user's validation, you will receive a JSON like this :

| Fields        | Type                    | Description                                 |
| ------------- | ----------------------- | ------------------------------------------- |
| fromAccountId | string                  | Account Id of the emitter                   |
| toAccountId   | string                  | Account Id of the receiver                  |
| amount        | number                  | HBAR sent from fromAccountId to toAccountId |
| memo          | string                  | Memo sent                                   |
| status        | 'Accepted' or 'Refused' | Status of the request                       |
| uniqId        | string                  | Custom Uniq Id                              |

Find more details on the Webhook implementation [here](https://xact.gitbook.io/xact/sdk/php/getting-started#step-3-webhook-use-case)

⭐ Congratulations! You have successfully completed a payment process
