Socket
Socket
Sign inDemoInstall

@oneblink/sdk-core

Package Overview
Dependencies
Maintainers
0
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oneblink/sdk-core - npm Package Compare versions

Comparing version 7.3.0-beta.1 to 7.3.0-beta.2

29

dist/paymentService.d.ts

@@ -34,22 +34,23 @@ import { FormTypes, SubmissionEventTypes, SubmissionTypes } from '@oneblink/types';

* const detailItems =
* paymentService.getDisplayDetailsFromFormSubmissionPayment({
* paymentService.getDisplayDetailsFromFormSubmissionPayment(
* formSubmissionPayment,
* formatCurrency,
* })
* {
* formatCurrency,
* formatDateTime,
* formatDate,
* },
* )
* ```
*
* @param formSubmissionPayment
* @param options
* @returns
*/
export declare const getDisplayDetailsFromFormSubmissionPayment: ({ formSubmissionPayment, formatCurrency, formatDateTime, }: {
/** The form submission payment to get the details from */
formSubmissionPayment: SubmissionTypes.FormSubmissionPayment;
/** A function to format any curreny values */
formatCurrency: ReplaceInjectablesFormatters['formatCurrency'];
/**
* A function to format any dates. If this is not passed, datetimes will be
* returned as iso strings.
*/
formatDateTime: ReplaceInjectablesFormatters['formatDateTime'];
}) => PaymentDisplayDetail[];
export declare const getDisplayDetailsFromFormSubmissionPayment: (formSubmissionPayment: SubmissionTypes.FormSubmissionPayment, { formatCurrency, formatDateTime, formatDate, }: Pick<ReplaceInjectablesFormatters, 'formatCurrency' | 'formatDate' | 'formatDateTime'>) => {
amount: {
value: number;
formatted: string;
};
paymentDisplayDetails: PaymentDisplayDetail[];
} | undefined;
export {};

@@ -65,12 +65,19 @@ "use strict";

* const detailItems =
* paymentService.getDisplayDetailsFromFormSubmissionPayment({
* paymentService.getDisplayDetailsFromFormSubmissionPayment(
* formSubmissionPayment,
* formatCurrency,
* })
* {
* formatCurrency,
* formatDateTime,
* formatDate,
* },
* )
* ```
*
* @param formSubmissionPayment
* @param options
* @returns
*/
const getDisplayDetailsFromFormSubmissionPayment = ({ formSubmissionPayment, formatCurrency, formatDateTime, }) => {
const getDisplayDetailsFromFormSubmissionPayment = (
/** The form submission payment to get the details from */
formSubmissionPayment, { formatCurrency, formatDateTime, formatDate, }) => {
var _a, _b;

@@ -81,66 +88,75 @@ switch (formSubmissionPayment.type) {

if (!paymentTransaction || !paymentTransaction.agencyCompletionPayment) {
return [];
return;
}
return [
{
key: 'completionReference',
label: 'Completion Reference',
value: paymentTransaction.agencyCompletionPayment
.paymentCompletionReference,
},
{
key: 'paymentReference',
label: 'Payment Reference',
value: paymentTransaction.agencyCompletionPayment.paymentReference,
},
{
key: 'bankReference',
label: 'Bank Reference',
value: paymentTransaction.agencyCompletionPayment.bankReference,
},
{
key: 'paymentMethod',
label: 'Payment Method',
value: paymentTransaction.agencyCompletionPayment.paymentMethod,
},
...(paymentTransaction.agencyCompletionPayment.paymentMethod ===
'BPAY' && ((_a = paymentTransaction.agencyCompletionPayment.bPay) === null || _a === void 0 ? void 0 : _a.billerCode)
? [
{
key: 'billerCode',
label: 'BPay Biller Code',
value: paymentTransaction.agencyCompletionPayment.bPay.billerCode,
},
]
: []),
...(paymentTransaction.agencyCompletionPayment.paymentMethod === 'CARD'
? [
{
key: 'creditCardMask',
label: 'Card Number',
value: `xxxx xxxx xxxx ${(_b = paymentTransaction.agencyCompletionPayment.card) === null || _b === void 0 ? void 0 : _b.last4Digits}`,
},
]
: []),
{
key: 'amount',
label: 'Amount',
value: formatCurrency(paymentTransaction.agencyCompletionPayment.amount),
},
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(paymentTransaction.agencyCompletionPayment.surcharge),
},
{
key: 'surchargeGST',
label: 'Surcharge GST',
value: formatCurrency(paymentTransaction.agencyCompletionPayment.surchargeGst),
},
{
key: 'createdDateTime',
label: 'Created Date Time',
value: formatDateTime(formSubmissionPayment.createdAt),
},
];
const amount = {
value: paymentTransaction.agencyCompletionPayment.amount,
formatted: formatCurrency(paymentTransaction.agencyCompletionPayment.amount),
};
return {
amount,
paymentDisplayDetails: [
{
key: 'completionReference',
label: 'Completion Reference',
value: paymentTransaction.agencyCompletionPayment
.paymentCompletionReference,
},
{
key: 'paymentReference',
label: 'Payment Reference',
value: paymentTransaction.agencyCompletionPayment.paymentReference,
},
{
key: 'bankReference',
label: 'Bank Reference',
value: paymentTransaction.agencyCompletionPayment.bankReference,
},
{
key: 'paymentMethod',
label: 'Payment Method',
value: paymentTransaction.agencyCompletionPayment.paymentMethod,
},
...(paymentTransaction.agencyCompletionPayment.paymentMethod ===
'BPAY' &&
((_a = paymentTransaction.agencyCompletionPayment.bPay) === null || _a === void 0 ? void 0 : _a.billerCode)
? [
{
key: 'billerCode',
label: 'BPay Biller Code',
value: paymentTransaction.agencyCompletionPayment.bPay.billerCode,
},
]
: []),
...(paymentTransaction.agencyCompletionPayment.paymentMethod ===
'CARD'
? [
{
key: 'creditCardMask',
label: 'Card Number',
value: `xxxx xxxx xxxx ${(_b = paymentTransaction.agencyCompletionPayment.card) === null || _b === void 0 ? void 0 : _b.last4Digits}`,
},
]
: []),
{
key: 'amount',
label: 'Amount',
value: amount.formatted,
},
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(paymentTransaction.agencyCompletionPayment.surcharge),
},
{
key: 'surchargeGST',
label: 'Surcharge GST',
value: formatCurrency(paymentTransaction.agencyCompletionPayment.surchargeGst),
},
{
key: 'createdDateTime',
label: 'Created Date Time',
value: formatDateTime(formSubmissionPayment.createdAt),
},
],
};
}

