This crate integrates the Lazerpay payment gateway for accepting cryptocurrency payments.
Add the following to your cargo.toml
toml
lazerpay-rust-sdk = "0.1.0"
Then you can easily import the crate.
```rust
use lazerpayrustsdk::Lazerpay;
```
Next you will need to create a Lazerpay instance with the help your API_PUBLIC_KEY
and API_SECRET_KEY
you can get that easily from your Lazerpay dashboard
```rust use serdejson::Value; use lazerpayrust_sdk::Lazerpay;
mod utils;
async fn main() { let api = utils::getapikeys().unwrap(); let lazerpay: Lazerpay = Lazerpay::new(&api.publickey, &api.secretkey);
let response = initialize_payment(
lazerpay,
"xxxxxxxxxxxxxxxxxxxxx".to_string(),
"1000".to_string(),
"xxxxx".to_string(),
"xxxxx@gmail.com".to_string(),
"USDC".to_string(),
"USD".to_string(),
api.public_key.to_string(),
true
).await;
println!("Response -> {:?}", response);
}
async fn initializepayment ( lazerpay: Lazerpay, reference: String, amount: String, customername: String, customeremail: String, coin: String, currency: String, apipublickey: String, acceptpartialpayment: bool ) -> Value { lazerpay.payment.initializepayment( reference, amount, customername, customeremail, coin, currency, apipublickey, acceptpartialpayment ).await }
async fn confirmpayment ( lazerpay: Lazerpay, identifier: String, ) -> Value { lazerpay.payment.confirmpayment("xxxxxxxxxxxxxxxxxxxxx".to_string()).await }
async fn getacceptedcoins ( lazerpay: Lazerpay, ) -> Value { lazerpay.payment.getacceptedcoins().await }
async fn getrate ( lazerpay: Lazerpay, currency: String, coin: String, ) -> Value { lazerpay.payment.getrate( currency, coin, ).await }
async fn transferfunds ( lazerpay: Lazerpay, amount: u32, recipient: String, coin: String, blockchain: String, apipublickey: String, apisecretkey: String, ) -> Value { lazerpay.payment.transferfunds( amount, recipient, coin, apipublickey, apisecretkey, ).await } ```
and that's it.
If you need more reference on this crate feel free to check the source code