vic-payment-js
Advanced tools
Payment for VIC coin
Weekly downloads
Readme
TypeScript library to interact with VIC PaymentGateway
This library provide functions for both frontend and backend to interact with PaymentGateway
Provide functions for:
Provide functions for:
We can directly install from npm:
npm install vic-payment-js
yarn add vic-payment-js
All modules packaged in vic-payment-js, however the usage for frontend and backend is completely different.
The key different is on frontend we don't require any apiKey to initialized library, but on backend we require apiKey
to interact with PaymentGateway.
On Frontend, we use the Client
module from vic-payment-js
Import Client into project:
import { Client } from "vic-payment-js";
Client module provide static method to directly handle PaymentSession returned from BE Merchant, ex:
// Ask User to pay for Order
const session = /*...from BE Merchant ...*/;
Client.userPay(session);
On Backend, we use the Session
, Event
module from vic-payment-js
Session module
Import Session into project:
import { Session } from "vic-payment-js/lib/session";
// Initialize session with apiKey
const session = Session.init({ apiKey });
Session module provide methods to send request to PaymentGateway to create PaymentSession, ex:
const paymentSession = await session.ofUserPay({
paymentId: nanoid(12),
amount: 50000,
chainName: "BINANCE",
metadata: {
orderId: req.params.id,
},
});
Event module
Import Event into project:
import { Event } from "vic-payment-js/lib/session";
// Initialize event with apiKey
const event = Event.init({ apiKey });
Event module provide methods to verify PaymentEvent
sent from PaymentGateway, ex:
router.post("/api/test/webhook", async (req, res) => {
const webhookEvent = req.body;
try {
const paymentEvent = event.verifySignature(webhookEvent);
console.log("paymentEvent", paymentEvent);
return res.json({ message: "Received" });
} catch (err) {
console.log("Fail to verify event", err.message);
return res.json({ message: err.message });
}
});
PaymentEvent
has base schema:
type PaymentEvent = {
paymentId: string;
chainName: string;
metadata?: Record<string, unknown>;
merchantAddress: string;
vndtTokenAddress: string;
paymentGatewayAddress: string;
};
FAQs
Payment for VIC coin
The npm package vic-payment-js receives a total of 49 weekly downloads. As such, vic-payment-js popularity was classified as not popular.
We found that vic-payment-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.