## Tutorials

The Tutorials section provides step-by-step guidance for using the TalusPay API to handle key business operations.

### How to Create a Merchant, Process a Payment, and Set Up a Webhook with TalusPay API

#### 1. Create a Merchant

To create a new merchant using the TalusPay API, refer to the [Create Merchant API Documentation](https://docs.taluspay.com/openapi/merchants/create%20merchant).

**Steps:**

1. Use the `POST` method to create a new merchant.
2. Include the relevant business and contact information in the request body.
3. On success, you will receive a `merchantId` that can be used for future operations.
4. Wait till merchant application onboarding is approved `onboarding_status: APPROVED`


#### 2. Create a Payment (Scan-to-Pay)

After successfully creating a merchant, you can initiate a payment using the Scan-to-Pay feature. For more details, refer to the [Create Scan to Pay Payment API Documentation](https://docs.taluspay.com/openapi/payments/create%20scan%20to%20pay%20payment).

**Steps:**

1. Use the `POST` method with the merchant's `merchantId`.
2. Specify the payment amount, currency, and other relevant details in the request body.
3. You will receive a response with a `paymentRequestId` and a QR code URL for the customer to scan and pay.


#### 3. Set Up a Webhook

To receive real-time notifications about events such as payment completions, merchant onboarding status, you can set up a webhook. Full instructions can be found in the [Create Webhook API Documentation](https://docs.taluspay.com/openapi/webhooks/create%20webhook).

**Steps:**

1. Use the `POST` method to create a webhook for specific scope events like `merchant` and `charge` that will return events ex. `mercahnt.approved` or `charge.paid`.
2. Provide the target URL for the webhook and an optional secret for securing the webhook.
3. On success, you will receive a `webhookId` for managing or updating the webhook later.


By following these steps, you can create merchants, process payments, and set up webhooks using the TalusPay API efficiently.


```mermaid
sequenceDiagram
    autonumber
    participant Client as Client
    participant API as API

    Client->>API: [POST /v1/merchants](Create Merchant)
    API-->>Client: Merchant ID received
    Note over API,Client: Merchant creation process
    
    API-->>Client: Webhook Event: merchants.approved
    Note right of Client: Merchant approved received, only then payments are enabled
    
    Client->>API: [POST /v1/scan-to-pay] (Create Scan To Pay Payment)
    API-->>Client: Payment Request ID received
    Note over API,Client: Payment creation process
    
    API-->>Client: Webhook Event: charge.paid
    Note right of Client: Payment confirmed
```