@adyen/react-native
Version:
Wraps Adyen Checkout Drop-In and Components for iOS and Android for convenient use with React Native
57 lines (56 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getWrapper = getWrapper;
var _core = require("../../core");
var _AdyenApplePay = require("../applepay/AdyenApplePay");
var _AdyenDropIn = require("../dropin/AdyenDropIn");
var _AdyenGooglePay = require("../googlepay/AdyenGooglePay");
var _AdyenInstant = require("../instant/AdyenInstant");
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.AdyenDropIn
};
case 'applepay':
return {
nativeComponent: _AdyenApplePay.AdyenApplePay
};
case 'paywithgoogle':
case 'googlepay':
return {
nativeComponent: _AdyenGooglePay.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.AdyenDropIn;
} else {
nativeComponent = _core.NATIVE_COMPONENTS.includes(typeName) ? _AdyenDropIn.AdyenDropIn : _AdyenInstant.AdyenInstant;
}
return {
nativeComponent,
paymentMethod
};
}
//# sourceMappingURL=getWrapper.js.map