toki-app
v1.2.14
Published
Toki - frontend packages
Downloads
1,159
Readme
Mini application for Toki
For UI components: Components
Installation
The package can be installed via npm:
npm install toki-app
Table of Contents
UI Components
Button
import { Button } from "toki-app";
...
function handleClick(event){
}
return <Button
text="title"
type="primary" // "primary" | "secondary" | "text" | "warning"
onClick={handleClick}>
</Button>
Input
import { Input } from "toki-app";
...
function handleChange(event){
setState()
}
return <Input
placeholder="Username"
value={state}
onChange={handleChange} />
App provided functions
app.buy()
app.selectContact()
app.checkNotification()
app.setColor()
app.openLink()
app.buyfromDynamiclink()
app.setScreenProtection()
app.downloadImage()
app.closeWebView()
Function examples
- Buy
import { app } from "toki-app";
...
function test() {
// Merchant ID
const merchantId = "qwerty"
// Payment amount
const amount = 100
// Unique Order ID
const orderId = "ORD-1234"
const description = "Test order"
/*
Webhook URL for success, failed transactions
Method: POST
Body: orderID, transactionID, statusCode, transRequestId, token, amount
*/
const backendCallbackUrl = "http://localhost:3001/api/v1/order"
app.buy(
merchantId,
amount,
orderId,
description,
(
transactionID: string,
orderID: string,
status: string,
statusCode: any,
transRequestId: string
) => {
// Callback for front-end
onGetOrder();
},
backendCallbackUrl
);
}
function onGetOrder() {
console.log("Transaction done")
}