@@ -150,51 +166,59 @@ case 'BPOINT': {

if (!paymentTransaction) {
return [];
return;
}
return [
{
key: 'receiptNumber',
label: 'Receipt Number',
value: paymentTransaction.ReceiptNumber,
},
{
key: 'crn1',
label: 'CRN 1',
value: paymentTransaction.Crn1,
},
{
key: 'crn2',
label: 'CRN 2',
value: paymentTransaction.Crn2,
},
{
key: 'crn3',
label: 'CRN 3',
value: paymentTransaction.Crn3,
},
{
key: 'billerCode',
label: 'Biller Code',
value: paymentTransaction.BillerCode,
},
{
key: 'creditCardMask',
label: 'Card Number',
value: paymentTransaction.CardDetails.MaskedCardNumber,
},
{
key: 'amount',
label: 'Amount',
value: formatCurrency(paymentTransaction.Amount / 100),
},
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(paymentTransaction.AmountSurcharge / 100),
},
{
key: 'processedDateTime',
label: 'Processed Date Time',
value: formatDateTime(paymentTransaction.ProcessedDateTime),
},
];
const amountValue = paymentTransaction.Amount / 100;
const amount = {
value: amountValue,
formatted: formatCurrency(amountValue),
};
return {
amount,
paymentDisplayDetails: [
{
key: 'receiptNumber',
label: 'Receipt Number',
value: paymentTransaction.ReceiptNumber,
},
{
key: 'crn1',
label: 'CRN 1',
value: paymentTransaction.Crn1,
},
{
key: 'crn2',
label: 'CRN 2',
value: paymentTransaction.Crn2,
},
{
key: 'crn3',
label: 'CRN 3',
value: paymentTransaction.Crn3,
},
{
key: 'billerCode',
label: 'Biller Code',
value: paymentTransaction.BillerCode,
},
{
key: 'creditCardMask',
label: 'Card Number',
value: paymentTransaction.CardDetails.MaskedCardNumber,
},
{
key: 'amount',
label: 'Amount',
value: amount.formatted,
},
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(paymentTransaction.AmountSurcharge / 100),
},
{
key: 'processedDateTime',
label: 'Processed Date Time',
value: formatDateTime(paymentTransaction.ProcessedDateTime),
},
],
};
}

