# Payment flow

## Invoice & Payment Flow via REST API

Integrating with FuratPay’s REST API involves creating an invoice, requesting payment, and handling webhook notifications for status updates.

<div data-full-width="true"><figure><img src="https://2367665784-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeH0Hlx851e8pROGoNijx%2Fuploads%2FWOPzHWM2BGJnAQJ534CH%2FFurat-payment-flow.drawio%20(1).png?alt=media&#x26;token=ba6f5494-bae3-4409-9456-b15bce630336" alt=""><figcaption><p>Payment Flow</p></figcaption></figure></div>

### **1. Creating an Invoice**

The first step is to create an invoice (bill) on FuratPay by making a **POST request** to the invoice creation endpoint. This generates an **invoice ID**, which is required for all subsequent steps.

Your application **does not need to manage financial transactions**—FuratPay handles all payment logic. Your system only needs to manage **cart logic** and store the **invoice ID** for reference.

**Response: Invoice Object**

Once the invoice is created, FuratPay returns the **invoice object**, which contains all necessary details, including the **invoice ID** required to proceed with payment.&#x20;

### **2. Requesting Payment for an Invoice**

After retrieving the available **linked payment services**, you initiate a **POST request** to request a payment, passing:

* **payment\_service\_id** (the selected payment method)
* **invoice.id** (the generated invoice)

**Response: Payment Service Data**

FuratPay will return the necessary response for the selected payment service. For example:

* A **redirect URL** for ZainCash
* A **QR code** for First Iraqi Bank (FIB)

### **3. Payment Processing & Result**

FuratPay communicates with the payment service and processes the transaction. Once completed, it returns the **payment result** from the provider.

### **4. Webhook Notification**

When an invoice status changes (e.g., marked as **PAID**), FuratPay triggers a **webhook notification** to your predefined endpoint. The webhook payload includes:

* **Event type** (e.g., `INVOICE_PAID`)
* **Invoice data**
* Any other necessary details related to the transaction

By following this process, your service can efficiently handle billing and payments without managing the financial logic directly.
