New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@tonpay/sdk

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tonpay/sdk

Tonpay JavaScript SDK

latest
Source
npmnpm
Version
2.9.18
Version published
Maintainers
1
Created
Source

Tonpay JavaScript SDK

JavaScript SDK for Tonpay

Installation

npm install @tonpay/sdk

or with yarn

yarn add @tonpay/sdk

Full documentation

Full documentation for this SDK is available on GitBook.

Example usage

import { Tonpay } from "@tonpay/sdk";

// implement a Sender interface from 'ton' library or use @tonpay/react package for useSender() hook
// hint: you don't need sender if you don't plan to interact with the TON Blockchain (i.e. if you only want to generate payment links or fetch info)
const sender = buildSender();

// create Tonpay instance
const tonpay = Tonpay.create("testnet", sender);

// get your interactive store by address
const store = tonpay.getStore(
  "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"
);

// get a payment link and provide it in any form (button, QR code) to the customer
const paymentLink = await store.getRequestPurchaseLink({
  invoiceId: "test_invoice_id",
  amount: 5
}, "tonkeeper");

// or initiate a purchase request and get the invoice address even before it's created on-chain
const invoice = await store.requestPurchase({
  invoiceId: "test_invoice_id",
  amount: 5 // TON
});

// now you can monitor invoice status manually
const isPaid = await invoice.isPaid();

// or redirect to hosted checkout page that'll display the payment state automatically

const hostedCheckoutUrl = `https://pay.thetonpay.app/i/${invoice.address}`;
window.location.href = hostedCheckoutUrl;

Demo store that uses this SDK can be found here.

Contact @Arterialist if you have questions and open issues on github, if there are any.

Keywords

tonpay

FAQs

Package last updated on 06 Jul 2023

Did you know?

Socket

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.

Install

Related posts