@4a/sdk-payment 中文文档教程
Payment
收银台SDK
- v0.x for payment1.0
- v2.x for payment2.0
Usage
const { Payment } = require('@4a/sdk-payment')
// or
import Payment from '@4a/sdk-payment'
const pay = new Payment({
appId: 'appId',
appSecret: 'appSecret',
baseURL: 'http://localhost:9121',
})
API
interface PlainObject {
[key: string]: any
}
interface Options {
appId: string
appSecret: string
baseURL: string
}
export declare class Payment {
sign: any
baseURL: string
constructor({ appId, appSecret, baseURL }: Options)
prepay(trade: PlainObject): Promise<any>
query(tradeid: string): Promise<any>
verifySign(params: PlainObject): boolean
isPaid(tradeid: string): Promise<boolean>
/**
* @deprecated
* verifyTrade is deprecated, please use {isPaid}
*/
verifyTrade(tradeid: string): Promise<boolean>
}
For FE
import { gotoPay } from '@4a/sdk-payment/dist/fe'
function gotoPay(baseURL: string, tradeid: string, params?: PlainObject): void