> ## Documentation Index
> Fetch the complete documentation index at: https://paydocs.dashu.sa/llms.txt
> Use this file to discover all available pages before exploring further.

# executePayment

> Executes a payment using the SessionId you have from the `initiateSession` endpoint. This endpoint will return a payment URL to redirect your customers to the payment page.

### Query Parameters

<ParamField body="apiKey" type="string" placeholder="API Key" required>
  The API Key of your account.
</ParamField>

<ParamField body="data" type="object" required>
  <Expandable title="properties" defaultOpen={true}>
    <ResponseField name="SessionId" type="string">
      The SessionId you have from the `initateSession` endpoint.

      Sample: `783851c4-b10f-4e40-bb2c-fcb657975ffb`.
    </ResponseField>

    <ResponseField name="InvoiceValue" type="string">
      The invoice total amount that should be paid by the customer.

      Sample: `313.14`.
    </ResponseField>

    <ParamField body="Suppliers" type="array" required>
      <Expandable title="properties" defaultOpen={true}>
        <ResponseField name="SupplierCode" type="integer" required>
          Your Supplier Code (you'll get it after joining DashPay)

          Sample: `123`.
        </ResponseField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="test" type="boolean" initialValue={true}>
  Set this property to `true` to send the request to the development
  environment.
</ParamField>

<ResponseExample>
  ```json Success theme={null}
  {
    "IsSuccess": true,
    "Message": "Invoice Created Successfully!",
    "ValidationErrors": null,
    "Data": {
      "InvoiceId": 927972,
      "IsDirectPayment": false,
      "PaymentURL": "https://demo.MyFatoorah.com/Ar/KWT/PayInvoice/Checkout?invoiceKey=0106292797237&paymentGatewayId=20",
      "CustomerReference": "noshipping-nosupplier"
    }
  }
  ```

  ```json Error theme={null}
  {
    "success": false,
    "code": 5,
    "test": true,
    "message": "Invalid data",
    "errors": [
      {
        "Name": "SessionId",
        "Error": "SessionId is invalid!"
      }
    ]
  }
  ```
</ResponseExample>

### Response properties

<ResponseField name="IsSuccess" type="boolean" required>
  The response status.
</ResponseField>

<ResponseField name="Message" type="string" required>
  The description of the response status.
</ResponseField>

<ResponseField name="ValidationErrors" type="array|null" required>
  List of validation errors (if any).
</ResponseField>

<ResponseField name="Data" type="object" required>
  <Expandable title="properties" defaultOpen={true}>
    <ResponseField name="InvoiceId" type="integer" required>
      A unique integer value of the created invoice.
    </ResponseField>

    <ResponseField name="IsDirectPayment" type="boolean" required>
      `true` or `false` to indicate if this URL for Direct Payment method.
    </ResponseField>

    <ResponseField name="PaymentURL" type="string" required>
      The URL that you should redirect the customer to OR submit the card
      details to process the payment.
    </ResponseField>

    <ResponseField name="CustomerReference" type="string" required>
      Refers to the order or transaction ID in your system that you have sent in
      the request earlier.
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Codes

Here's a list of possible error codes of this endpoint.

| **Code** | **Description**                         |
| -------- | --------------------------------------- |
| 1        | Missing or invalid api key              |
| 2        | `InvoiceValue` is a required parameter. |
| 3        | `Suppliers` is not valid.               |
| 4        | wrong supplier code.                    |
| 5        | An error meessage from the bank.        |
