Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
vic-payment-js
Advanced tools
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;
vicTokenAddress: string;
paymentGatewayAddress: string;
};
FAQs
VIC Pay SDK
The npm package vic-payment-js receives a total of 5 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 for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.