npm.io
2.69.0 • Published 7h ago

@paypay/mini-app-js-sdk

Licence
MIT
Version
2.69.0
Deps
1
Size
1.7 MB
Vulns
0
Weekly
0

mini-app-js-sdk

Installation

The SDK is provided as NPM package. Please add it to your project by:

npm i @paypay/mini-app-js-sdk -S
# OR 
yarn add @paypay/mini-app-js-sdk

To use the Javascript API, please add the following import:

import pp from "@paypay/mini-app-js-sdk";
Option 2: HTML

The SDK can also be used by simply including it in your HTML code:

<script src="https://static.paypay.ne.jp/libs/mini-app-js-sdk/<version#>/mini-app-js-sdk.js"></script>

Getting started

The Javascript automatically detects if you are running your website inside PayPay's Mini App environment or inside a browser.

Please initialize the SDK with the following command:

pp.init({
  clientId: 'YOUR_CLIENT_ID',
  env: 'sandbox', //default: 'production'
  success() {
    console.log('init successful')
  },
  fail() {
    console.log('init failed')
  },
})

After initializing, the Mini App JS SDK is ready to use. You can verify it by getting a success callback with a sample call, i.e.:

pp.getUAID({
  success: (res) => {
    console.log(JSON.stringify(res))
  },
  fail: (error) => {
    console.log(JSON.stringify(error))
  },
  complete: () => {}
})