mirror of
https://github.com/jlengrand/adyen-web.git
synced 2026-03-10 08:01:22 +00:00
chore: format all files with eslint and prettier (#2152)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"scripts": {
|
||||
"start": "concurrently --kill-others-on-fail \"yarn workspace @adyen/adyen-web start\" \"yarn workspace @adyen/adyen-web-playground start\" --names \"lib,playground\"",
|
||||
"build": "yarn workspace @adyen/adyen-web build",
|
||||
"format": "yarn workspace @adyen/adyen-web format",
|
||||
"lint": "yarn workspace @adyen/adyen-web lint",
|
||||
"test": "yarn workspace @adyen/adyen-web test",
|
||||
"test:watch": "yarn workspace @adyen/adyen-web test:watch",
|
||||
|
||||
@@ -44,9 +44,12 @@
|
||||
"size-only": "node ./scripts/size",
|
||||
"type-check": "tsc --noEmit",
|
||||
"type-check-generate": "tsc --emitDeclarationOnly",
|
||||
"format": "npm run lint:fix && npm run prettier:fix && npm run styles:fix",
|
||||
"lint": "eslint 'src/**/*.{js,ts,tsx}' --quiet",
|
||||
"lint-styles": "stylelint '**/*.scss'",
|
||||
"styles:fix": "npm run lint-styles -- --fix",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"prettier:fix": "prettier \"src/**/*.{js,ts,tsx}\" \"package.json\" --write --loglevel silent",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prepare": "cd ../.. && husky install packages/lib/.husky"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ import { h } from 'preact';
|
||||
import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer';
|
||||
import ConsentCheckboxLabel from './components/ConsentCheckboxLabel';
|
||||
import { AFTERPAY_B2B_CONSENT_URL, ALLOWED_COUNTRIES } from './config';
|
||||
import {OpenInvoiceContainerProps} from "../helpers/OpenInvoiceContainer/OpenInvoiceContainer";
|
||||
import { OpenInvoiceContainerProps } from '../helpers/OpenInvoiceContainer/OpenInvoiceContainer';
|
||||
|
||||
export default class AfterPayB2B extends OpenInvoiceContainer {
|
||||
public static type = 'afterpay_b2b';
|
||||
|
||||
@@ -7,15 +7,7 @@ import {
|
||||
SUPPORTED_LOCALES_EU,
|
||||
SUPPORTED_LOCALES_US
|
||||
} from './config';
|
||||
import {
|
||||
AmazonPayButtonProps,
|
||||
AmazonPayButtonSettings,
|
||||
ChargeAmount,
|
||||
Currency,
|
||||
PayloadJSON,
|
||||
Region,
|
||||
SupportedLocale
|
||||
} from './types';
|
||||
import { AmazonPayButtonProps, AmazonPayButtonSettings, ChargeAmount, Currency, PayloadJSON, Region, SupportedLocale } from './types';
|
||||
import { PaymentAmount } from '../../types';
|
||||
import { getDecimalAmount } from '../../utils/amount-util';
|
||||
|
||||
@@ -62,7 +54,7 @@ export function getFallbackLocale(region: Region): SupportedLocale {
|
||||
*/
|
||||
export function getSupportedLocales(region: Region): SupportedLocale[] {
|
||||
const supportedLocales = region === 'US' ? SUPPORTED_LOCALES_US : SUPPORTED_LOCALES_EU;
|
||||
return (supportedLocales as unknown) as SupportedLocale[];
|
||||
return supportedLocales as unknown as SupportedLocale[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,16 +100,8 @@ export function getChargeAmount(amount: PaymentAmount): ChargeAmount {
|
||||
* @returns PayloadJSON
|
||||
*/
|
||||
export function getPayloadJSON(props): PayloadJSON {
|
||||
const {
|
||||
addressDetails,
|
||||
cancelUrl,
|
||||
checkoutMode,
|
||||
deliverySpecifications,
|
||||
returnUrl,
|
||||
merchantMetadata,
|
||||
chargePermissionType,
|
||||
recurringMetadata,
|
||||
} = props;
|
||||
const { addressDetails, cancelUrl, checkoutMode, deliverySpecifications, returnUrl, merchantMetadata, chargePermissionType, recurringMetadata } =
|
||||
props;
|
||||
|
||||
const { storeId } = props.configuration;
|
||||
const isPayNow = checkoutMode === 'ProcessOrder';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CardElement } from './Card';
|
||||
|
||||
describe('Card', () => {
|
||||
describe('formatProps', function() {
|
||||
describe('formatProps', function () {
|
||||
test('should not require a billingAddress if it is a stored card', () => {
|
||||
const card = new CardElement({ billingAddressRequired: true, storedPaymentMethodId: 'test' });
|
||||
expect(card.props.billingAddressRequired).toBe(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { h } from 'preact';
|
||||
import { GiftcardNumberField } from './GiftcardNumberField';
|
||||
import { GiftcardPinField } from './GiftcardPinField';
|
||||
import {GiftcardFieldsProps} from "./types";
|
||||
import { GiftcardFieldsProps } from './types';
|
||||
|
||||
export const GiftCardFields = (props: GiftcardFieldsProps) => {
|
||||
const { setRootNode, pinRequired } = props;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Language from '../../../language/Language';
|
||||
import {SFPState} from '../../internal/SecuredFields/SFP/types';
|
||||
import { SFPState } from '../../internal/SecuredFields/SFP/types';
|
||||
|
||||
export type GiftcardFieldsProps = {
|
||||
setRootNode: (input: HTMLElement) => void;
|
||||
|
||||
@@ -29,7 +29,7 @@ export function KlarnaWidget({ sdkData, paymentMethodType, payButton, ...props }
|
||||
container: klarnaWidgetRef.current,
|
||||
payment_method_category: sdkData.payment_method_category
|
||||
},
|
||||
function(res) {
|
||||
function (res) {
|
||||
// If show_form: true is received together with an error, something fixable is wrong and the consumer
|
||||
// needs to take action before moving forward
|
||||
// If show_form: false, the payment method in the loaded widget will not be offered for this order
|
||||
@@ -48,7 +48,7 @@ export function KlarnaWidget({ sdkData, paymentMethodType, payButton, ...props }
|
||||
{
|
||||
payment_method_category: sdkData.payment_method_category
|
||||
},
|
||||
function(res: KlarnaWidgetAuthorizeResponse) {
|
||||
function (res: KlarnaWidgetAuthorizeResponse) {
|
||||
if (res.approved === true && res.show_form === true) {
|
||||
// Klarna has approved the authorization of credit for this order.
|
||||
setStatus('success');
|
||||
@@ -78,7 +78,7 @@ export function KlarnaWidget({ sdkData, paymentMethodType, payButton, ...props }
|
||||
|
||||
// Add Klarna Payments Widget SDK
|
||||
useEffect(() => {
|
||||
window.klarnaAsyncCallback = function() {
|
||||
window.klarnaAsyncCallback = function () {
|
||||
initializeKlarnaWidget();
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export class MealVoucherFRElement extends GiftcardElement {
|
||||
encryptedCardNumber: this.state.data?.encryptedCardNumber,
|
||||
encryptedSecurityCode: this.state.data?.encryptedSecurityCode,
|
||||
encryptedExpiryMonth: this.state.data?.encryptedExpiryMonth,
|
||||
encryptedExpiryYear: this.state.data?.encryptedExpiryYear,
|
||||
encryptedExpiryYear: this.state.data?.encryptedExpiryYear
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { h } from 'preact';
|
||||
import {MealVoucherExpiryField} from "./MealVoucherExpiryField";
|
||||
import {GiftcardFieldsProps} from "../../Giftcard/components/types";
|
||||
import {GiftcardPinField} from "../../Giftcard/components/GiftcardPinField";
|
||||
import {GiftcardNumberField} from "../../Giftcard/components/GiftcardNumberField";
|
||||
import { MealVoucherExpiryField } from './MealVoucherExpiryField';
|
||||
import { GiftcardFieldsProps } from '../../Giftcard/components/types';
|
||||
import { GiftcardPinField } from '../../Giftcard/components/GiftcardPinField';
|
||||
import { GiftcardNumberField } from '../../Giftcard/components/GiftcardNumberField';
|
||||
|
||||
export const MealVoucherFields = (props: GiftcardFieldsProps) => {
|
||||
const { setRootNode } = props;
|
||||
|
||||
@@ -12,8 +12,8 @@ class OnlineBankingINElement extends IssuerListContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the component data output
|
||||
*/
|
||||
* Formats the component data output
|
||||
*/
|
||||
formatData() {
|
||||
return {
|
||||
...super.formatData(),
|
||||
|
||||
@@ -22,4 +22,3 @@ describe('PayNow', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ describe('Sepa', () => {
|
||||
const mockStateChange = sepa => {
|
||||
sepa.setState({
|
||||
data: {
|
||||
'ownerName': 'A. Klaassen',
|
||||
'ibanNumber': 'NL13TEST0123456789'
|
||||
ownerName: 'A. Klaassen',
|
||||
ibanNumber: 'NL13TEST0123456789'
|
||||
},
|
||||
isValid: true
|
||||
});
|
||||
@@ -15,8 +15,8 @@ describe('Sepa', () => {
|
||||
const mockInvalidStateChange = sepa => {
|
||||
sepa.setState({
|
||||
data: {
|
||||
'ownerName': 'A. Klaassen',
|
||||
'ibanNumber': 'NOTANIBAN'
|
||||
ownerName: 'A. Klaassen',
|
||||
ibanNumber: 'NOTANIBAN'
|
||||
},
|
||||
isValid: false
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import RedirectElement from "../Redirect";
|
||||
import PayButton, {payAmountLabel} from "../internal/PayButton";
|
||||
import {h} from "preact";
|
||||
import RedirectElement from '../Redirect';
|
||||
import PayButton, { payAmountLabel } from '../internal/PayButton';
|
||||
import { h } from 'preact';
|
||||
|
||||
/**
|
||||
* TwintElement
|
||||
@@ -18,15 +18,12 @@ class TwintElement extends RedirectElement {
|
||||
*/
|
||||
get displayName(): string {
|
||||
const { i18n, name, storedPaymentMethodId } = this.props;
|
||||
return storedPaymentMethodId ? `${name} ${i18n.get('twint.saved')}`
|
||||
: name || this.constructor['type'];
|
||||
return storedPaymentMethodId ? `${name} ${i18n.get('twint.saved')}` : name || this.constructor['type'];
|
||||
}
|
||||
|
||||
|
||||
public payButtonLabel() {
|
||||
const {i18n, amount, storedPaymentMethodId, name} = this.props;
|
||||
if (storedPaymentMethodId)
|
||||
return payAmountLabel(i18n, amount);
|
||||
const { i18n, amount, storedPaymentMethodId, name } = this.props;
|
||||
if (storedPaymentMethodId) return payAmountLabel(i18n, amount);
|
||||
return `${i18n.get('continueTo')} ${name}`;
|
||||
}
|
||||
|
||||
@@ -35,12 +32,7 @@ class TwintElement extends RedirectElement {
|
||||
* @param props - props
|
||||
*/
|
||||
public payButton = props => {
|
||||
return (
|
||||
<PayButton
|
||||
{...props }
|
||||
label={this.payButtonLabel()}
|
||||
onClick={this.submit} />
|
||||
);
|
||||
return <PayButton {...props} label={this.payButtonLabel()} onClick={this.submit} />;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class WalletINElement extends IssuerListContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the component data output
|
||||
*/
|
||||
* Formats the component data output
|
||||
*/
|
||||
formatData() {
|
||||
return {
|
||||
...super.formatData(),
|
||||
|
||||
@@ -56,8 +56,8 @@ import WalletINElement from './WalletIN';
|
||||
import OnlineBankingCZElement from './OnlineBankingCZ';
|
||||
import OnlineBankingSKElement from './OnlineBankingSK';
|
||||
import PayByBank from './PayByBank';
|
||||
import PromptPay from "./PromptPay";
|
||||
import Duitnow from "./DuitNow";
|
||||
import PromptPay from './PromptPay';
|
||||
import Duitnow from './DuitNow';
|
||||
|
||||
/**
|
||||
* Maps each component with a Component element.
|
||||
|
||||
@@ -9,7 +9,7 @@ interface AlertProps {
|
||||
children: ComponentChildren;
|
||||
classNames?: string[];
|
||||
icon?: string;
|
||||
type?: typeof ALERT_TYPES[number];
|
||||
type?: (typeof ALERT_TYPES)[number];
|
||||
}
|
||||
|
||||
export default function Alert({ children, classNames = [], type = 'error', icon }: AlertProps) {
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function ConsentCheckbox({ errorMessage, label, onChange, i18n, .
|
||||
<Field classNameModifiers={['consentCheckbox']} errorMessage={errorMessage} i18n={i18n}>
|
||||
<Checkbox
|
||||
name="consentCheckbox"
|
||||
classNameModifiers={[...props.classNameModifiers??=[], 'consentCheckbox']}
|
||||
classNameModifiers={[...(props.classNameModifiers ??= []), 'consentCheckbox']}
|
||||
onInput={onChange}
|
||||
value={props?.data?.consentCheckbox}
|
||||
label={label}
|
||||
|
||||
@@ -5,6 +5,5 @@ export default function InputText(props) {
|
||||
/* Type of input base is always text, which is combined with using inputmode to change mobile keyboards.
|
||||
* This gives the most consistent and performant mobile input experience.
|
||||
*/
|
||||
return <InputBase classNameModifiers={['large']} {...props} aria-required={props.required} type='text' />;
|
||||
return <InputBase classNameModifiers={['large']} {...props} aria-required={props.required} type="text" />;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,7 @@ describe('IssuerList', () => {
|
||||
expect(onChangeCb.mock.calls[0][0]).toStrictEqual(callbackData);
|
||||
expect(onChangeCb.mock.calls[1][0]).toStrictEqual(callbackData);
|
||||
|
||||
wrapper
|
||||
.find('.adyen-checkout__issuer-button-group button')
|
||||
.at(1)
|
||||
.simulate('click');
|
||||
wrapper.find('.adyen-checkout__issuer-button-group button').at(1).simulate('click');
|
||||
|
||||
callbackData = { data: { issuer: '3' }, valid: { issuer: true }, errors: { issuer: null }, isValid: true };
|
||||
|
||||
|
||||
@@ -46,11 +46,11 @@ abstract class AbstractCSF {
|
||||
// --
|
||||
protected constructor(setupObj: CSFSetupObject) {
|
||||
this.props = setupObj;
|
||||
this.state = ({} as any) as CSFStateObject;
|
||||
this.state = {} as any as CSFStateObject;
|
||||
|
||||
// Initialise storage objects
|
||||
this.config = ({} as any) as CSFConfigObject; // {} as ConfigObject fails in linting
|
||||
this.callbacks = ({} as any) as CSFCallbacksConfig;
|
||||
this.config = {} as any as CSFConfigObject; // {} as ConfigObject fails in linting
|
||||
this.callbacks = {} as any as CSFCallbacksConfig;
|
||||
}
|
||||
}
|
||||
export default AbstractCSF;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CSFCallbacksConfig } from '../types';
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
export function configureCallbacks(callbacksObj: CSFCallbacksConfig = ({} as any) as CSFCallbacksConfig): void {
|
||||
export function configureCallbacks(callbacksObj: CSFCallbacksConfig = {} as any as CSFCallbacksConfig): void {
|
||||
// --
|
||||
this.callbacks.onLoad = callbacksObj.onLoad ? callbacksObj.onLoad : noop;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export function handleEncryption(pFeedbackObj: SFFeedbackObj): void {
|
||||
|
||||
// REMOVE ANY ERRORS ON FIELD e.g. was a full number that failed the luhnCheck, then we corrected the number and now it passes
|
||||
processErrors(
|
||||
({ error: '', fieldType } as any) as SFFeedbackObj,
|
||||
{ error: '', fieldType } as any as SFFeedbackObj,
|
||||
this.state.securedFields[fieldType],
|
||||
this.state.type,
|
||||
this.props.rootNode,
|
||||
|
||||
@@ -93,7 +93,8 @@ CardType.cards.push({
|
||||
startingRules: [506699, 50670, 50671, 50672, 50673, 50674, 50675, 50676, 506770, 506771, 506772, 506773, 506774, 506775, 506776, 506777, 506778, 401178, 438935, 451416, 457631, 457632, 504175, 627780, 636297, 636368], // eslint-disable-line max-len
|
||||
permittedLengths: [16],
|
||||
// prettier-ignore
|
||||
pattern: /^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/ // eslint-disable-line max-len
|
||||
pattern:
|
||||
/^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/ // eslint-disable-line max-len
|
||||
});
|
||||
|
||||
CardType.cards.push({ cardType: 'uatp', startingRules: [1], permittedLengths: [15], pattern: /^1[0-9]{0,14}$/, cvcPolicy: 'optional' });
|
||||
@@ -179,7 +180,8 @@ CardType.cards.push({
|
||||
startingRules: [508528],
|
||||
permittedLengths: [16],
|
||||
// prettier-ignore
|
||||
pattern: /^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/ // eslint-disable-line max-len
|
||||
pattern:
|
||||
/^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/ // eslint-disable-line max-len
|
||||
});
|
||||
|
||||
CardType.cards.push({
|
||||
|
||||
@@ -12,7 +12,7 @@ export function destroySecuredFields(): void {
|
||||
// Then remove ref to SecuredField instance
|
||||
securedFieldKeys.forEach(pFieldType => {
|
||||
const sf: SecuredField = this.state.securedFields[pFieldType];
|
||||
if (sf) sf.destroy();// Comment out if you want to test the 'destroy' effects in the actual SF
|
||||
if (sf) sf.destroy(); // Comment out if you want to test the 'destroy' effects in the actual SF
|
||||
this.state.securedFields[pFieldType] = null;
|
||||
});
|
||||
// --
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function(ssn) {
|
||||
export default function (ssn) {
|
||||
return /(^\d{3}\.\d{3}\.\d{3}-\d{2}$)|(^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$)/.test(ssn);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {PaymentResponse, RawPaymentResponse, UIElementStatus} from './types';
|
||||
import { PaymentResponse, RawPaymentResponse, UIElementStatus } from './types';
|
||||
|
||||
const ALLOWED_PROPERTIES = ['action', 'resultCode', 'sessionData', 'order', 'sessionResult'];
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ describe('getComponentForAction', () => {
|
||||
method: 'GET',
|
||||
paymentMethodType: 'ideal',
|
||||
type: 'redirect',
|
||||
url:
|
||||
'http://localhost:8080/hpp/redirectIdeal.shtml?brandCode=ideal&countryCode=NL¤cyCode=EUR&issuerId=1121&merchantAccount=TestMerchant&merchantIntegration.type=CHECKOUT_GENERIC&merchantIntegration.version=49&merchantReference=8&merchantReturnData=991558707124405K&merchantSig=g1KlViuS0JSr%2Fl9ah1uC4dpYjpn9T%2FvB7dAwHn81sdA%3D&paymentAmount=250&recurringContract=RECURRING&resURL=http%3A%2F%2Flocalhost%3A8080%2Fcheckoutshopper%2Fservices%2FPaymentIncomingRedirect%2Fv1%2FlocalPaymentMethod%3FmerchantAccount%3DTestMerchant%26returnURL%3Dapp%253A%252F%252Fyou&sessionValidity=2019-05-24T15%3A12%3A04Z&shopperReference=emred&skinCode=pub.v2.9915585372919700.W8YBZHHDHqOtHZK8ZC-X7_n9x1N3opO8Wbc_MQlh2IU'
|
||||
url: 'http://localhost:8080/hpp/redirectIdeal.shtml?brandCode=ideal&countryCode=NL¤cyCode=EUR&issuerId=1121&merchantAccount=TestMerchant&merchantIntegration.type=CHECKOUT_GENERIC&merchantIntegration.version=49&merchantReference=8&merchantReturnData=991558707124405K&merchantSig=g1KlViuS0JSr%2Fl9ah1uC4dpYjpn9T%2FvB7dAwHn81sdA%3D&paymentAmount=250&recurringContract=RECURRING&resURL=http%3A%2F%2Flocalhost%3A8080%2Fcheckoutshopper%2Fservices%2FPaymentIncomingRedirect%2Fv1%2FlocalPaymentMethod%3FmerchantAccount%3DTestMerchant%26returnURL%3Dapp%253A%252F%252Fyou&sessionValidity=2019-05-24T15%3A12%3A04Z&shopperReference=emred&skinCode=pub.v2.9915585372919700.W8YBZHHDHqOtHZK8ZC-X7_n9x1N3opO8Wbc_MQlh2IU'
|
||||
};
|
||||
|
||||
const redirectPostActionMock = {
|
||||
@@ -17,8 +16,7 @@ describe('getComponentForAction', () => {
|
||||
data: {
|
||||
test: '123'
|
||||
},
|
||||
url:
|
||||
'http://localhost:8080/hpp/redirectIdeal.shtml?brandCode=ideal&countryCode=NL¤cyCode=EUR&issuerId=1121&merchantAccount=TestMerchant&merchantIntegration.type=CHECKOUT_GENERIC&merchantIntegration.version=49&merchantReference=8&merchantReturnData=991558707124405K&merchantSig=g1KlViuS0JSr%2Fl9ah1uC4dpYjpn9T%2FvB7dAwHn81sdA%3D&paymentAmount=250&recurringContract=RECURRING&resURL=http%3A%2F%2Flocalhost%3A8080%2Fcheckoutshopper%2Fservices%2FPaymentIncomingRedirect%2Fv1%2FlocalPaymentMethod%3FmerchantAccount%3DTestMerchant%26returnURL%3Dapp%253A%252F%252Fyou&sessionValidity=2019-05-24T15%3A12%3A04Z&shopperReference=emred&skinCode=pub.v2.9915585372919700.W8YBZHHDHqOtHZK8ZC-X7_n9x1N3opO8Wbc_MQlh2IU'
|
||||
url: 'http://localhost:8080/hpp/redirectIdeal.shtml?brandCode=ideal&countryCode=NL¤cyCode=EUR&issuerId=1121&merchantAccount=TestMerchant&merchantIntegration.type=CHECKOUT_GENERIC&merchantIntegration.version=49&merchantReference=8&merchantReturnData=991558707124405K&merchantSig=g1KlViuS0JSr%2Fl9ah1uC4dpYjpn9T%2FvB7dAwHn81sdA%3D&paymentAmount=250&recurringContract=RECURRING&resURL=http%3A%2F%2Flocalhost%3A8080%2Fcheckoutshopper%2Fservices%2FPaymentIncomingRedirect%2Fv1%2FlocalPaymentMethod%3FmerchantAccount%3DTestMerchant%26returnURL%3Dapp%253A%252F%252Fyou&sessionValidity=2019-05-24T15%3A12%3A04Z&shopperReference=emred&skinCode=pub.v2.9915585372919700.W8YBZHHDHqOtHZK8ZC-X7_n9x1N3opO8Wbc_MQlh2IU'
|
||||
};
|
||||
|
||||
test('processes a redirect response', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { httpPost } from '../http';
|
||||
import Session from '../../CheckoutSession';
|
||||
import {CheckoutSessionOrdersResponse, Order} from '../../../types';
|
||||
import { CheckoutSessionOrdersResponse, Order } from '../../../types';
|
||||
import { API_VERSION } from './constants';
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,8 +89,7 @@ describe('Core', () => {
|
||||
paymentData: 'Ab02b4c0!BQABAgCUeRP+3La4...',
|
||||
paymentMethodType: 'scheme',
|
||||
subtype: 'fingerprint',
|
||||
token:
|
||||
'eyJ0aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2hvcHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC90aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uLnNodG1sP29yaWdpbktleT1wdWIudjIuODExNTY1ODcwNTcxMzk0MC5hSFIwY0hNNkx5OXdhSEF0TnpFdGMybHRiMjR1YzJWaGJXeGxjM010WTJobFkydHZkWFF1WTI5dC50VnJIV3B4UktWVTVPMENiNUg5TVFlUnJKdmZRQ1lnbXR6VTY1WFhzZ2NvIiwidGhyZWVEU01ldGhvZFVybCI6Imh0dHBzOlwvXC9wYWwtdGVzdC5hZHllbi5jb21cL3RocmVlZHMyc2ltdWxhdG9yXC9hY3NcL3N0YXJ0TWV0aG9kLnNodG1sIiwidGhyZWVEU1NlcnZlclRyYW5zSUQiOiI5MzI2ZjNiOS00MTc3LTQ4ZTktYmM2Mi1kOTliYzVkZDA2Y2IifQ==',
|
||||
token: 'eyJ0aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2hvcHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC90aHJlZURTTWV0aG9kTm90aWZpY2F0aW9uLnNodG1sP29yaWdpbktleT1wdWIudjIuODExNTY1ODcwNTcxMzk0MC5hSFIwY0hNNkx5OXdhSEF0TnpFdGMybHRiMjR1YzJWaGJXeGxjM010WTJobFkydHZkWFF1WTI5dC50VnJIV3B4UktWVTVPMENiNUg5TVFlUnJKdmZRQ1lnbXR6VTY1WFhzZ2NvIiwidGhyZWVEU01ldGhvZFVybCI6Imh0dHBzOlwvXC9wYWwtdGVzdC5hZHllbi5jb21cL3RocmVlZHMyc2ltdWxhdG9yXC9hY3NcL3N0YXJ0TWV0aG9kLnNodG1sIiwidGhyZWVEU1NlcnZlclRyYW5zSUQiOiI5MzI2ZjNiOS00MTc3LTQ4ZTktYmM2Mi1kOTliYzVkZDA2Y2IifQ==',
|
||||
type: 'threeDS2'
|
||||
};
|
||||
|
||||
@@ -117,8 +116,7 @@ describe('Core', () => {
|
||||
const challengeAction = {
|
||||
paymentData: 'Ab02b4c0!BQABAgCUeRP+3La4...',
|
||||
subtype: 'challenge',
|
||||
token:
|
||||
'eyJhY3NSZWZlcmVuY2VOdW1iZXIiOiJBRFlFTi1BQ1MtU0lNVUxBVE9SIiwiYWNzVHJhbnNJRCI6Ijg0MzZjYThkLThkN2EtNGFjYy05NmYyLTE0ZjU0MjgyNzczZiIsImFjc1VSTCI6Imh0dHBzOlwvXC9wYWwtdGVzdC5hZHllbi5jb21cL3RocmVlZHMyc2ltdWxhdG9yXC9hY3NcL2NoYWxsZW5nZS5zaHRtbCIsIm1lc3NhZ2VWZXJzaW9uIjoiMi4xLjAiLCJ0aHJlZURTTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2hvcHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC8zZG5vdGlmLnNodG1sP29yaWdpbktleT1wdWIudjIuODExNTY1ODcwNTcxMzk0MC5hSFIwY0hNNkx5OWphR1ZqYTI5MWRITm9iM0J3WlhJdGRHVnpkQzVoWkhsbGJpNWpiMjAuVGFKalVLN3VrUFdTUzJEX3l2ZDY4TFRLN2dRN2ozRXFOM05nS1JWQW84OCIsInRocmVlRFNTZXJ2ZXJUcmFuc0lEIjoiZTU0NDNjZTYtNTE3Mi00MmM1LThjY2MtYmRjMGE1MmNkZjViIn0=',
|
||||
token: 'eyJhY3NSZWZlcmVuY2VOdW1iZXIiOiJBRFlFTi1BQ1MtU0lNVUxBVE9SIiwiYWNzVHJhbnNJRCI6Ijg0MzZjYThkLThkN2EtNGFjYy05NmYyLTE0ZjU0MjgyNzczZiIsImFjc1VSTCI6Imh0dHBzOlwvXC9wYWwtdGVzdC5hZHllbi5jb21cL3RocmVlZHMyc2ltdWxhdG9yXC9hY3NcL2NoYWxsZW5nZS5zaHRtbCIsIm1lc3NhZ2VWZXJzaW9uIjoiMi4xLjAiLCJ0aHJlZURTTm90aWZpY2F0aW9uVVJMIjoiaHR0cHM6XC9cL2NoZWNrb3V0c2hvcHBlci10ZXN0LmFkeWVuLmNvbVwvY2hlY2tvdXRzaG9wcGVyXC8zZG5vdGlmLnNodG1sP29yaWdpbktleT1wdWIudjIuODExNTY1ODcwNTcxMzk0MC5hSFIwY0hNNkx5OWphR1ZqYTI5MWRITm9iM0J3WlhJdGRHVnpkQzVoWkhsbGJpNWpiMjAuVGFKalVLN3VrUFdTUzJEX3l2ZDY4TFRLN2dRN2ozRXFOM05nS1JWQW84OCIsInRocmVlRFNTZXJ2ZXJUcmFuc0lEIjoiZTU0NDNjZTYtNTE3Mi00MmM1LThjY2MtYmRjMGE1MmNkZjViIn0=',
|
||||
type: 'threeDS2',
|
||||
paymentMethodType: 'scheme'
|
||||
};
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import {
|
||||
formatCustomTranslations,
|
||||
formatLocale,
|
||||
getTranslation,
|
||||
interpolateElement,
|
||||
loadTranslations,
|
||||
matchLocale,
|
||||
parseLocale
|
||||
} from './utils';
|
||||
import { formatCustomTranslations, formatLocale, getTranslation, interpolateElement, loadTranslations, matchLocale, parseLocale } from './utils';
|
||||
import locales from './locales';
|
||||
import {createElement} from "preact";
|
||||
import { createElement } from 'preact';
|
||||
|
||||
const defaultSupportedLocales = Object.keys(locales);
|
||||
|
||||
@@ -257,7 +249,7 @@ describe('interpolateElement()', () => {
|
||||
|
||||
test('it should throw an error when wrong amount elements', () => {
|
||||
const renderLink = translation => createElement('a', { href: 'example.com' }, [translation]);
|
||||
const resultFn = () => interpolateElement('By clicking continue %#you%# agree with the %#term and conditions%#', [renderLink]);
|
||||
const resultFn = () => interpolateElement('By clicking continue %#you%# agree with the %#term and conditions%#', [renderLink]);
|
||||
expect(resultFn).toThrow(Error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { digitsOnlyFormatter } from "./formatters";
|
||||
import { digitsOnlyFormatter } from './formatters';
|
||||
|
||||
function getAllCharactersArray() {
|
||||
const allCharacters:Array<string> = [];
|
||||
for (let i=32; i<127; i++) { allCharacters.push(String.fromCharCode(i)); }
|
||||
function getAllCharactersArray() {
|
||||
const allCharacters: Array<string> = [];
|
||||
for (let i = 32; i < 127; i++) {
|
||||
allCharacters.push(String.fromCharCode(i));
|
||||
}
|
||||
return allCharacters.join(',');
|
||||
}
|
||||
|
||||
|
||||
describe('Formatters', () => {
|
||||
describe('digitsOnlyFormatter', () => {
|
||||
test('All non-digit characters get removed from value', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FormatterFn } from "./types";
|
||||
import { FormatterFn } from './types';
|
||||
|
||||
// Removes all non-digits
|
||||
export const digitsOnlyFormatter: FormatterFn = (value:string) => {
|
||||
export const digitsOnlyFormatter: FormatterFn = (value: string) => {
|
||||
return value.replace(/[^0-9]/g, '');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Context holds state data for the input field implementing this.
|
||||
export type FormatterFn = (value: string, context?: {
|
||||
state: {
|
||||
data: {
|
||||
country?: string,
|
||||
},
|
||||
},
|
||||
}) => string;
|
||||
export type FormatterFn = (
|
||||
value: string,
|
||||
context?: {
|
||||
state: {
|
||||
data: {
|
||||
country?: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
) => string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ValidationRuleResult } from './ValidationRuleResult';
|
||||
import { Formatter } from '../useForm/types'
|
||||
import { Formatter } from '../useForm/types';
|
||||
|
||||
type ValidatorMode = 'blur' | 'input';
|
||||
|
||||
|
||||
@@ -15,19 +15,19 @@ export interface ImageOptions {
|
||||
const returnImage = ({ name, loadingContext, imageFolder = '', parentFolder = '', extension, size = '', subFolder = '' }: ImageOptions): string =>
|
||||
`${loadingContext}images/${imageFolder}${subFolder}${parentFolder}${name}${size}.${extension}`;
|
||||
|
||||
export const getImageUrl = ({ loadingContext = FALLBACK_CONTEXT, extension = 'svg', ...options }: ImageOptions): Function => (
|
||||
name: string
|
||||
): string => {
|
||||
const imageOptions: ImageOptions = {
|
||||
extension,
|
||||
loadingContext,
|
||||
imageFolder: 'logos/',
|
||||
parentFolder: '',
|
||||
name,
|
||||
...options
|
||||
export const getImageUrl =
|
||||
({ loadingContext = FALLBACK_CONTEXT, extension = 'svg', ...options }: ImageOptions): Function =>
|
||||
(name: string): string => {
|
||||
const imageOptions: ImageOptions = {
|
||||
extension,
|
||||
loadingContext,
|
||||
imageFolder: 'logos/',
|
||||
parentFolder: '',
|
||||
name,
|
||||
...options
|
||||
};
|
||||
|
||||
return returnImage(imageOptions);
|
||||
};
|
||||
|
||||
return returnImage(imageOptions);
|
||||
};
|
||||
|
||||
export default getImageUrl;
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { getImageUrl, ImageOptions } from './get-image';
|
||||
|
||||
const getIssuerImageUrl = (options: object, type: string) => (issuer: string): string => {
|
||||
if (!issuer) return null;
|
||||
const getIssuerImageUrl =
|
||||
(options: object, type: string) =>
|
||||
(issuer: string): string => {
|
||||
if (!issuer) return null;
|
||||
|
||||
const imageOptions: ImageOptions = {
|
||||
parentFolder: issuer ? `${type}/` : '',
|
||||
type: issuer || type,
|
||||
...options
|
||||
const imageOptions: ImageOptions = {
|
||||
parentFolder: issuer ? `${type}/` : '',
|
||||
type: issuer || type,
|
||||
...options
|
||||
};
|
||||
|
||||
return getImageUrl(imageOptions)(issuer);
|
||||
};
|
||||
|
||||
return getImageUrl(imageOptions)(issuer);
|
||||
};
|
||||
|
||||
export default getIssuerImageUrl;
|
||||
|
||||
@@ -12,44 +12,46 @@
|
||||
import { hasOwnProperty } from './hasOwnProperty';
|
||||
import { PostMsgParseErrorObject } from '../components/ThreeDS2/types';
|
||||
|
||||
const getProcessMessageHandler = (domain: string, resolve: Function, reject: Function, expectedType: string): Function => event => {
|
||||
const parseErrorObj: PostMsgParseErrorObject = {};
|
||||
const origin = event.origin || event.originalEvent.origin;
|
||||
const getProcessMessageHandler =
|
||||
(domain: string, resolve: Function, reject: Function, expectedType: string): Function =>
|
||||
event => {
|
||||
const parseErrorObj: PostMsgParseErrorObject = {};
|
||||
const origin = event.origin || event.originalEvent.origin;
|
||||
|
||||
if (origin !== domain) {
|
||||
return 'Message was not sent from the expected domain';
|
||||
}
|
||||
|
||||
if (typeof event.data !== 'string') {
|
||||
return 'Event data was not of type string';
|
||||
}
|
||||
|
||||
if (!event.data.length) {
|
||||
return 'Invalid event data string';
|
||||
}
|
||||
|
||||
// Try to parse the data
|
||||
try {
|
||||
const feedbackObj = JSON.parse(event.data);
|
||||
if (hasOwnProperty(feedbackObj, 'type') && feedbackObj.type === expectedType) {
|
||||
resolve(feedbackObj);
|
||||
} else {
|
||||
// Silent fail - applies when RiskModule device fingerprinting is ongoing and this handler is picking up securedFields traffic
|
||||
return 'Event data was not of expected type';
|
||||
if (origin !== domain) {
|
||||
return 'Message was not sent from the expected domain';
|
||||
}
|
||||
} catch (e) {
|
||||
parseErrorObj.type = `${expectedType}-JSON-parse-error`;
|
||||
parseErrorObj.comment = 'failed to JSON parse event.data';
|
||||
parseErrorObj.extraInfo = `event.data = ${event.data}`;
|
||||
parseErrorObj.eventDataRaw = event.data;
|
||||
|
||||
// TODO - decide whether to console.log/debug/error &/or call the merchant defined onError callback
|
||||
console.debug('get-process-message-handler::CATCH::Un-parseable JSON:: parseErrorObj=', parseErrorObj);
|
||||
if (typeof event.data !== 'string') {
|
||||
return 'Event data was not of type string';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!event.data.length) {
|
||||
return 'Invalid event data string';
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
// Try to parse the data
|
||||
try {
|
||||
const feedbackObj = JSON.parse(event.data);
|
||||
if (hasOwnProperty(feedbackObj, 'type') && feedbackObj.type === expectedType) {
|
||||
resolve(feedbackObj);
|
||||
} else {
|
||||
// Silent fail - applies when RiskModule device fingerprinting is ongoing and this handler is picking up securedFields traffic
|
||||
return 'Event data was not of expected type';
|
||||
}
|
||||
} catch (e) {
|
||||
parseErrorObj.type = `${expectedType}-JSON-parse-error`;
|
||||
parseErrorObj.comment = 'failed to JSON parse event.data';
|
||||
parseErrorObj.extraInfo = `event.data = ${event.data}`;
|
||||
parseErrorObj.eventDataRaw = event.data;
|
||||
|
||||
// TODO - decide whether to console.log/debug/error &/or call the merchant defined onError callback
|
||||
console.debug('get-process-message-handler::CATCH::Un-parseable JSON:: parseErrorObj=', parseErrorObj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default getProcessMessageHandler;
|
||||
|
||||
@@ -2,7 +2,11 @@ import getProp from './getProp';
|
||||
|
||||
const props = {
|
||||
user: {
|
||||
posts: [{ title: 'Foo', comments: ['Good one!', 'Interesting...'] }, { title: 'Bar', comments: ['Ok'] }, { title: 'Baz', comments: [] }]
|
||||
posts: [
|
||||
{ title: 'Foo', comments: ['Good one!', 'Interesting...'] },
|
||||
{ title: 'Bar', comments: ['Ok'] },
|
||||
{ title: 'Baz', comments: [] }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,11 @@ describe('creating a promiseTimeout', () => {
|
||||
|
||||
test('and letting it time out', async () => {
|
||||
jest.useFakeTimers();
|
||||
const newPromiseTimeout = promiseTimeout(1000, promiseOne(() => {}), { timed_out: true });
|
||||
const newPromiseTimeout = promiseTimeout(
|
||||
1000,
|
||||
promiseOne(() => {}),
|
||||
{ timed_out: true }
|
||||
);
|
||||
|
||||
// Fast-forward until all timers have been executed
|
||||
jest.advanceTimersByTime(1000);
|
||||
|
||||
@@ -23,11 +23,11 @@ export interface Formatter {
|
||||
}
|
||||
|
||||
export type FormProps = {
|
||||
rules?: ValidatorRules,
|
||||
rules?: ValidatorRules;
|
||||
formatters?: {
|
||||
[key: string]: Formatter | Function;
|
||||
},
|
||||
[key: string]: any,
|
||||
};
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export interface Form<FormSchema> extends FormState<FormSchema> {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getReducer, init } from './reducer';
|
||||
import { Form, FormState, FormProps, Formatter } from './types';
|
||||
|
||||
function isFormatterObject(formatter: Formatter | Function): formatter is Formatter {
|
||||
return formatter && ('formatterFn' in formatter);
|
||||
return formatter && 'formatterFn' in formatter;
|
||||
}
|
||||
|
||||
function useForm<FormSchema>(props: FormProps): Form<FormSchema> {
|
||||
|
||||
Reference in New Issue
Block a user