@infinity-payments/checkout-js
v0.1.4
Published
Infinity Checkout JavaScript SDK
Downloads
176
Readme
@infinity/checkout-js
Browser checkout SDK for Infinity.
Install
npm install @infinity/checkout-jsVanilla JavaScript
import { Checkout } from "@infinity/checkout-js";
const checkout = new Checkout({
publishableKey: "pk_test_123",
environment: "sandbox"
});
const session = await checkout.createSession({
paymentLinkId: "plink_123",
customerEmail: "[email protected]"
});
checkout.open(session.url, {
onSuccess: (event) => {
console.log("checkout event", event);
},
onClose: () => {
console.log("checkout closed");
}
});React (no React dependency in this package)
import { useMemo } from "react";
import { Checkout } from "@infinity/checkout-js";
export function PayButton() {
const checkout = useMemo(
() =>
new Checkout({
publishableKey: "pk_test_123",
environment: "sandbox"
}),
[]
);
const handleClick = async () => {
const session = await checkout.createSession({
paymentLinkId: "plink_123"
});
checkout.open(session.url, {
onSuccess: (event) => {
console.log(event);
}
});
};
return <button onClick={handleClick}>Pay now</button>;
}