@adyen/react-native
Version:
Wraps Adyen Checkout Drop-In and Components for iOS and Android for convenient use with React Native
54 lines (53 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getWrapper = getWrapper;
var _core = require("../../core");
var _ = require("..");
var _constants = require("./constants");
var _utils = require("./utils");
/**
* Get native component capable of handling provided payment method type.
*/
function getWrapper(typeName, paymentMethods) {
switch (typeName) {
case 'dropin':
case 'dropIn':
case 'drop-in':
case 'adyendropin':
return {
nativeComponent: _.AdyenDropIn
};
case 'applepay':
return {
nativeComponent: _.AdyenApplePay
};
case 'paywithgoogle':
case 'googlepay':
return {
nativeComponent: _.AdyenGooglePay
};
default:
break;
}
const paymentMethod = (0, _utils.find)(paymentMethods, typeName);
if (!paymentMethod) {
throw new Error(_constants.UNKNOWN_PAYMENT_METHOD_ERROR + typeName);
}
if (_core.UNSUPPORTED_PAYMENT_METHODS.includes(typeName)) {
throw new Error(_constants.UNSUPPORTED_PAYMENT_METHOD_ERROR + typeName);
}
let nativeComponent;
// Currently this resolves address lookup and bin lookup callbacks for Dropin-based Card payment.
if (_core.ADDRESS_COMPONENTS.includes(typeName)) {
nativeComponent = _.AdyenDropIn;
} else {
nativeComponent = _core.NATIVE_COMPONENTS.includes(typeName) ? _.AdyenDropIn : _.AdyenInstant;
}
return {
nativeComponent,
paymentMethod
};
}
//# sourceMappingURL=getWrapper.js.map