Types
simplepay-js-sdk exports these types:
ts
import type {
Currency, Language, PaymentMethod, PaymentConfig, StartPaymentConfig, SimplePayUrls,
PaymentData, RecurringPaymentData, TokenPaymentData, PaymentItem, DeliveryAddress, InvoiceAddress, ThreeDSReqAuthMethod,
GooglePayPaymentData, SimplePayGooglePayResponse,
ApplePayStartData, ApplePayChargeData, SimplePayApplePayStartResponse, SimplePayApplePayChargeResponse,
SimplePayResponse, SimplePayRecurringResponse, SimplePayTokenResponse, SimplePayCancelCardResponse,
SimplePayResult, SimplePayIPNResponse,
TransactionStatus, TransactionId, TransactionStatusQuery, SimplePayTransactionStatusResponse,
TransactionQuery, SimplePayQueryResponse, QueriedTransaction, QueriedTransactionDetails, QueriedTransactionRefunds, TransactionRefund,
RefundData, SimplePayRefundResponse,
} from 'simplepay-js-sdk'Basic types
ts
type Currency = 'HUF' | 'HUF_SZEP' | 'EUR' | 'USD'
type PaymentMethod = 'CARD' | 'WIRE'
type Language = 'AR' | 'BG' | 'CS' | 'DE' | 'EN' | 'ES' | 'FR' | 'IT' | 'HR' | 'HU' | 'PL' | 'RO' | 'RU' | 'SK' | 'TR' | 'ZH'
type TransactionStatus = 'INIT' | 'INPAYMENT' | 'INFRAUD' | 'AUTHORIZED' | 'FINISHED' | 'CANCELLED' | 'NOTAUTHORIZED' | 'TIMEOUT' | 'REVERSED'Input
PaymentData
ts
interface PaymentData {
orderRef: string
total: number | string
customerEmail: string
currency?: Currency // default: 'HUF'
language?: Language // default: 'HU'
method?: PaymentMethod // default: 'CARD'
invoice?: InvoiceAddress
items?: PaymentItem[] // when sent, SimplePay ignores total
shippingCost?: number
discount?: number
delivery?: DeliveryAddress
customer?: string // if it differs from invoice.name
extra?: Record<string, unknown>
maySelectEmail?: boolean
maySelectInvoice?: boolean
maySelectDelivery?: string[] // country codes, ['HU', 'AT']
timeout?: Date | string // default: now + 30 minutes
threeDSReqAuthMethod?: ThreeDSReqAuthMethod
}
type ThreeDSReqAuthMethod = '01' | '02' | '05' // guest, registered, registered with a third-party identifier
interface PaymentItem {
ref?: string
title?: string
desc?: string
amount: number // quantity
price: number // unit price
tax?: number // VAT %, e.g. 27
}
interface DeliveryAddress {
name?: string
company?: string
country: string
state: string
city: string
zip: string
address: string
address2?: string
phone?: string
}
interface InvoiceAddress extends DeliveryAddress {
fiscalCode?: string // tax number
}PaymentConfig
ts
interface PaymentConfig {
redirectUrl?: string
}StartPaymentConfig
The second argument of startPayment and startRecurringPayment. When urls is given, it is sent instead of url.
ts
interface StartPaymentConfig extends PaymentConfig {
urls?: SimplePayUrls
}
interface SimplePayUrls {
success: string
fail: string
cancel: string
timeout: string
}RecurringPaymentData
ts
interface RecurringPaymentData extends PaymentData {
customer: string
recurring: {
times: number
until: string // ISO 8601, see toISO8601DateString
maxAmount: number
}
}TokenPaymentData
ts
interface TokenPaymentData extends Omit<PaymentData, 'method' | 'items' | 'shippingCost' | 'discount' | 'delivery' | 'extra' | 'maySelectEmail' | 'maySelectInvoice' | 'maySelectDelivery' | 'timeout'> {
method: 'CARD'
customer: string
token: string
}GooglePayPaymentData
ts
interface GooglePayPaymentData {
orderRef: string
total: number | string
customerEmail: string
googlePayToken: string // Base64, unchanged from the browser
currency?: Currency // not HUF_SZEP
language?: Language
invoice?: PaymentData['invoice']
}ApplePayStartData
ts
interface ApplePayStartData {
orderRef: string
total: number | string
customerEmail: string
domain: string // the registered FQDN
currency?: Currency // not HUF_SZEP
language?: Language
invoice?: PaymentData['invoice']
}ApplePayChargeData
ts
interface ApplePayChargeData {
transactionId: string | number
applePayToken: string // Base64
currency?: Currency
}TransactionStatusQuery
The getTransactionStatus parameter. Exactly one identifier is required.
ts
type TransactionId = string | number
type TransactionStatusQuery = { currency?: Currency } & (
| { transactionId: TransactionId }
| { orderRef: string }
)TransactionQuery
The queryTransactions parameter. At least one identifier is required.
ts
interface TransactionQuery {
transactionIds?: TransactionId[]
orderRefs?: string[]
detailed?: boolean
refunds?: boolean
currency?: Currency
}RefundData
The refund parameter. Exactly one identifier is required.
ts
type RefundData = {
refundTotal: number | string
currency?: Currency
} & (
| { transactionId: TransactionId }
| { orderRef: string }
)Responses
SimplePayResponse
Returned by startPayment.
ts
interface SimplePayResponse {
salt: string
merchant: string
orderRef: string
currency: Currency
transactionId: string
timeout: string
total: string
paymentUrl: string
errorCodes?: string[]
}SimplePayRecurringResponse
ts
interface SimplePayRecurringResponse extends SimplePayResponse {
tokens: string[]
}SimplePayTokenResponse
ts
type SimplePayTokenResponse = Omit<SimplePayResponse, 'paymentUrl' | 'timeout'>SimplePayCancelCardResponse
ts
interface SimplePayCancelCardResponse {
salt: string
merchant: string
cardId: string
status: 'DISABLED'
expiry: string
}SimplePayResult
Returned by getPaymentResponse.
ts
interface SimplePayResult {
responseCode: number
transactionId: string
event: 'SUCCESS' | 'FAIL' | 'TIMEOUT' | 'CANCEL'
merchantId: string
orderRef: string
tokens?: string[]
}SimplePayIPNResponse
The shape of an IPN body (handleIpnRequest adds receiveDate).
ts
interface SimplePayIPNResponse {
salt: string
orderRef: string
method: string
merchant: string
finishDate: string
paymentDate: string
transactionId: number
status: 'FINISHED' | 'AUTHORIZED' | 'NOTAUTHORIZED' | 'REVERSED' | 'CANCELLED' | 'TIMEOUT'
receiveDate: string
expiry?: string // card registration only
cardMask?: string // card registration only
}SimplePayTransactionStatusResponse
What getTransactionStatus returns.
ts
interface SimplePayTransactionStatusResponse {
salt: string
merchant: string
orderRef: string
transactionId: number
status: TransactionStatus
endState: boolean // true: FINISHED, CANCELLED, NOTAUTHORIZED, TIMEOUT, REVERSED
}SimplePayQueryResponse
What queryTransactions returns. The type of each transactions item follows the detailed and refunds flags.
ts
interface SimplePayQueryResponse<Q extends TransactionQuery> {
salt: string
merchant: string
transactions: QueriedTransactionOf<Q>[]
totalCount: number
}
interface QueriedTransaction {
salt: string
merchant: string
orderRef: string
transactionId: number
status: TransactionStatus
resultCode?: string
total: number
remainingTotal: number
method: string
paymentDate: string
finishDate?: string
}
// detailed: true
interface QueriedTransactionDetails {
currency: Currency
customer?: string
customerEmail: string
language: Language
twoStep?: boolean
shippingCost?: number
discount?: number
invoice?: QueriedAddress
delivery?: QueriedAddress
}
// refunds: true
interface QueriedTransactionRefunds {
refundStatus: string
refunds: TransactionRefund[]
}
interface TransactionRefund {
transactionId: number
refundTotal: number
refundDate: string
status: TransactionStatus
}SimplePayRefundResponse
What refund returns.
ts
interface SimplePayRefundResponse {
salt: string
merchant: string
orderRef: string
currency: Currency
transactionId: number // the original transaction
refundTransactionId: number // the refund transaction
refundTotal: number
remainingTotal: number // still refundable
}SimplePayGooglePayResponse
ts
interface SimplePayGooglePayResponse {
salt?: string
merchant: string
orderRef: string
currency: Currency
transactionId: string | number
total: string | number
timeout?: string
paymentUrl?: string
redirectUrl?: string // on 3DS
errorCodes?: Array<string | number> // on 3DS ['3004']
}SimplePayApplePayStartResponse
ts
interface SimplePayApplePayStartResponse {
salt?: string
merchant: string
orderRef?: string
currency?: Currency
transactionId: string | number
total?: string | number
timeout?: string
applePaySession?: ApplePayMerchantSession // merchantSessionIdentifier, nonce, signature …
errorCodes?: Array<string | number>
}SimplePayApplePayChargeResponse
ts
interface SimplePayApplePayChargeResponse {
salt?: string
merchant: string
orderRef?: string
currency?: Currency
transactionId: string | number
total?: string | number
applePayStatus?: string // 'STATUS_SUCCESS'
errorCodes?: Array<string | number>
}Browser config
GooglePayButtonConfig
simplepay-js-sdk/google-pay
| Field | Type | Required | Description |
|---|---|---|---|
container | HTMLElement | string | yes | Where the button goes |
merchantId | string | yes | Google merchant ID |
merchantName | string | yes | Display name |
environment | 'TEST' | 'PRODUCTION' | yes | Google Pay environment |
gatewayMerchantId | string | yes | SimplePay merchant ID |
authorizationEndpoint | string | yes | Your server endpoint |
currency | string | yes | Currency |
total | string | yes | Displayed amount |
orderRef | string | yes | Order reference |
countryCode | string | no | Default: HU |
allowedCardNetworks | ('VISA' | 'MASTERCARD' | 'AMEX')[] | no | Default: all |
onResult | (response: unknown) => void | no | Your server's response |
onError | (error: unknown) => void | no | Error |
ApplePayButtonConfig
simplepay-js-sdk/apple-pay
| Field | Type | Required | Description |
|---|---|---|---|
container | HTMLElement | string | yes | Where the button goes |
merchantIdentifier | string | yes | Apple Pay merchant identifier |
merchantName | string | yes | Display name |
validationEndpoint | string | yes | Endpoint that calls startApplePay |
authorizationEndpoint | string | yes | Endpoint that calls doApplePay |
currency | string | yes | 3-letter currency code |
total | string | yes | Positive amount, at most 2 decimals |
orderRef | string | yes | Order reference |
countryCode | string | no | Default: HU |
locale | string | no | Default: hu-HU |
buttonStyle | 'black' | 'white' | 'white-outline' | no | Default: black |
buttonType | 'plain' | 'buy' | 'pay' | 'check-out' | 'book' | 'donate' | 'subscribe' | no | Default: plain |
supportedNetworks | ('visa' | 'masterCard' | 'amex' | 'discover')[] | no | Default: all |
onResult | (response: unknown) => void | no | Successful charge |
onError | (error: unknown) => void | no | Error |
