@rnw-community/react-native-payments
Version:
Accept Payments with Apple Pay and Android Pay using the Payment Request API.
13 lines • 684 B
JavaScript
import { isDefined } from '@rnw-community/shared';
import { PaymentShippingTypeEnum } from '../enum/payment-shipping-type.enum.js';
const validShippingTypes = Object.values(PaymentShippingTypeEnum);
// https://www.w3.org/TR/payment-request/#dom-paymentoptions-shippingtype
export const validateShippingType = (methodData, ErrorType) => {
methodData.forEach(paymentMethodData => {
const { shippingType } = paymentMethodData.data;
if (isDefined(shippingType) && !validShippingTypes.includes(shippingType)) {
throw new ErrorType(`'${shippingType}' is not a valid shippingType`);
}
});
};
//# sourceMappingURL=validate-shipping-type.util.js.map