2.9.18 • Published 2 years ago

@tonpay/sdk v2.9.18

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

2.9.18

2 years ago

2.9.17

2 years ago

2.6.15

2 years ago

2.6.14

2 years ago

2.9.16

2 years ago

2.7.15

2 years ago

2.8.15

2 years ago

2.9.15

2 years ago

2.4.9

2 years ago

2.4.10

2 years ago

2.6.12

2 years ago

2.6.13

2 years ago

2.4.11

2 years ago

1.4.9

2 years ago

1.4.8

2 years ago

0.2.7

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago