🉑Accept Payments
Inline Checkout - Popup
The Lazerpay popup provides a convenient and easy way for developers to accept payments on the web. You can start receiving payments on your website with the checkout easily.
1. Add the Inline Checkout
Add the inline checkout to your website using a script tag, it is delivered through a reliable CDN.
<script>
https://cdn.jsdelivr.net/gh/LazerPay-Finance/checkout-build@main/[email protected]/dist/index.min.js
</script>
2. Collect user Details
To receive payments you will need to pass some parameters which include some functions and optional customer information. They include:
Props | FUNCTIONALITY | Priority | Type |
---|---|---|---|
name | Customers Name | Optional |
|
Customer email | Optional |
| |
amount | Customer amount to pay(in USD, AED, GBP, EUR, NGN) | Required |
|
reference | Unique case sensitive transaction reference. If you do not pass this parameter, Lazerpay will generate a unique reference for you. | Optional |
|
acceptPartialPayment | If you want accept partial payment from customers, By default it's false | Optional |
|
key | Lazerpay key. Get you public key from your Lazerpay dashboard. Testnet public keys begin with "pk_test_" and mainnet keys begin with "pk_live_". | Required |
|
currency | The currency | Required |
|
metadata | Stringified JSON object of custom data. eg | Optional | Object |
onClose | The function called when the payment modal closes. | Optional |
|
onSuccess | The function called after the payment is confirmed. | Optional |
|
onError | The function that is called if an error occurs during payment confirmation. | Optional |
|
When you add the inline checkout script, you immediately have access to the LazerCheckout
function. Pass the information you get in step 2 to the function in an object inside the payWithLazerpay
function.
The customer information can be retrieved from your database if you already have it stored, or from a form like in the example below:
In this sample, notice how:
The Lazerpay inline javascript is included using a
script
tag. This is how you import Lazerpay into your code.The
name
andemail
here can be optional. The PopUp will provide those fields to the customersThe
Pay With Lazerpay
button has been tied to anonClick
function calledpayWithLazerpay
. This is the action that causes the Lazerpay popup to load.
Initialize Payment API
The initialize payment endpoint allows you to initiate payment directly to Lazerpay by passing in the payment details
POST
https://api.lazerpay.engineering/api/v1/transaction/initialize
Headers
Name | Type | Description |
---|---|---|
x-api-key* | String | YOUR_PUBLIC_KEY |
Request Body
Name | Type | Description |
---|---|---|
reference | String | YOUR_REFERENCE |
customer_name* | String | Your Customer's name |
customer_email* | String | Your Customer's email |
coin* | String | Stablecoins you want your customers to pay you in. |
currency* | String | Currency should be in the currency you accept on your store, or application |
amount* | String | Number | The amount you want to charge the customer in the currency specified above |
accept_partial_payment | Boolean | This parameter is set to "false" by default. When you want to accept partial payments and ensure customers complete the required amount they are supposed to pay, it should be set to true |
Important Note
The
coin
field must either be "BUSD", "DAI", "USDT", or "USDC".It's ideal to generate a unique
reference
from your system for every transaction to avoid duplicate attempts.The
accept_partial_payment
field is used to enforce payment completion by your customers. A scenario is when a customer is trying to pay for a service worth a fixedamount
of $100 USD. Whenaccept_partial_payment
is set to false, the customer must pay the exact amount before the funds will be sent to you. Read more about Partial Payments hereThe
amount
field should be in your fiat currency. The currencies we support are USD, AED, GBP, EUR and NGN. Please reach out to [email protected] if you would want us to support a currency.The
amount
during initialization is converted to the coin equivalent of thecurrency
specified.
Never call the Lazerpay API directly from your frontend to avoid exposing your secret key on the frontend. All requests to the Lazerpay API should be initiated from your server, and your frontend gets the response from your server.
Lazerpay's NodeJS SDK
The SDK allows you to initialise a payment transaction and to confirm payment. It's an NPM package so you can use it in a node environment.
Here's a sample code on how to use the NodeJS SDK
Response Object
When a payment is successful, Lazerpay sends a DEPOSIT_TRANSACTION
webhook event to the webhook URL that you provide. It is highly recommended that you use webhooks to confirm the payment status before delivering value to your customers.
Last updated