react-native-moyasar-sdk
Version:
Official React Native Moyasar SDK - Integrate Credit Cards, Apple Pay, Samsung Pay, and STC Pay with simple interfaces for a seamless payment experience in your React Native app
48 lines (42 loc) • 2.03 kB
JavaScript
;
import { Platform, requireNativeComponent, View } from 'react-native';
import { SAMSUNG_PAY_BUTTON_COMPONENT_NAME } from "../../specs/RTNSamsungPayNativeComponent.android.js";
import { debugLog, errorLog } from "../../helpers/debug_log.js";
// Just a simple check for optimization when we are sure that the component will not be available on other devices
import { jsx as _jsx } from "react/jsx-runtime";
const isSamsungPayComponentAvailable = Platform.OS === 'android';
let SamsungPayButton;
// For extreme cases where the component is not available, we will use an empty component
// @ts-expect-error - Using type assertion to maintain original type signature
let FallbackComponent = () => {
debugLog('Moyasar SDK: Rendering Samsung Pay fallback component');
return /*#__PURE__*/_jsx(View, {
style: {
width: 0,
height: 0
}
});
};
if (isSamsungPayComponentAvailable) {
// We will Use either codegen or requireNativeComponent based on availability
// Try to import from the spec
try {
debugLog('Moyasar SDK: Importing Samsung Pay component from spec...');
SamsungPayButton = require('../../specs/RTNSamsungPayNativeComponent').default;
} catch (e) {
debugLog('Moyasar SDK: Samsung Pay component not found in spec, falling back to manual registration (old arch)...');
try {
// Fallback to manual registration (old arch)
SamsungPayButton = requireNativeComponent(SAMSUNG_PAY_BUTTON_COMPONENT_NAME);
} catch (innerError) {
errorLog(`Moyasar SDK: Failed to register Samsung Pay component manually. Please check your setup. ${innerError}`);
SamsungPayButton = FallbackComponent;
}
}
} else {
debugLog('Moyasar SDK: Samsung Pay component is not available on this device.');
// Shouldn't really render because the Samsung Pay compoent checks if the device is an Android device, but if it does, we will use a fallback component
SamsungPayButton = FallbackComponent;
}
export { SamsungPayButton };
//# sourceMappingURL=index.js.map