@@ -204,3 +228,3 @@ case 'CP_PAY': {

if (!paymentTransaction) {
return [];
return;
}

@@ -219,4 +243,10 @@ const determineDetails = () => {

amount: paymentTransaction.result.amount !== undefined
? formatCurrency(paymentTransaction.result.amount)
: 'Unknown',
? {
value: paymentTransaction.result.amount,
formatted: formatCurrency(paymentTransaction.result.amount),
}
: {
value: NaN,
formatted: 'Unknown',
},
createdDateTime: paymentTransaction.result.createdOnUtc,

@@ -237,3 +267,6 @@ };

: undefined,
amount: formatCurrency(paymentTransaction.amount),
amount: {
value: paymentTransaction.amount,
formatted: formatCurrency(paymentTransaction.amount),
},
createdDateTime: paymentTransaction.createdAt,

@@ -245,5 +278,5 @@ };

const { transactionId, orderNumber, paymentType, creditCardMask, amount, createdDateTime, } = determineDetails();
const result = [];
const paymentDisplayDetails = [];
if (transactionId) {
result.push({
paymentDisplayDetails.push({
key: 'transactionId',

@@ -255,3 +288,3 @@ label: 'Transaction Id',

if (orderNumber) {
result.push({
paymentDisplayDetails.push({
key: 'orderNumber',

@@ -263,3 +296,3 @@ label: 'Order Number',

if (paymentType) {
result.push({
paymentDisplayDetails.push({
key: 'paymentType',

@@ -271,3 +304,3 @@ label: 'Payment Type',

if (creditCardMask) {
result.push({
paymentDisplayDetails.push({
key: 'creditCardMask',

@@ -278,11 +311,9 @@ label: 'Card Number',

}
if (amount) {
result.push({
key: 'amount',
label: 'Amount',
value: amount,
});
}
paymentDisplayDetails.push({
key: 'amount',
label: 'Amount',
value: amount.formatted,
});
if (createdDateTime) {
result.push({
paymentDisplayDetails.push({
key: 'createdDateTime',

@@ -293,3 +324,6 @@ label: 'Created At',

}
return result;
return {
amount,
paymentDisplayDetails,
};
}

@@ -299,44 +333,47 @@ case 'WESTPAC_QUICK_STREAM': {

if (!paymentTransaction) {
return [];
return;
}
return [
{
key: 'receiptNumber',
label: 'Receipt Number',
value: paymentTransaction.receiptNumber,
},
{
key: 'paymentReferenceNumber',
label: 'Payment Reference',
value: paymentTransaction.paymentReferenceNumber,
},
{
key: 'customerReferenceNumber',
label: 'Customer Reference Number',
value: paymentTransaction.customerReferenceNumber,
},
...(paymentTransaction.totalAmount
? [
{
key: 'amount',
label: 'Amount',
value: formatCurrency(parseFloat(paymentTransaction.totalAmount.amount.toString())),
},
]
: []),
...(paymentTransaction.surchargeAmount.amount
? [
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(parseFloat(paymentTransaction.surchargeAmount.amount.toString())),
},
]
: []),
{
key: 'settlementDate',
label: 'Settlement Date',
value: formatDateTime(paymentTransaction.settlementDate),
},
];
const amount = {
value: paymentTransaction.totalAmount.amount,
formatted: formatCurrency(parseFloat(paymentTransaction.totalAmount.amount.toString())),
};
return {
amount,
paymentDisplayDetails: [
{
key: 'receiptNumber',
label: 'Receipt Number',
value: paymentTransaction.receiptNumber,
},
{
key: 'paymentReferenceNumber',
label: 'Payment Reference',
value: paymentTransaction.paymentReferenceNumber,
},
{
key: 'customerReferenceNumber',
label: 'Customer Reference Number',
value: paymentTransaction.customerReferenceNumber,
},
{
key: 'amount',
label: 'Amount',
value: amount.formatted,
},
...(paymentTransaction.surchargeAmount.amount
? [
{
key: 'surchargeAmount',
label: 'Surcharge Amount',
value: formatCurrency(parseFloat(paymentTransaction.surchargeAmount.amount.toString())),
},
]
: []),
{
key: 'settlementDate',
label: 'Settlement Date',
value: formatDate(paymentTransaction.settlementDate),
},
],
};
}

@@ -343,0 +380,0 @@ }

import { FormTypes, MiscTypes, ScheduledTasksTypes, SubmissionTypes } from '@oneblink/types';
export type ReplaceInjectablesFormatters = {
/** A function to format any date/times. */
formatDateTime: (value: string) => string;
/** A function to format any dates. */
formatDate: (value: string) => string;
/** A function to format any times. */
formatTime: (value: string) => string;
/** A function to format any numbers. */
formatNumber: (value: number) => string;
/** A function to format any numbers as currency. */
formatCurrency: (value: number) => string;

@@ -8,0 +13,0 @@ };

{
"name": "@oneblink/sdk-core",
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)",
"version": "7.3.0-beta.1",
"version": "7.3.0-beta.2",
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",

@@ -6,0 +6,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc