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

# Collect

> Collect local currency payments from customers

![title](https://res.cloudinary.com/payourse-technologies-inc/image/upload/v1711722450/seo-partna/collect_yceqli.webp)

## User flow

Our collect API allows your customers to pay in local currency easily using a voucher system we've developed from the ground up.

Here's how the process looks like for your customers:

<Steps>
  <Step title="User verifies identity">
    We use a simple **3 step** ID verification flow. The user only needs to
    verify identity once.
  </Step>

  <Step title="User account created">
    After the user has verified their identity, we create a permanent account
    for the user to make payments to at any time.
  </Step>

  <Step title="Create voucher">
    Anytime the user makes payment to their account, a voucher is instantly
    created for them.
  </Step>

  <Step title="Redeem voucher">
    Once voucher payment is done, voucher can be redeemed. You either auto
    redeem the voucher for the user, or allowing them to manually redeem using a
    code in your app.
  </Step>
</Steps>

## Update your merchant information

Once you get your API credentials, update your merchant details using our **update merchant record**.

**Params:**

1. `logo` : Sets your widget logo.
2. `callbackUrl` : Your callback URL. Webhook will be sent to this URL.
3. `feeBearer` : Payee of the transaction fees.
4. `creditCurrency` : Sets which currency to be settled in after voucher is redeemed

See our [update-merchant](/api-reference/endpoint/ventogram/merchants/update-merchant-record) API reference for more details.

## Create a voucher

You can create a voucher in two different ways:

<AccordionGroup>
  <Accordion title="Method 1">
    ### Redirect users to our pay URL

    `https://staging.ventogram.com/v1/voucher/pay?currency=NGN&voucherId=${voucherId}&amount=${amount}&fullname=${fullname}&email=${email}&user=${merchant}&callback=${callback}`

    **Params:**

    1. `voucherId` : (optional) A unique ID (min length=32) generated by the merchant used to create a voucher.
    2. `amount` : The value of the voucher.
    3. `currency` : Currency in which voucher will be created and redeemed.
    4. `fullname` : Voucher recipient full name.
    5. `email` : Voucher recipient email.
    6. `merchant` : Merchant's username.
    7. `callback` : Successful payment redirect URL.

    <Note>
      **callback:** When a payment is successful the user will be redirected to this
      URL with the `vouchercode` appended to the URL as shown below{" "}
    </Note>

    ```bash theme={null}
    callback?vouchercode=samplecode
    ```

    ### Building your redirect URL

    <CodeGroup>
      ```javascript TypeScript theme={null}
      const redirectURL = "https://staging.ventogram.com/v1/voucher/pay"
      const callback = `${window.location.protocol}//${window.location.host}/redeemvoucher`
        
      const params = new URLSearchParams()  
      params.append('amount', amount)  
      params.append('voucherId', voucherId) 
      params.append('currency', 'NGN')  
      params.append('fullname', fullname)  
      params.append('email', email)  
      params.append('user', merchant)  
      params.append('callback', callback)

      const url = `${redirectURL}?${params.toString()}`

      //You could redirect your users to the url just formed like so  
      window.location.href = url

      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Method 2">
    ### Step 1

    Use the Create Voucher API to generate a voucher id. See our [create-voucher](/api-reference/endpoint/ventogram/voucher/create-a-new-voucher-payment) reference for more details.

    <CodeGroup>
      ```javascript Request theme={null}
      const options = {
        method: 'POST',
        headers: {accept: 'application/json', 'content-type': 'application/json'},
        body: JSON.stringify({email: 'youremail@mailserver.com', fullname: 'ali deen', amount: 2000, merchant:'macdonalds'})
      };

      fetch('https://staging-vouchers.ventogram.com/api/v1/vouchers', options)
        .then(response => response.json())
        .then(response => console.log(response))
        .catch(err => console.error(err));
      ```

      ```javascript Response 201 theme={null}
      {
        "success": true,
        "message": "string",
        "data": {
          "id": "string"
        }
      }

      ```
    </CodeGroup>

    ### Step 2

    Redirect your users to the pay URL
    `https://staging.ventogram.com/voucher/pay?voucherId=${voucherId}&callback=${callback}` to view voucher payment details.

    **Required params:**

    1. `voucherId` : The id returned by the Create Voucher API from Step 1.
    2. `callback` : Successful payment redirect URL.

    <Note>
      **callback:** When a payment is successful the user will be redirected to this
      URL with the `vouchercode` appended to the URL as shown below{" "}
    </Note>

    ```bash theme={null}
    callback?vouchercode=samplecode
    ```

    ### Building your redirect URL

    <CodeGroup>
      ```javascript TypeScript theme={null}
      const redirectURL = "https://staging.ventogram.com/v1/voucher/pay"
      const callback = `${window.location.protocol}//${window.location.host}/redeemvoucher`
        
      const params = new URLSearchParams()  
      params.append('voucherId', voucherId) 
      params.append('callback', callback)

      const url = `${redirectURL}?${params.toString()}`

      //You could redirect your users to the url just formed like so  
      window.location.href = url

      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

Completing the above steps using either **Method 1** or **Method 2** will issue a permanent account to the user that they can deposit funds to at any time.

## Redeem a voucher

After creating a voucher, your users will be directed to the provided callback URL upon successful payment.

**Your callback URL will receive the following query parameters:**

1. `vouchercode` : The code used to redeem the voucher.
2. `voucherId` : The ID of the created voucher.

See our [redeem-voucher](/api-reference/endpoint/ventogram/voucher/redeem-existing-unused-voucher)  API reference for more details

<Tip>
  **feeBearer:** The `feeBearer` param allows you to choose between `client` or `merchant` as the payee of the fee. `merchant` will charge fees from your balance, while `client` will charge fees from the customer.
</Tip>
