mirror of
https://github.com/valitydev/checkout.git
synced 2024-11-06 10:35:20 +00:00
FE-667: Lodash import fix. Apple pay make payment fix. (#278)
This commit is contained in:
parent
d2ce195bc9
commit
1849a12b32
@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { get } from 'lodash-es';
|
import get from 'lodash-es/get';
|
||||||
import * as styles from './user-interaction-modal.scss';
|
import * as styles from './user-interaction-modal.scss';
|
||||||
import {
|
import {
|
||||||
EventInteractionObject,
|
EventInteractionObject,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { last } from 'lodash-es';
|
import last from 'lodash-es/last';
|
||||||
import { call, CallEffect, ForkEffect, put, select, takeLatest } from 'redux-saga/effects';
|
import { call, CallEffect, ForkEffect, put, select, takeLatest } from 'redux-saga/effects';
|
||||||
import { goToFormInfo, TypeKeys } from 'checkout/actions';
|
import { goToFormInfo, TypeKeys } from 'checkout/actions';
|
||||||
import { ConfigState, ModelState, ResultFormInfo, ResultType, State, EventsStatus } from 'checkout/state';
|
import { ConfigState, ModelState, ResultFormInfo, ResultType, State, EventsStatus } from 'checkout/state';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { call, CallEffect, ForkEffect, put, PutEffect, select, SelectEffect, takeLatest } from 'redux-saga/effects';
|
import { call, CallEffect, ForkEffect, put, PutEffect, select, SelectEffect, takeLatest } from 'redux-saga/effects';
|
||||||
import { last } from 'lodash-es';
|
import last from 'lodash-es/last';
|
||||||
import {
|
import {
|
||||||
GoToFormInfo,
|
GoToFormInfo,
|
||||||
goToFormInfo,
|
goToFormInfo,
|
||||||
|
@ -2,7 +2,7 @@ import { call, CallEffect, put, PutEffect } from 'redux-saga/effects';
|
|||||||
import { InvoiceTemplate, createInvoiceWithTemplate as request } from 'checkout/backend';
|
import { InvoiceTemplate, createInvoiceWithTemplate as request } from 'checkout/backend';
|
||||||
import { InvoiceCreated, TypeKeys } from 'checkout/actions';
|
import { InvoiceCreated, TypeKeys } from 'checkout/actions';
|
||||||
import { AmountInfoState, AmountInfoStatus } from 'checkout/state';
|
import { AmountInfoState, AmountInfoStatus } from 'checkout/state';
|
||||||
import { formAmountToMinorNumver } from 'checkout/utils';
|
import { formAmountToMinorNumber } from 'checkout/utils';
|
||||||
|
|
||||||
export type Effects = CallEffect | PutEffect<InvoiceCreated>;
|
export type Effects = CallEffect | PutEffect<InvoiceCreated>;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ const getAmount = (amountInfo: AmountInfoState, formAmount: string): number => {
|
|||||||
case AmountInfoStatus.final:
|
case AmountInfoStatus.final:
|
||||||
return amountInfo.minorValue;
|
return amountInfo.minorValue;
|
||||||
case AmountInfoStatus.notKnown:
|
case AmountInfoStatus.notKnown:
|
||||||
return formAmountToMinorNumver(formAmount);
|
return formAmountToMinorNumber(formAmount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
import { call, CallEffect } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, ModelState, PayableFormValues } from 'checkout/state';
|
import { AmountInfoState, ModelState, PayableFormValues } from 'checkout/state';
|
||||||
import { getPayableInvoice } from './get-payable-invoice';
|
import { getPayableInvoice } from './get-payable-invoice';
|
||||||
import { InvoiceEvent, PaymentResource } from 'checkout/backend';
|
import { PaymentResource } from 'checkout/backend';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { createPayment } from './create-payment';
|
import { createPayment } from './create-payment';
|
||||||
import { pollInvoiceEvents } from '../../poll-events';
|
import { pollInvoiceEvents } from '../../poll-events';
|
||||||
|
|
||||||
type CreatePaymentResourceFn = () => Iterator<PaymentResource>;
|
type CreatePaymentResourceFn = () => Iterator<PaymentResource>;
|
||||||
|
|
||||||
type Effects = CallEffect | InvoiceEvent;
|
|
||||||
|
|
||||||
export function* makePayment(
|
export function* makePayment(
|
||||||
config: Config,
|
config: Config,
|
||||||
model: ModelState,
|
model: ModelState,
|
||||||
values: PayableFormValues,
|
values: PayableFormValues,
|
||||||
amountInfo: AmountInfoState,
|
amountInfo: AmountInfoState,
|
||||||
fn: CreatePaymentResourceFn
|
fn: CreatePaymentResourceFn
|
||||||
): Iterator<Effects> {
|
): Iterator<CallEffect> {
|
||||||
const { initConfig, appConfig } = config;
|
const { initConfig, appConfig } = config;
|
||||||
const { capiEndpoint } = appConfig;
|
const { capiEndpoint } = appConfig;
|
||||||
const {
|
const {
|
||||||
@ -25,5 +23,5 @@ export function* makePayment(
|
|||||||
} = yield call(getPayableInvoice, initConfig, capiEndpoint, model, amountInfo, values.amount);
|
} = yield call(getPayableInvoice, initConfig, capiEndpoint, model, amountInfo, values.amount);
|
||||||
const paymentResource = yield call(fn, invoiceAccessToken);
|
const paymentResource = yield call(fn, invoiceAccessToken);
|
||||||
yield call(createPayment, capiEndpoint, invoiceAccessToken, id, values.email, paymentResource, initConfig);
|
yield call(createPayment, capiEndpoint, invoiceAccessToken, id, values.email, paymentResource, initConfig);
|
||||||
return yield call(pollInvoiceEvents, capiEndpoint, invoiceAccessToken, id);
|
yield call(pollInvoiceEvents, capiEndpoint, invoiceAccessToken, id);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { validateMerchant } from './validate-merchant';
|
|
||||||
import { call, CallEffect } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
|
import { validateMerchant } from './validate-merchant';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { LogicError } from 'checkout/backend';
|
import { LogicError } from 'checkout/backend';
|
||||||
|
|
||||||
@ -20,11 +20,15 @@ const toLogicError = (errorEvent: any): LogicError => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const begin = (session: ApplePaySession, endpoint: string, payload: ApplePayPayload): Promise<ApplePayPayment> =>
|
const begin = (
|
||||||
|
session: ApplePaySession,
|
||||||
|
validationEndpoint: string,
|
||||||
|
payload: ApplePayPayload
|
||||||
|
): Promise<ApplePayPayment> =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
session.onvalidatemerchant = (event) =>
|
session.onvalidatemerchant = (event) =>
|
||||||
validateMerchant(endpoint, payload, event.validationURL)
|
validateMerchant(validationEndpoint, payload, event.validationURL)
|
||||||
.then((response: any) => session.completeMerchantValidation(response))
|
.then((response) => session.completeMerchantValidation(response))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
session.abort();
|
session.abort();
|
||||||
reject(toLogicError(error));
|
reject(toLogicError(error));
|
||||||
@ -36,11 +40,10 @@ const begin = (session: ApplePaySession, endpoint: string, payload: ApplePayPayl
|
|||||||
|
|
||||||
export function* beginSession(config: Config, session: ApplePaySession): Iterator<CallEffect> {
|
export function* beginSession(config: Config, session: ApplePaySession): Iterator<CallEffect> {
|
||||||
const { applePayMerchantID, wrapperEndpoint } = config.appConfig;
|
const { applePayMerchantID, wrapperEndpoint } = config.appConfig;
|
||||||
const applePayMerchantValidationEndpoint = wrapperEndpoint + '/applepay';
|
|
||||||
const payload = {
|
const payload = {
|
||||||
merchantIdentifier: applePayMerchantID,
|
merchantIdentifier: applePayMerchantID,
|
||||||
domainName: new URL(config.origin).hostname,
|
domainName: location.hostname,
|
||||||
displayName: 'RBKmoney Checkout'
|
displayName: 'RBKmoney Checkout'
|
||||||
};
|
};
|
||||||
return yield call(begin, session, applePayMerchantValidationEndpoint, payload);
|
return yield call(begin, session, `${wrapperEndpoint}/applepay`, payload);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ const fromInvoiceStatusChanged = (change: InvoiceStatusChanged): boolean => {
|
|||||||
|
|
||||||
const isSuccess = (event: InvoiceEvent): boolean => {
|
const isSuccess = (event: InvoiceEvent): boolean => {
|
||||||
const change = last(event.changes);
|
const change = last(event.changes);
|
||||||
|
if (!change) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (change.changeType) {
|
switch (change.changeType) {
|
||||||
case InvoiceChangeType.PaymentStatusChanged:
|
case InvoiceChangeType.PaymentStatusChanged:
|
||||||
return fromPaymentStatusChanged(change as PaymentStatusChanged);
|
return fromPaymentStatusChanged(change as PaymentStatusChanged);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { call } from 'redux-saga/effects';
|
import { call, CallEffect, select, SelectEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, ModelState, TokenProviderFormValues } from 'checkout/state';
|
import last from 'lodash-es/last';
|
||||||
|
import { AmountInfoState, ModelState, State, TokenProviderFormValues } from 'checkout/state';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { beginSession } from './begin-session';
|
import { beginSession } from './begin-session';
|
||||||
import { createSession } from './create-session';
|
import { createSession } from './create-session';
|
||||||
import { createApplePay } from '../../../create-payment-resource';
|
import { createApplePay } from '../../../create-payment-resource';
|
||||||
import { PaymentMethod, BankCard } from 'checkout/backend/model';
|
import { PaymentMethod, BankCard } from 'checkout/backend/model';
|
||||||
import { makePayment } from '../make-payment';
|
import { makePayment } from '../make-payment';
|
||||||
import { ProvidePaymentEffects } from '../provide-payment';
|
|
||||||
import { PaymentMethodName } from 'checkout/backend/model/payment-method';
|
import { PaymentMethodName } from 'checkout/backend/model/payment-method';
|
||||||
import { PaymentSystem } from 'checkout/backend/model/payment-system';
|
import { PaymentSystem } from 'checkout/backend/model/payment-system';
|
||||||
import { getSessionStatus } from './get-session-status';
|
import { getSessionStatus } from './get-session-status';
|
||||||
@ -26,7 +26,7 @@ export function* payWithApplePay(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: TokenProviderFormValues
|
v: TokenProviderFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<SelectEffect | CallEffect> {
|
||||||
const {
|
const {
|
||||||
initConfig: { description, name },
|
initConfig: { description, name },
|
||||||
appConfig
|
appConfig
|
||||||
@ -38,9 +38,9 @@ export function* payWithApplePay(
|
|||||||
const { capiEndpoint, applePayMerchantID } = appConfig;
|
const { capiEndpoint, applePayMerchantID } = appConfig;
|
||||||
try {
|
try {
|
||||||
const fn = createPaymentResource(capiEndpoint, applePayMerchantID, paymentToken);
|
const fn = createPaymentResource(capiEndpoint, applePayMerchantID, paymentToken);
|
||||||
const event = yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
|
const event = yield select((s: State) => last(s.events.events));
|
||||||
session.completePayment(getSessionStatus(event));
|
session.completePayment(getSessionStatus(event));
|
||||||
return event;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
session.completePayment(ApplePaySession.STATUS_FAILURE);
|
session.completePayment(ApplePaySession.STATUS_FAILURE);
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { call } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, CardFormValues, ModelState } from 'checkout/state';
|
import { AmountInfoState, CardFormValues, ModelState } from 'checkout/state';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { createCardData } from '../../create-payment-resource';
|
import { createCardData } from '../../create-payment-resource';
|
||||||
import { makePayment } from './make-payment';
|
import { makePayment } from './make-payment';
|
||||||
import { ProvidePaymentEffects } from './provide-payment';
|
|
||||||
|
|
||||||
const createPaymentResource = (endpoint: string, formValues: CardFormValues) =>
|
const createPaymentResource = (endpoint: string, formValues: CardFormValues) =>
|
||||||
createCardData.bind(null, endpoint, formValues);
|
createCardData.bind(null, endpoint, formValues);
|
||||||
@ -13,7 +12,7 @@ export function* payWithBankCard(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: CardFormValues
|
v: CardFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<CallEffect> {
|
||||||
const fn = createPaymentResource(c.appConfig.capiEndpoint, v);
|
const fn = createPaymentResource(c.appConfig.capiEndpoint, v);
|
||||||
return yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { call } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, ModelState, WalletFormValues } from 'checkout/state';
|
import { AmountInfoState, ModelState, WalletFormValues } from 'checkout/state';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { ProvidePaymentEffects } from './provide-payment';
|
|
||||||
import { createDigitalWalletQiwi } from '../../create-payment-resource';
|
import { createDigitalWalletQiwi } from '../../create-payment-resource';
|
||||||
import { makePayment } from './make-payment';
|
import { makePayment } from './make-payment';
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ export function* payWithDigitalWalletQiwi(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: WalletFormValues
|
v: WalletFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<CallEffect> {
|
||||||
const fn = createPaymentResource(c.appConfig.capiEndpoint, v);
|
const fn = createPaymentResource(c.appConfig.capiEndpoint, v);
|
||||||
return yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { call } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, ModelState, TokenProviderFormValues } from 'checkout/state';
|
import { AmountInfoState, ModelState, TokenProviderFormValues } from 'checkout/state';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { makePayment } from '../make-payment';
|
import { makePayment } from '../make-payment';
|
||||||
import { getPaymentData } from './get-payment-data';
|
import { getPaymentData } from './get-payment-data';
|
||||||
import { ProvidePaymentEffects } from '../provide-payment';
|
|
||||||
import { createGooglePay } from '../../../create-payment-resource';
|
import { createGooglePay } from '../../../create-payment-resource';
|
||||||
|
|
||||||
const createPaymentResource = (endpoint: string, googlePayMerchantID: string, paymentData: PaymentData) =>
|
const createPaymentResource = (endpoint: string, googlePayMerchantID: string, paymentData: PaymentData) =>
|
||||||
@ -14,11 +13,11 @@ export function* payWithGooglePay(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: TokenProviderFormValues
|
v: TokenProviderFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<CallEffect> {
|
||||||
const {
|
const {
|
||||||
appConfig: { googlePayMerchantID, googlePayGatewayMerchantID, capiEndpoint }
|
appConfig: { googlePayMerchantID, googlePayGatewayMerchantID, capiEndpoint }
|
||||||
} = c;
|
} = c;
|
||||||
const paymentData = yield call(getPaymentData, googlePayMerchantID, googlePayGatewayMerchantID, a, v.amount);
|
const paymentData = yield call(getPaymentData, googlePayMerchantID, googlePayGatewayMerchantID, a, v.amount);
|
||||||
const fn = createPaymentResource(capiEndpoint, googlePayGatewayMerchantID, paymentData);
|
const fn = createPaymentResource(capiEndpoint, googlePayGatewayMerchantID, paymentData);
|
||||||
return yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
ModelState,
|
ModelState,
|
||||||
TokenProviderFormValues
|
TokenProviderFormValues
|
||||||
} from 'checkout/state';
|
} from 'checkout/state';
|
||||||
import { call, put, PutEffect } from 'redux-saga/effects';
|
import { call, CallEffect, put, PutEffect } from 'redux-saga/effects';
|
||||||
import { TypeKeys } from 'checkout/actions';
|
import { TypeKeys } from 'checkout/actions';
|
||||||
import { Transaction } from 'checkout/backend';
|
import { Transaction } from 'checkout/backend';
|
||||||
import { ResultData, Type, URIPath } from '../../../../../constants/samsung-pay-communicator';
|
import { ResultData, Type, URIPath } from '../../../../../constants/samsung-pay-communicator';
|
||||||
@ -14,7 +14,6 @@ import { makePayment } from 'checkout/sagas/payment/provide-payment/make-payment
|
|||||||
import { createSamsungPay } from 'checkout/sagas/create-payment-resource/create-samsung-pay';
|
import { createSamsungPay } from 'checkout/sagas/create-payment-resource/create-samsung-pay';
|
||||||
import { createTransaction } from './create-transaction';
|
import { createTransaction } from './create-transaction';
|
||||||
import { getResultData } from './get-result-data';
|
import { getResultData } from './get-result-data';
|
||||||
import { ProvidePaymentEffects } from 'checkout/sagas/payment/provide-payment/provide-payment';
|
|
||||||
import { SetModalState } from 'checkout/actions/modal-actions/set-modal-state';
|
import { SetModalState } from 'checkout/actions/modal-actions/set-modal-state';
|
||||||
import { TokenizedInteractionObject } from 'checkout/state/modal/modal-interaction';
|
import { TokenizedInteractionObject } from 'checkout/state/modal/modal-interaction';
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ export function* payWithSamsungPay(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: TokenProviderFormValues
|
v: TokenProviderFormValues
|
||||||
): Iterator<Promise<Transaction> | PutEffect<SetModalState> | Promise<ResultData> | ProvidePaymentEffects> {
|
): Iterator<Promise<Transaction> | PutEffect<SetModalState> | Promise<ResultData> | CallEffect> {
|
||||||
const {
|
const {
|
||||||
appConfig,
|
appConfig,
|
||||||
appConfig: { samsungPayServiceID, capiEndpoint },
|
appConfig: { samsungPayServiceID, capiEndpoint },
|
||||||
@ -46,7 +45,7 @@ export function* payWithSamsungPay(
|
|||||||
const resultData: ResultData = yield getResultData(transaction, samsungPayServiceID, locale);
|
const resultData: ResultData = yield getResultData(transaction, samsungPayServiceID, locale);
|
||||||
if (resultData.type === Type.SUCCESS) {
|
if (resultData.type === Type.SUCCESS) {
|
||||||
const fn = createPaymentResource(capiEndpoint, resultData.refId, samsungPayServiceID);
|
const fn = createPaymentResource(capiEndpoint, resultData.refId, samsungPayServiceID);
|
||||||
return yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
} else {
|
} else {
|
||||||
throw { code: resultData.code || 'error.samsung.pay.cancel' };
|
throw { code: resultData.code || 'error.samsung.pay.cancel' };
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { call } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { createTerminalEuroset } from '../../create-payment-resource';
|
import { createTerminalEuroset } from '../../create-payment-resource';
|
||||||
import { ProvidePaymentEffects } from './provide-payment';
|
|
||||||
import { AmountInfoState, ModelState, PayableFormValues } from 'checkout/state';
|
import { AmountInfoState, ModelState, PayableFormValues } from 'checkout/state';
|
||||||
import { Config } from 'checkout/config';
|
import { Config } from 'checkout/config';
|
||||||
import { makePayment } from './make-payment';
|
import { makePayment } from './make-payment';
|
||||||
@ -12,7 +11,7 @@ export function* payWithTerminalEuroset(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: PayableFormValues
|
v: PayableFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<CallEffect> {
|
||||||
const fn = createPaymentResource(c.appConfig.capiEndpoint);
|
const fn = createPaymentResource(c.appConfig.capiEndpoint);
|
||||||
return yield call(makePayment, c, m, v, a, fn);
|
yield call(makePayment, c, m, v, a, fn);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { call, CallEffect } from 'redux-saga/effects';
|
import { call, CallEffect } from 'redux-saga/effects';
|
||||||
import { AmountInfoState, ConfigState, ModelState, PayableFormValues, PaymentMethodName } from 'checkout/state';
|
import { AmountInfoState, ConfigState, ModelState, PayableFormValues, PaymentMethodName } from 'checkout/state';
|
||||||
import { InvoiceEvent } from 'checkout/backend';
|
|
||||||
import { payWithApplePay } from './pay-with-apple-pay';
|
import { payWithApplePay } from './pay-with-apple-pay';
|
||||||
import { payWithBankCard } from './pay-with-bank-card';
|
import { payWithBankCard } from './pay-with-bank-card';
|
||||||
import { payWithDigitalWalletQiwi } from './pay-with-digital-wallet-qiwi';
|
import { payWithDigitalWalletQiwi } from './pay-with-digital-wallet-qiwi';
|
||||||
@ -8,8 +7,6 @@ import { payWithTerminalEuroset } from './pay-with-terminal-euroset';
|
|||||||
import { payWithGooglePay } from './pay-with-google-pay';
|
import { payWithGooglePay } from './pay-with-google-pay';
|
||||||
import { payWithSamsungPay } from './pay-with-samsung-pay';
|
import { payWithSamsungPay } from './pay-with-samsung-pay';
|
||||||
|
|
||||||
export type ProvidePaymentEffects = CallEffect | InvoiceEvent;
|
|
||||||
|
|
||||||
const getPayFn = (method: PaymentMethodName) => {
|
const getPayFn = (method: PaymentMethodName) => {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case PaymentMethodName.ApplePay:
|
case PaymentMethodName.ApplePay:
|
||||||
@ -35,7 +32,7 @@ export function* providePayment(
|
|||||||
m: ModelState,
|
m: ModelState,
|
||||||
a: AmountInfoState,
|
a: AmountInfoState,
|
||||||
v: PayableFormValues
|
v: PayableFormValues
|
||||||
): Iterator<ProvidePaymentEffects> {
|
): Iterator<CallEffect> {
|
||||||
const values = v ? v : { amount: null, email: null };
|
const values = v ? v : { amount: null, email: null };
|
||||||
return yield getPayFn(method)(c, m, a, values);
|
yield getPayFn(method)(c, m, a, values);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { last } from 'lodash-es';
|
import last from 'lodash-es/last';
|
||||||
import { delay } from 'redux-saga';
|
import { delay } from 'redux-saga';
|
||||||
import { call, CallEffect, put, PutEffect, race, RaceEffect, select, SelectEffect } from 'redux-saga/effects';
|
import { call, put, race, select, CallEffect, PutEffect, RaceEffect, SelectEffect } from 'redux-saga/effects';
|
||||||
import { CustomerChangeType, CustomerEvent, getCustomerEvents } from 'checkout/backend';
|
import { CustomerChangeType, CustomerEvent, getCustomerEvents } from 'checkout/backend';
|
||||||
import { SetEventsAction, TypeKeys } from 'checkout/actions';
|
import { SetEventsAction, TypeKeys } from 'checkout/actions';
|
||||||
import { State } from 'checkout/state';
|
import { State } from 'checkout/state';
|
||||||
@ -50,7 +50,7 @@ export function* pollCustomerEvents(
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
token: string,
|
token: string,
|
||||||
invoiceID: string
|
invoiceID: string
|
||||||
): Iterator<PutEffect<SetEventsAction> | RaceEffect> {
|
): Iterator<RaceEffect | PutEffect<SetEventsAction>> {
|
||||||
const [result] = yield race<any>([call(poll, endpoint, token, invoiceID), call(delay, 60000)]);
|
const [result] = yield race<any>([call(poll, endpoint, token, invoiceID), call(delay, 60000)]);
|
||||||
if (result) {
|
if (result) {
|
||||||
return yield put({
|
return yield put({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { last } from 'lodash-es';
|
import last from 'lodash-es/last';
|
||||||
import { delay } from 'redux-saga';
|
import { delay } from 'redux-saga';
|
||||||
import { call, CallEffect, put, PutEffect, race, RaceEffect, select, SelectEffect } from 'redux-saga/effects';
|
import { call, put, race, select, CallEffect, PutEffect, RaceEffect, SelectEffect } from 'redux-saga/effects';
|
||||||
import { InvoiceEvent, getInvoiceEvents, InvoiceChangeType } from 'checkout/backend';
|
import { InvoiceEvent, getInvoiceEvents, InvoiceChangeType } from 'checkout/backend';
|
||||||
import { SetEventsAction, TypeKeys } from 'checkout/actions';
|
import { SetEventsAction, TypeKeys } from 'checkout/actions';
|
||||||
import { State } from 'checkout/state';
|
import { State } from 'checkout/state';
|
||||||
@ -51,7 +51,7 @@ export function* pollInvoiceEvents(
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
token: string,
|
token: string,
|
||||||
invoiceID: string
|
invoiceID: string
|
||||||
): Iterator<PutEffect<SetEventsAction> | RaceEffect> {
|
): Iterator<RaceEffect | PutEffect<SetEventsAction>> {
|
||||||
const [result] = yield race<any>([call(poll, endpoint, token, invoiceID), call(delay, 60000)]);
|
const [result] = yield race<any>([call(poll, endpoint, token, invoiceID), call(delay, 60000)]);
|
||||||
if (result) {
|
if (result) {
|
||||||
return yield put({
|
return yield put({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { CallEffect, ForkEffect, PutEffect, SelectEffect, put, call, select, takeLatest } from 'redux-saga/effects';
|
import { CallEffect, ForkEffect, PutEffect, SelectEffect, put, call, select, takeLatest } from 'redux-saga/effects';
|
||||||
import { last } from 'lodash-es';
|
import last from 'lodash-es/last';
|
||||||
import {
|
import {
|
||||||
PrepareToPay,
|
PrepareToPay,
|
||||||
TypeKeys,
|
TypeKeys,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { toNumber } from 'lodash-es';
|
import toNumber from 'lodash-es/toNumber';
|
||||||
|
|
||||||
export const formAmountToMinorNumver = (formAmount: string): number =>
|
export const formAmountToMinorNumber = (formAmount: string): number =>
|
||||||
toNumber(formAmount.replace(/\s/g, '').replace(/,/g, '.')) * 100;
|
toNumber(formAmount.replace(/\s/g, '').replace(/,/g, '.')) * 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user