Skip to content

Latest commit

 

History

History
182 lines (138 loc) · 5.84 KB

collect.mdx

File metadata and controls

182 lines (138 loc) · 5.84 KB
title description
Collect
Collect local currency payments from customers

title

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:

We use a simple **3 step** ID verification flow. The user only needs to verify identity once. After the user has verified their identity, we create a permanent account for the user to make payments to at any time. Anytime the user makes payment to their account, a voucher is instantly created for them. 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.

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 for more details.

Create a voucher

You can create a voucher in two different ways:

### 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.
**callback:** When a payment is successful the user will be redirected to this URL with the `vouchercode` appended to the URL as shown below{" "}
callback?vouchercode=samplecode

Building your redirect URL

```javascript TypeScript 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
const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: JSON.stringify({email: '[email protected]', 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
{
  "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
callback?vouchercode=samplecode
```

### Building your redirect URL

<CodeGroup>
```javascript TypeScript
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

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 for more details

**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.