Searchโ€ฆ
๐Ÿ‰‘
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.

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
String
email
Customer email
Optional
String
amount
Customer amount to pay(in USD, AED, GBP, EUR, NGN)
Required
String | Number
reference
Unique case sensitive transaction reference. If you do not pass this parameter, Lazerpay will generate a unique reference for you.
Optional
String | Number
acceptPartialPayment
If you want accept partial payment from customers, By default it's false
Optional
Boolean
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
String
currency
The currency amount is denominated in. Can be USD, GBP, EUR, AED or NGN.
Required
String
metadata
Stringified JSON object of custom data. eg {type: "Wallet fund"}
Optional
Object
onClose
The function called when the payment modal closes.
Optional
Function
onSuccess
The function called after the payment is confirmed.
Optional
Function
onError
The function that is called if an error occurs during payment confirmation.
Optional
Function
โ€‹
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:
<form id="paymentForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" />
</div>
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" id="email-address" />
</div>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="number" id="amount" required />
</div>
<div class="form-submit">
<button type="submit" onclick="payWithLazerpay()"> Pay with Lazerpay </button>
</div>
</form>
โ€‹
<script>
https: //cdn.jsdelivr.net/gh/LazerPay-Finance/[email protected]/[email protected]/dist/index.min.js
</script>
โ€‹
<script>
const paymentForm = document.getElementById('paymentForm');
โ€‹
paymentForm.addEventListener("submit", payWithLazerpay, false);
โ€‹
function payWithLazerpay(e){
e.preventDefault();
LazerCheckout({
reference: 'W6b8hV55l0435t3545435',
name: document.querySelector("#name").value,
email: document.querySelector("#email-address").value,
amount: document.querySelector("#amount").value,
key: "pk_test_xG0EjfzUsGIUDpMeQKZFItGFEBtR5SzHzsqwrzlsdADVzPrjZb",
currency: "USD",
acceptPartialPayment: true // By default it's false
onClose: (data)=>{
},
onSuccess: (data)=>{
},
onError: (data)=>{
}
})
}
</script>
In this sample, notice how:
  1. 1.
    The Lazerpay inline javascript is included using a script tag. This is how you import Lazerpay into your code.
  2. 2.
    The name and email here can be optional. The PopUp will provide those fields to the customers
  3. 3.
    The Pay With Lazerpay button has been tied to an onClick function called payWithLazerpay. 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

Important Note

  1. 1.
    The coin field must either be "BUSD", "DAI", "USDT", or "USDC".
  2. 2.
    It's ideal to generate a unique reference from your system for every transaction to avoid duplicate attempts.
  3. 3.
    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 fixed amount of $100 USD. When accept_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 hereโ€‹
  4. 4.
    The 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.
  5. 5.
    The amount during initialization is converted to the coin equivalent of the currency 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
const LazerPay = require('lazerpay-node-sdk');
โ€‹
const lazerpay = new LazerPay(LAZER_PUBLIC_KEY, LAZER_SECRET_KEY);
โ€‹
const payment_tx = async () => {
try {
const transaction_payload = {
reference: 'W6b8hV55l0435t3545435', // Replace with a reference you generated
customer_name: 'iamnotstatic.eth',
customer_email: '[email protected]',
coin: 'USDC',
currency: 'USD',
fiatAmount: '100',
acceptPartialPayment: true // By default it's false
};
โ€‹
const response = await lazerpay.Payment.initializePayment(transaction_payload);
โ€‹
console.log(response);
} catch (error) {
console.log(error);
}
};

Response Object

{
"reference": "wfqweweqrtwerwrtwer45354545",
"businessName": "Lazerpay Finance",
"businessEmail": "[email protected]",
"businessLogo": "https://res.cloudinary.com/lazer/image/upload/v1637512933/logo-default_ufyz0x.svg",
"customerName": "Abdulfatai Suleiman",
"customerEmail": "[email protected]",
"address": "0xcA20e971400F81F97fEc5416A963e8FA7F81aaE3",
"coin": "BUSD",
"cryptoAmount": 50.5,
"currency": "USD",
"fiatAmount": 50,
"feeInCrypto": 0.5,
"fiatRate": 0.9988,
"cryptoRate": 1.001,
"network": "testnet",
"acceptPartialPayment": true
}
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.
Copy link
Edit on GitHub
Outline
Inline Checkout - Popup
Initialize Payment API
post
Lazerpay's NodeJS SDK