1.0.0-alpha.15 • Published 2 years ago
alfabank v1.0.0-alpha.15
- axios
- composition api like
- written on typescript (autocomplete filed)
register.do
register.do
withorderBundle
getOrderStatus.do
getOrderStatusExtended.do
addParams.do
refund.do
based on merchant manual - ru
Installing
Install alfabank package
npm i alfabank
# or
yarn add alfabank
import
import { useAlfaBank, toBynPenny } from 'alfabank'
Usage
toBynPenny
convert human amount to minimum unit of measure
toBynPenny(10.5)
// Result: 1050
useAlfaBank
instance for action
Options
token
- (string) Token
userName
- (string) Login for integration
password
- (string) Password for integration
language
- (string, default: ru) language for all requests
const alfaBank = useAlfaBank({
token: 'your token'
// or
userName: 'your name',
password: ' yor',
language: 'en'
})
Autorization example, for storage use .env
variables
Methods
register
- Register order
const result = await alfaBank.register({
amount: toBynPenny(115 * 2),
orderNumber: '1234',
returnUrl: `https://mysite/order/status`,
jsonParams: {
email: 'test@mail.ru',
phone: '+375251001100',
},
orderBundle: {
cartItems: {
items: [
{
name: 'Apple iPhone XR 64GB',
positionId: 1,
quantity: {
measure: 'pieces',
value: 2,
},
itemCode: '2',
},
],
},
},
})
if (result?.orderId) {
console.log(result.formUrl, result.orderId)
} else if (result?.errorCode) {
throw new Error(result.errorMessage)
}
refund
- Order payment refund
const refundData = await alfaBank.refund({
amount: toBynPenny(115 * 2),
orderId: '291c4b92-4c38-70db-b265-5a2000c91c61',
})
console.log(refundData)
getOrderStatus
- get order status
getOrderStatusExtended
- get extended order status
mutate response:
params
- field with value converted merchantOrderParams
array to object like {"key": "value"}
paid
- boolean - syntax sugar for check is order paid
{
// ...
merchantOrderParams: [
{
name: "browser_language_param",
value: "ru"
},
],
params: {
browser_language_param: "ru",
// ...
}
}
addParams
- add params to order
1.0.0-alpha.15
2 years ago
1.0.0-alpha.14
4 years ago
1.0.0-alpha.13
4 years ago
1.0.0-alpha.12
4 years ago
1.0.0-alpha.9
4 years ago
1.0.0-alpha.10
4 years ago
1.0.0-alpha.11
4 years ago
1.0.0-alpha.8
4 years ago
1.0.0-alpha.7
4 years ago
1.0.0-alpha.6
4 years ago
1.0.0-alpha.5
4 years ago
1.0.0-alpha.4
4 years ago
1.0.0-alpha.3
4 years ago
1.0.0-alpha.2
4 years ago
1.0.0-alpha.1
4 years ago