Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"parserOptions": {
"requireConfigFile": false,
"sourceType": "module",
"ecmaVersion": 2021
"ecmaVersion": 2022
},
"settings": {
"react": {
Expand All @@ -24,7 +24,7 @@
},
"env": {
"browser": true,
"es2021": true
"es2022": true
},
"rules": {
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
Expand Down
12 changes: 10 additions & 2 deletions src/payment/card/quickpay.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import Payment from '../payment';
import { isLiveMode } from '../../utils';
import { UnableAuthenticatePaymentMethodError } from '../../utils/errors';

import Payment from '../payment';

export default class QuickpayCardPayment extends Payment {
constructor(api, options, params, methods) {
super(api, options, params, methods.card);
}

get orderId() {
return Math.random().toString(36).substr(2, 9);
return Math.random().toString(36).slice(2, 11);
}

async tokenize() {
Expand Down Expand Up @@ -69,6 +71,12 @@ export default class QuickpayCardPayment extends Payment {
throw new Error(card.error.message);
}

card.gateway = 'quickpay';

if (!isLiveMode(this.method.mode)) {
card.test = true;
}

await this.updateCart({
billing: {
method: 'card',
Expand Down
11 changes: 9 additions & 2 deletions src/payment/card/stripe.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import Payment from '../payment';
import { isLiveMode } from '../../utils';
import { LibraryNotLoadedError } from '../../utils/errors';

import {
createElement,
createPaymentMethod,
isStripeChargeableAmount,
stripeAmountByCurrency,
} from '../../utils/stripe';
import { LibraryNotLoadedError } from '../../utils/errors';

import Payment from '../payment';

/** @typedef {import('@stripe/stripe-js').Stripe} Stripe */
/** @typedef {import('@stripe/stripe-js').StripeCardElement} StripeCardElement */
Expand Down Expand Up @@ -82,6 +85,10 @@ export default class StripeCardPayment extends Payment {
throw new Error(paymentMethod.error.message);
}

if (!isLiveMode(this.method.mode)) {
paymentMethod.test = true;
}

// should save payment method data when payment amount is not chargeable
if (!isStripeChargeableAmount(cart.capture_total, cart.currency)) {
await this.updateCart({
Expand Down
1 change: 1 addition & 0 deletions src/utils/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export async function createPaymentMethod(stripe, cardElement, cart) {
return error
? { error }
: {
gateway: 'stripe',
token: paymentMethod.id,
last4: paymentMethod.card.last4,
exp_month: paymentMethod.card.exp_month,
Expand Down
1 change: 1 addition & 0 deletions src/utils/stripe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('utils/stripe', () => {
address_check: 'address_line1_check',
cvc_check: 'cvc_check',
zip_check: 'address_postal_code_check',
gateway: 'stripe',
};

const stripe = {
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"esModuleInterop": false,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"baseUrl": "./",
"lib": ["es2022", "dom"]
"lib": ["es2022", "dom"],
"allowJs": true
},
"exclude": [
"node_modules",
Expand Down
Loading