Skip to content

moneyboxes

MoneyBoxes payments.

Overview

k.payment.moneyBoxs is used to create MoneyBoxes payment requests, supporting card information, billing address, shipping address and item details. MoneyBoxs merchant information needs to be configured in the site CMS before use.

moneyBoxes.charge()

Create a MoneyBoxs payment request.

ts
k.api.post(() => {
    const result = k.payment.moneyBoxs.charge({
        name: 'TEST order',
        description: 'Order payment',
        totalAmount: 100,
        currency: 'USD',
        order: 'order-id',
        returnUrl: '/payment/success?orderId=order-id',
        card: {
            number: '378282246310005',
            expMonth: '03',
            expYear: '2030',
            cvc: '123',
            name: 'John Doe'
        },
        billingAddress: {
            firstName: 'Customer',
            lastName: 'MoneyBoxs',
            countryCode: 'US',
            state: 'California',
            city: 'LA',
            address1: 'Test Address',
            zip: '12345',
            email: 'testcustomer@example.com',
            phone: '13800138000'
        },
        shipAddress: {
            firstName: 'Customer',
            lastName: 'MoneyBoxs',
            countryCode: 'US',
            state: 'California',
            city: 'LA',
            address1: 'Test Address',
            zip: '12345',
            email: 'testcustomer@example.com',
            phone: '13800138000'
        },
        goods: [
            { goodsName: 'T-shirt', quantity: '1', goodsPrice: '100' }
        ]
    })

    if (result.nextAction?.redirectUrl) {
        return k.response.redirect(result.nextAction.redirectUrl)
    }

    return { paid: result.paid, requestId: result.requestId }
})

Parameter: MoneyBoxsParams

parametertypeRequiredillustrate
returnUrlstringyesJump address after successful 3D verification
cardCardyesCard information
billingAddressAddressyesbilling address
shipAddressAddressyesShipping address
goodsGood[]yesProduct details
totalAmountnumberyesOrder amount
namestringyesOrder name
descriptionstringyesOrder description
currencystringyesCurrency, such as USD
orderstringnoCommerce order ID. Once the payment is successful, the order payment status will be updated.
callbackCodeNamestringnoThe name of the callback code executed after payment is completed

Return: ChargeResponse

checkStatus()

Check payment status.

Parameters:

ParameterTypeRequiredDescription
requestIdstringYesrequestId returned by charge().
ts
k.api.get(() => {
    const status = k.payment.moneyBoxs.checkStatus('request-id')
    return { paid: status.paid, failed: status.failed, status: status.status }
})

Return: PaymentStatusResponse

updateOrder()

Handle MoneyBoxs callbacks and update orders.

Parameters:

ParameterTypeRequiredDescription
contextobjectYesCurrent payment callback context, usually k.payment.moneyBoxs.context.
ts
k.api.post(() => {
    const callback = k.payment.moneyBoxs.updateOrder(k.payment.moneyBoxs.context)
    return { paid: callback.paid, status: callback.status }
})

Return: PaymentCallback

verify3DAuthCallback()

Verify 3D Auth callback.

ts
k.api.post(() => {
    k.payment.moneyBoxs.verify3DAuthCallback(
        'orderNo',
        'merchantNo',
        'terminalNo',
        '100',
        'hashCode',
        '00'
    )
    return 'success'
})

parameter:

parametertypeRequiredillustrate
orderNostringyesOrder number
merchantNostringyesMerchant number
terminalNostringyesterminal number
amountstringyesAmount
hashCodestringyesCallback Hash
respCodestringyesresponse code

Return: void

Good

propertytypeillustrate
goodsNamestringProduct name
quantitystringquantity
goodsPricestringProduct price

MoneyBoxesSetting

propertytypeillustrate
baseUrlstringMoneyBoxs API address
merchantNostringMerchant number
terminalNostringterminal number
keystringkey
transactionURLstringTransaction address
typestringtype