QIWI SDK / Modules / index / QIWI / P2p
Export
-
↳
P2p
↳↳
_P2pCompat
• new P2p(options?
)
Creates an instance of P2p.
Memberof
P2p
Name | Type |
---|---|
options? |
Partial <P2pApiOptions > |
• Protected
Readonly
_options: P2pApiOptions
Memberof
OptionsWrapper
• Readonly
bills: P2pBillsApi
▪ Static
Readonly
BillCurrency: typeof BillCurrency
= BillCurrency
▪ Static
Readonly
BillPaySource: typeof BillPaySource
= BillPaySource
▪ Static
Readonly
BillStatus: typeof BillStatus
= BillStatus
▪ Static
Readonly
BillsApi: typeof P2pBillsApi
= P2pBillsApi
▪ Static
Readonly
Currency: typeof BillCurrency
= BillCurrency
▪ Static
Readonly
PaySource: typeof BillPaySource
= BillPaySource
▪ Static
Readonly
Status: typeof BillStatus
= BillStatus
• get
agent(): any
Memberof
WalletCompat
any
ApiClass.agent
• set
agent(agent
): void
Memberof
WalletCompat
Name | Type |
---|---|
agent |
any |
void
ApiClass.agent
• get
options(): T
Memberof
OptionsWrapperWithGetter
T
ApiClass.options
▸ notificationMiddleware(options?
, handler?
): RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record
<string
, any
>>
[Экспериментально]
Упрощает интеграцию с express
Name | Type | Description |
---|---|---|
options? |
MiddlewareOptions |
Параметры обработки запроса |
handler? |
BillRequestHandler |
RequestHandler
<ParamsDictionary
, any
, any
, ParsedQs
, Record
<string
, any
>>
В начале файла
const p2p = new QIWI.P2P(process.env.QIWI_PRIVATE_KEY);
Вариант 1 - Классический
app.post('/webhook/qiwi', p2p.notificationMiddleware(), (req, res) => {
req.body // Это `BillStatusNotificationBody`
})
Вариант 2 - Если нужны подсказки типов
app.post('/webhook/qiwi', p2p.notificationMiddleware({}, (req, res) => {
req.body // Это `BillStatusNotificationBody`
}))
Обработка ошибок
app.use((error, request, response, next) => {
console.log(error); // [Error: Notification signature mismatch]
})
▸ Static
create(secretKey
, publicKey?
): P2p
Static
Memberof
P2p
Name | Type | Default value |
---|---|---|
secretKey |
string |
undefined |
publicKey? |
string |
"" |
P2p
▸ Static
env(secretKey?
, publicKey?
): P2p
Static
Memberof
P2p
Name | Type | Default value |
---|---|---|
secretKey? |
string |
environment.QIWI_SECRET_KEY |
publicKey? |
string |
environment.QIWI_PUBLIC_KEY |
P2p
▸ Static
httpClientFactory(secretKey
): SimpleJsonHttp
Static
Memberof
P2p
Name | Type |
---|---|
secretKey |
string |
SimpleJsonHttp