0.0.39 • Published 8 months ago

kakapay-js-sdk v0.0.39

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Kakapay-js-sdk

Simple library for show a custom payment button in any website

Api document: Api Document

Installation

NPM

npm install --save kakapay-js-sdk

CDN

<script src="https://cdn.kakapay.io/sdk/kakapay/kakapay-v1.min.js"></script>
<script>
  console.log(typeof Kakapay); // 'function'
</script>

Quick Start

<!-- Render button placeholder -->
<div id="light-theme-popup"></div>
<form id="form">
  <input type="hidden" name="amount" value="{amount}" />
  <input type="hidden" name="out_trade_no" value="{out_trade_no}" />
  <input type="hidden" name="return_url" value="{return_url}" />
  <input type="hidden" name="notify_url" value="{notify_url}" />
  <input type="hidden" name="title" value="{title}" />
  <input type="hidden" name="description" value="{description}" />
  <input type="hidden" name="currency" value="BRL" />
</form>
import Kakapay from "kakapay-js-sdk";
const appId = "{app_id}";
const appPublishKey = "{app_publish_key}";
const env = "sandbox";
new Kakapay({ appId, appPublishKey, env } as IKakapayParams).render("#light-theme-popup" as string, {
  formSelector: "#form", // Submitted data form
  theme: "light", // light or dark
} as IRenderOptions);

Interface

type IKakapayParams = {
  appId: string;
  appPublishKey: string;
  env?: "sandbox" | "production";
  onModalShow?: () => void;
  onOrderComplete?: () => void;
};

type IRenderOptions = {
  formSelector?: string;
  theme?: "dark" | "light";
};

API

It's easy to use Kakapay-js-sdk to create payin order.

Constructor

Use appId,appPublishKey to initialize the context

constructor Kakapay(props: IKakapayParams): Kakapay
const kakapay = new Kakapay({
  appId,
  appPublishKey,
  env,
  onModalShow,
  onOrderComplete,
});
console.log(kakapay);

render

(property) Kakapay.render: (selector: string, { formSelector, theme }: IRenderOptions) => void
kakapay.render("#light-theme-popup", {
  formSelector: "#form", // Submitted data form
  theme: "light", // Popup theme style
});

Simple web demo

Sandbox

Online demo

Production

Online demo

Others

Preflight

// Important: The SDK will perform preflight preconnection optimization. If you directly use api docking, it is recommended to add preconnection to optimize Payin efficiency
fetch("https://gateway.kakapay.io/api/v1/payin", {
  method: "OPTIONS",
});

Webpack 5 +

Waring: BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

  // webpack.config.js
  {
    ...
    resolve: {
      fallback: {
        ...
        "crypto": false,
        ...
      }
    }
    ...
  }

Authors

This library is created by the team of Kakapay

License

The MIT License.

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.0.32

9 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.0.31

9 months ago

0.0.30

9 months ago

0.0.29

9 months ago

0.0.28

9 months ago

0.0.27

9 months ago

0.0.26

9 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago