Unofficial PayPay client
- Login
- Get balance
- Get History
- Accept Link
- Create Link
- Send Money
- Get Account Info
// CommonJS
const { PayPay, PayPayLoginStatus } = require("paypay.js");
const { createInterface } = require("readline");
// ESM or TypeScript
import { PayPay, PayPayLoginStatus } from "paypay.js";
import { createInterface } from "readline";
const rl = createInterface({
input: process.stdin,
output: process.stdout
})
const paypay = new PayPay();
const loginResult = await paypay.login("09012345678", "password");
if (loginResult.status === PayPayLoginStatus.DONE) {
console.log("Logged in!");
console.log(`Your access Token: ${loginResult.accessToken}`);
} else if (loginResult.status === PayPayLoginStatus.OTP_REQUIRED) {
console.log("OTP Required");
rl.question(`Enter otp code: ${loginResult.otpPrefix}-`, async (answer) => {
const otpResult = await paypay.loginOtp(loginResult.otpReferenceId, answer);
console.log("Logged in!");
console.log(`Your access Token: ${otpResult.accessToken}`);
})
}
const paypay = new PayPay({ accessToken: "YOUR_ACCESS_TOKEN" });
console.log(await paypay.getBalance()); // get balance
console.log(await paypay.getHistory()); // get history
console.log(await paypay.getLinkInfo("L1nKc0dE")); // get send money link info
console.log(await paypay.acceptLink("L1nKc0dE")); // accept link
console.log(await paypay.executeLink(100)); // create 100 yen link