expo-openpay 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/android/build.gradle +76 -0
- package/android/gradle.properties +2 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/openpay/ExpoOpenpayModule.kt +127 -0
- package/android/src/main/java/expo/modules/openpay/ExpoOpenpayView.kt +30 -0
- package/android/src/main/java/mx/openpay/android/BuildConfig.java +8 -0
- package/android/src/main/java/mx/openpay/android/DeviceCollectorDefaultImpl.java +70 -0
- package/android/src/main/java/mx/openpay/android/JavaScriptInterface.java +19 -0
- package/android/src/main/java/mx/openpay/android/OpCountry.java +24 -0
- package/android/src/main/java/mx/openpay/android/OpenPayResult.java +35 -0
- package/android/src/main/java/mx/openpay/android/Openpay.java +98 -0
- package/android/src/main/java/mx/openpay/android/OpenpayUrls.java +11 -0
- package/android/src/main/java/mx/openpay/android/OperationCallBack.java +13 -0
- package/android/src/main/java/mx/openpay/android/OperationResult.java +14 -0
- package/android/src/main/java/mx/openpay/android/exceptions/OpenpayServiceException.java +93 -0
- package/android/src/main/java/mx/openpay/android/exceptions/ServiceUnavailableException.java +23 -0
- package/android/src/main/java/mx/openpay/android/model/Address.java +123 -0
- package/android/src/main/java/mx/openpay/android/model/Card.java +219 -0
- package/android/src/main/java/mx/openpay/android/model/Token.java +43 -0
- package/android/src/main/java/mx/openpay/android/services/BaseService.java +93 -0
- package/android/src/main/java/mx/openpay/android/services/ServicesFactory.java +47 -0
- package/android/src/main/java/mx/openpay/android/services/TokenService.java +19 -0
- package/android/src/main/java/mx/openpay/android/validation/CardType.java +9 -0
- package/android/src/main/java/mx/openpay/android/validation/CardValidator.java +105 -0
- package/android/src/main/java/mx/openpay/android/validation/LuhnValidator.java +34 -0
- package/build/ExpoOpenpay.types.d.ts +42 -0
- package/build/ExpoOpenpay.types.d.ts.map +1 -0
- package/build/ExpoOpenpay.types.js +2 -0
- package/build/ExpoOpenpay.types.js.map +1 -0
- package/build/ExpoOpenpayModule.d.ts +10 -0
- package/build/ExpoOpenpayModule.d.ts.map +1 -0
- package/build/ExpoOpenpayModule.js +6 -0
- package/build/ExpoOpenpayModule.js.map +1 -0
- package/build/ExpoOpenpayModule.web.d.ts +10 -0
- package/build/ExpoOpenpayModule.web.d.ts.map +1 -0
- package/build/ExpoOpenpayModule.web.js +12 -0
- package/build/ExpoOpenpayModule.web.js.map +1 -0
- package/build/ExpoOpenpayView.d.ts +4 -0
- package/build/ExpoOpenpayView.d.ts.map +1 -0
- package/build/ExpoOpenpayView.js +7 -0
- package/build/ExpoOpenpayView.js.map +1 -0
- package/build/ExpoOpenpayView.web.d.ts +3 -0
- package/build/ExpoOpenpayView.web.d.ts.map +1 -0
- package/build/ExpoOpenpayView.web.js +5 -0
- package/build/ExpoOpenpayView.web.js.map +1 -0
- package/build/assets/AmexLogo.d.ts +4 -0
- package/build/assets/AmexLogo.d.ts.map +1 -0
- package/build/assets/AmexLogo.js +9 -0
- package/build/assets/AmexLogo.js.map +1 -0
- package/build/assets/MCLogo.d.ts +4 -0
- package/build/assets/MCLogo.d.ts.map +1 -0
- package/build/assets/MCLogo.js +9 -0
- package/build/assets/MCLogo.js.map +1 -0
- package/build/assets/VisaLogo.d.ts +4 -0
- package/build/assets/VisaLogo.d.ts.map +1 -0
- package/build/assets/VisaLogo.js +6 -0
- package/build/assets/VisaLogo.js.map +1 -0
- package/build/assets/index.d.ts +4 -0
- package/build/assets/index.d.ts.map +1 -0
- package/build/assets/index.js +4 -0
- package/build/assets/index.js.map +1 -0
- package/build/components/OPCardForm.d.ts +33 -0
- package/build/components/OPCardForm.d.ts.map +1 -0
- package/build/components/OPCardForm.js +120 -0
- package/build/components/OPCardForm.js.map +1 -0
- package/build/components/OPCardNumberInput.d.ts +17 -0
- package/build/components/OPCardNumberInput.d.ts.map +1 -0
- package/build/components/OPCardNumberInput.js +60 -0
- package/build/components/OPCardNumberInput.js.map +1 -0
- package/build/components/OPCvv2Input.d.ts +17 -0
- package/build/components/OPCvv2Input.d.ts.map +1 -0
- package/build/components/OPCvv2Input.js +13 -0
- package/build/components/OPCvv2Input.js.map +1 -0
- package/build/components/OPExpInput.d.ts +17 -0
- package/build/components/OPExpInput.d.ts.map +1 -0
- package/build/components/OPExpInput.js +22 -0
- package/build/components/OPExpInput.js.map +1 -0
- package/build/components/OPExpMonthInput.d.ts +17 -0
- package/build/components/OPExpMonthInput.d.ts.map +1 -0
- package/build/components/OPExpMonthInput.js +6 -0
- package/build/components/OPExpMonthInput.js.map +1 -0
- package/build/components/OPExpYearInput.d.ts +17 -0
- package/build/components/OPExpYearInput.d.ts.map +1 -0
- package/build/components/OPExpYearInput.js +6 -0
- package/build/components/OPExpYearInput.js.map +1 -0
- package/build/components/OPHolderNameInput.d.ts +17 -0
- package/build/components/OPHolderNameInput.d.ts.map +1 -0
- package/build/components/OPHolderNameInput.js +6 -0
- package/build/components/OPHolderNameInput.js.map +1 -0
- package/build/components/forms/ErrorMessage.d.ts +7 -0
- package/build/components/forms/ErrorMessage.d.ts.map +1 -0
- package/build/components/forms/ErrorMessage.js +12 -0
- package/build/components/forms/ErrorMessage.js.map +1 -0
- package/build/components/forms/FormField.d.ts +34 -0
- package/build/components/forms/FormField.d.ts.map +1 -0
- package/build/components/forms/FormField.js +33 -0
- package/build/components/forms/FormField.js.map +1 -0
- package/build/components/forms/SubmitButton.d.ts +11 -0
- package/build/components/forms/SubmitButton.d.ts.map +1 -0
- package/build/components/forms/SubmitButton.js +45 -0
- package/build/components/forms/SubmitButton.js.map +1 -0
- package/build/components/forms/Text.d.ts +7 -0
- package/build/components/forms/Text.d.ts.map +1 -0
- package/build/components/forms/Text.js +12 -0
- package/build/components/forms/Text.js.map +1 -0
- package/build/components/forms/TextInput.d.ts +30 -0
- package/build/components/forms/TextInput.d.ts.map +1 -0
- package/build/components/forms/TextInput.js +195 -0
- package/build/components/forms/TextInput.js.map +1 -0
- package/build/components/forms/index.d.ts +4 -0
- package/build/components/forms/index.d.ts.map +1 -0
- package/build/components/forms/index.js +5 -0
- package/build/components/forms/index.js.map +1 -0
- package/build/components/index.d.ts +8 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +8 -0
- package/build/components/index.js.map +1 -0
- package/build/constants/Colors.d.ts +27 -0
- package/build/constants/Colors.d.ts.map +1 -0
- package/build/constants/Colors.js +27 -0
- package/build/constants/Colors.js.map +1 -0
- package/build/constants/Styles.d.ts +9 -0
- package/build/constants/Styles.d.ts.map +1 -0
- package/build/constants/Styles.js +9 -0
- package/build/constants/Styles.js.map +1 -0
- package/build/context/FormContext.d.ts +22 -0
- package/build/context/FormContext.d.ts.map +1 -0
- package/build/context/FormContext.js +63 -0
- package/build/context/FormContext.js.map +1 -0
- package/build/context/FormThemeContext.d.ts +20 -0
- package/build/context/FormThemeContext.d.ts.map +1 -0
- package/build/context/FormThemeContext.js +21 -0
- package/build/context/FormThemeContext.js.map +1 -0
- package/build/context/index.d.ts +4 -0
- package/build/context/index.d.ts.map +1 -0
- package/build/context/index.js +3 -0
- package/build/context/index.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +18 -0
- package/build/index.js.map +1 -0
- package/build/utility/cardBranding.d.ts +2 -0
- package/build/utility/cardBranding.d.ts.map +1 -0
- package/build/utility/cardBranding.js +2 -0
- package/build/utility/cardBranding.js.map +1 -0
- package/build/utility/formatting.d.ts +4 -0
- package/build/utility/formatting.d.ts.map +1 -0
- package/build/utility/formatting.js +20 -0
- package/build/utility/formatting.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/ExpoOpenpay.podspec +30 -0
- package/ios/Frameworks/OpenpayKit.xcframework/Info.plist +40 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Headers/OpenpayKit-Swift.h +274 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Info.plist +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/Modules/module.modulemap +4 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/OpenpayKit +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/_CodeSignature/CodeResources +287 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/en.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/en.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es-MX.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es-MX.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64/OpenpayKit.framework/es.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Headers/OpenpayKit-Swift.h +544 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Info.plist +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +5179 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/OpenpayKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +127 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/Modules/module.modulemap +4 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/OpenpayKit +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/_CodeSignature/CodeResources +342 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/en.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/en.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es-MX.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es-MX.lproj/Localizable.strings +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es.lproj/CardView.nib +0 -0
- package/ios/Frameworks/OpenpayKit.xcframework/ios-arm64_x86_64-simulator/OpenpayKit.framework/es.lproj/Localizable.strings +0 -0
- package/ios/src/ExpoOpenpayModule.swift +105 -0
- package/ios/src/ExpoOpenpayView.swift +38 -0
- package/package.json +46 -0
- package/src/ExpoOpenpay.types.ts +47 -0
- package/src/ExpoOpenpayModule.ts +29 -0
- package/src/ExpoOpenpayModule.web.ts +15 -0
- package/src/ExpoOpenpayView.tsx +11 -0
- package/src/ExpoOpenpayView.web.tsx +5 -0
- package/src/assets/AmexLogo.tsx +24 -0
- package/src/assets/MCLogo.tsx +19 -0
- package/src/assets/VisaLogo.tsx +11 -0
- package/src/assets/index.ts +3 -0
- package/src/assets/photos/discover_logo.png +0 -0
- package/src/components/OPCardForm.tsx +303 -0
- package/src/components/OPCardNumberInput.tsx +126 -0
- package/src/components/OPCvv2Input.tsx +62 -0
- package/src/components/OPExpInput.tsx +74 -0
- package/src/components/OPExpMonthInput.tsx +55 -0
- package/src/components/OPExpYearInput.tsx +55 -0
- package/src/components/OPHolderNameInput.tsx +53 -0
- package/src/components/forms/ErrorMessage.tsx +19 -0
- package/src/components/forms/FormField.tsx +96 -0
- package/src/components/forms/SubmitButton.tsx +81 -0
- package/src/components/forms/Text.tsx +20 -0
- package/src/components/forms/TextInput.tsx +329 -0
- package/src/components/forms/index.ts +4 -0
- package/src/components/index.ts +7 -0
- package/src/constants/Colors.ts +26 -0
- package/src/constants/Styles.ts +9 -0
- package/src/context/FormContext.tsx +109 -0
- package/src/context/FormThemeContext.tsx +55 -0
- package/src/context/index.ts +3 -0
- package/src/index.ts +19 -0
- package/src/utility/cardBranding.ts +0 -0
- package/src/utility/formatting.ts +23 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jgallaway2011
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# expo-openpay
|
|
2
|
+
|
|
3
|
+
Expo module for integrating Openpay payments in React Native / Expo projects.
|
|
4
|
+
|
|
5
|
+
**Supports:** iOS, Android, and Expo-managed workflow.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Managed Expo Projects
|
|
12
|
+
|
|
13
|
+
If you are using the Expo-managed workflow, you can install:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install expo-openpay react-native-svg
|
|
17
|
+
# or
|
|
18
|
+
yarn add expo-openpay react-native-svg
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
react-native-svg is required to display card logos.
|
|
22
|
+
|
|
23
|
+
No additional linking is required for Expo-managed projects.
|
|
24
|
+
|
|
25
|
+
Bare React Native Projects
|
|
26
|
+
For bare React Native projects:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
Copy code
|
|
30
|
+
npm install expo-openpay react-native-svg
|
|
31
|
+
# or
|
|
32
|
+
yarn add expo-openpay react-native-svg
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
After installing, run CocoaPods for iOS:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
Copy code
|
|
39
|
+
npx pod-install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Follow any extra React Native setup for Expo modules if needed.
|
|
43
|
+
|
|
44
|
+
Usage
|
|
45
|
+
Basic Example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
Copy code
|
|
49
|
+
import ExpoOpenpay, { ExpoOpenpayView } from 'expo-openpay';
|
|
50
|
+
|
|
51
|
+
// Initialize Openpay (example)
|
|
52
|
+
ExpoOpenpay.initialize({
|
|
53
|
+
merchantId: 'YOUR_MERCHANT_ID',
|
|
54
|
+
publicKey: 'YOUR_PUBLIC_KEY',
|
|
55
|
+
production: false
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Use the component in JSX
|
|
59
|
+
export default function PaymentScreen() {
|
|
60
|
+
return (
|
|
61
|
+
<ExpoOpenpayView
|
|
62
|
+
amount={100}
|
|
63
|
+
cardType="visa"
|
|
64
|
+
onPaymentSuccess={(response) => console.log('Success', response)}
|
|
65
|
+
onPaymentError={(error) => console.log('Error', error)}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Notes
|
|
72
|
+
This module requires react-native-svg to render card logos.
|
|
73
|
+
|
|
74
|
+
Peer dependencies: react, react-native, expo, react-native-svg.
|
|
75
|
+
|
|
76
|
+
API
|
|
77
|
+
ExpoOpenpay.initialize(config) – Initialize with your Openpay keys.
|
|
78
|
+
|
|
79
|
+
ExpoOpenpayView – React component for payment UI.
|
|
80
|
+
|
|
81
|
+
Other exports from ./components and ./ExpoOpenpayModule are also available for advanced usage.
|
|
82
|
+
|
|
83
|
+
Contributing
|
|
84
|
+
Contributions are welcome! Please read the contributing guide.
|
|
85
|
+
|
|
86
|
+
License
|
|
87
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.openpay'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.openpay"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// packagingOptions {
|
|
45
|
+
// resources {
|
|
46
|
+
// excludes += [
|
|
47
|
+
// "META-INF/DEPENDENCIES",
|
|
48
|
+
// "META-INF/LICENSE",
|
|
49
|
+
// "META-INF/LICENSE.txt",
|
|
50
|
+
// "META-INF/license.txt",
|
|
51
|
+
// "META-INF/NOTICE",
|
|
52
|
+
// "META-INF/NOTICE.txt",
|
|
53
|
+
// "META-INF/notice.txt",
|
|
54
|
+
// "META-INF/ASL2.0"
|
|
55
|
+
// ]
|
|
56
|
+
// }
|
|
57
|
+
// exclude("META-INF/DEPENDENCIES")
|
|
58
|
+
// exclude("META-INF/LICENSE")
|
|
59
|
+
// exclude("META-INF/LICENSE.txt")
|
|
60
|
+
// exclude("META-INF/license.txt")
|
|
61
|
+
// exclude("META-INF/NOTICE")
|
|
62
|
+
// exclude("META-INF/NOTICE.txt")
|
|
63
|
+
// exclude("META-INF/notice.txt")
|
|
64
|
+
// exclude("META-INF/ASL2.0")
|
|
65
|
+
// exclude("META-INF/*.kotlin_module")
|
|
66
|
+
// }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
dependencies {
|
|
70
|
+
implementation 'androidx.fragment:fragment:1.6.2'
|
|
71
|
+
implementation 'com.google.http-client:google-http-client:1.43.3'
|
|
72
|
+
implementation 'com.google.http-client:google-http-client-android:1.43.3'
|
|
73
|
+
implementation 'com.google.http-client:google-http-client-jackson2:1.43.3'
|
|
74
|
+
implementation 'com.fasterxml.jackson.core:jackson-core:2.19.1'
|
|
75
|
+
implementation 'org.slf4j:slf4j-log4j12:2.0.12'
|
|
76
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
package expo.modules.openpay
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import expo.modules.kotlin.Promise
|
|
6
|
+
import java.net.URL
|
|
7
|
+
import mx.openpay.android.Openpay
|
|
8
|
+
import mx.openpay.android.OpCountry
|
|
9
|
+
import mx.openpay.android.OperationCallBack
|
|
10
|
+
import mx.openpay.android.OperationResult
|
|
11
|
+
import mx.openpay.android.exceptions.OpenpayServiceException
|
|
12
|
+
import mx.openpay.android.exceptions.ServiceUnavailableException
|
|
13
|
+
import mx.openpay.android.model.Card
|
|
14
|
+
import mx.openpay.android.model.Token
|
|
15
|
+
|
|
16
|
+
class ExpoOpenpayModule : Module() {
|
|
17
|
+
private var openpay: Openpay? = null
|
|
18
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
19
|
+
// that describes the module's functionality and behavior.
|
|
20
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
21
|
+
override fun definition() = ModuleDefinition {
|
|
22
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
23
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
24
|
+
// The module will be accessible from `requireNativeModule('ExpoOpenpay')` in JavaScript.
|
|
25
|
+
Name("Openpay")
|
|
26
|
+
|
|
27
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
28
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
29
|
+
AsyncFunction("initialize") { merchantId: String, apiKey: String, isProduction: Boolean, countryCode: String?, promise: Promise ->
|
|
30
|
+
|
|
31
|
+
if (merchantId.isEmpty() || apiKey.isEmpty()) {
|
|
32
|
+
promise.reject("OPENPAY_INVALID_PARAMS", "Merchant ID and API Key are required", Throwable("Missing parameters"))
|
|
33
|
+
return@AsyncFunction
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
val opCountry = when (countryCode?.uppercase()) {
|
|
37
|
+
"CO" -> OpCountry.COL
|
|
38
|
+
"PE" -> OpCountry.PE
|
|
39
|
+
null, "", "MX" -> OpCountry.MX
|
|
40
|
+
else -> {
|
|
41
|
+
promise.reject(
|
|
42
|
+
"OPENPAY_INVALID_COUNTRY_CODE",
|
|
43
|
+
"Invalid country code: ${countryCode?.uppercase()}. Please use 'MX', 'CO', or 'PE', or leave empty to default to 'MX'.",
|
|
44
|
+
Throwable("Invalid Country Code")
|
|
45
|
+
)
|
|
46
|
+
return@AsyncFunction
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
openpay = Openpay(merchantId, apiKey, isProduction, opCountry)
|
|
52
|
+
promise.resolve("Openpay initialized")
|
|
53
|
+
} catch (e: Exception) {
|
|
54
|
+
promise.reject("OPENPAY_INITIALIZATION_FAILED", e.message, e)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
AsyncFunction("isInitialized") { promise: Promise ->
|
|
59
|
+
promise.resolve(openpay != null)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
AsyncFunction("createDeviceSessionId") { promise: Promise ->
|
|
63
|
+
if (openpay == null) {
|
|
64
|
+
promise.reject("OPENPAY_NOT_INITIALIZED", "Openpay is not initialized", Throwable("Openpay init failed or never occured"))
|
|
65
|
+
return@AsyncFunction
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val activity = appContext.currentActivity
|
|
69
|
+
|
|
70
|
+
if (activity == null) {
|
|
71
|
+
promise.reject("NO_ACTIVITY", "Current activity is null", Throwable("No activity object"))
|
|
72
|
+
return@AsyncFunction
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
val deviceId = openpay.deviceCollectorDefaultImpl.setup(activity)
|
|
77
|
+
promise.resolve(deviceId)
|
|
78
|
+
} catch (e: Exception) {
|
|
79
|
+
promise.reject("OPENPAY_DEVICE_SESSION_ID_ERROR", e.message, e)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
AsyncFunction("tokenizeCard") { cardNumber: String, holderName: String, expirationYear: String, expirationMonth: String, cvv2: String, promise: Promise ->
|
|
84
|
+
if (openpay == null) {
|
|
85
|
+
promise.reject("OPENPAY_NOT_INITIALIZED", "Openpay is not initialized", Throwable("Openpay init failed or never occured"))
|
|
86
|
+
return@AsyncFunction
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
val card = Card().apply {
|
|
91
|
+
holderName(holderName)
|
|
92
|
+
cardNumber(cardNumber)
|
|
93
|
+
expirationMonth(expirationMonth.toInt())
|
|
94
|
+
expirationYear(expirationYear.toInt())
|
|
95
|
+
cvv2(cvv2)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
openpay.createToken(card, object: OperationCallBack<Token> {
|
|
99
|
+
override fun onSuccess(result: OperationResult<Token>) {
|
|
100
|
+
promise.resolve(result.result.id)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override fun onError(e: OpenpayServiceException) {
|
|
104
|
+
promise.reject("OPENPAY_CARD_TOKEN_ERROR", e.message, e)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun onCommunicationError(e: ServiceUnavailableException) {
|
|
108
|
+
promise.reject("OPENPAY_CARD_TOKEN_ERROR", e.message, e)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
} catch (e: Exception) {
|
|
112
|
+
promise.reject("OPENPAY_CARD_TOKEN_ERROR", e.message, e)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
117
|
+
// the view definition: Prop, Events.
|
|
118
|
+
View(ExpoOpenpayView::class) {
|
|
119
|
+
// Defines a setter for the `url` prop.
|
|
120
|
+
Prop("url") { view: ExpoOpenpayView, url: URL ->
|
|
121
|
+
view.webView.loadUrl(url.toString())
|
|
122
|
+
}
|
|
123
|
+
// Defines an event that the view can send to JavaScript.
|
|
124
|
+
Events("onLoad")
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.openpay
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class ExpoOpenpayView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
/* loaded from: BuildConfig.class */
|
|
4
|
+
public final class BuildConfig {
|
|
5
|
+
public static final boolean DEBUG = false;
|
|
6
|
+
public static final String LIBRARY_PACKAGE_NAME = "mx.openpay.android";
|
|
7
|
+
public static final String BUILD_TYPE = "release";
|
|
8
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import android.webkit.WebResourceError;
|
|
6
|
+
import android.webkit.WebResourceRequest;
|
|
7
|
+
import android.webkit.WebSettings;
|
|
8
|
+
import android.webkit.WebView;
|
|
9
|
+
import android.webkit.WebViewClient;
|
|
10
|
+
import java.util.UUID;
|
|
11
|
+
|
|
12
|
+
/* loaded from: DeviceCollectorDefaultImpl.class */
|
|
13
|
+
public class DeviceCollectorDefaultImpl {
|
|
14
|
+
private String baseUrl;
|
|
15
|
+
private String merchantId;
|
|
16
|
+
private String errorMessage;
|
|
17
|
+
private WebView webView;
|
|
18
|
+
|
|
19
|
+
public DeviceCollectorDefaultImpl(final String baseUrl, final String merchantId) {
|
|
20
|
+
this.baseUrl = baseUrl;
|
|
21
|
+
this.merchantId = merchantId;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public String setup(final Activity activity) {
|
|
25
|
+
try {
|
|
26
|
+
char[] sessionIdChars = UUID.randomUUID().toString().replace("-", "").toCharArray();
|
|
27
|
+
sessionIdChars[12] = 'A';
|
|
28
|
+
String sessionId = String.valueOf(sessionIdChars);
|
|
29
|
+
Log.i("OpenpaySDK", "buildedDeviceId: " + sessionId);
|
|
30
|
+
this.webView = new WebView(activity);
|
|
31
|
+
this.webView.setWebViewClient(new WebViewClient() { // from class: mx.openpay.android.DeviceCollectorDefaultImpl.1
|
|
32
|
+
@Override // android.webkit.WebViewClient
|
|
33
|
+
public void onPageFinished(WebView view, String url) {
|
|
34
|
+
super.onPageFinished(view, url);
|
|
35
|
+
Log.i("OpenpaySDK", "oc loaded");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override // android.webkit.WebViewClient
|
|
39
|
+
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
|
40
|
+
super.onReceivedError(view, request, error);
|
|
41
|
+
Log.i("OpenpaySDK", "page error: " + error.toString());
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
WebSettings webSettings = this.webView.getSettings();
|
|
45
|
+
webSettings.setJavaScriptEnabled(true);
|
|
46
|
+
String urlAsString = String.format("%s/oa/logo.htm?m=%s&s=%s", this.baseUrl, this.merchantId, sessionId);
|
|
47
|
+
this.webView.loadUrl(urlAsString);
|
|
48
|
+
return sessionId;
|
|
49
|
+
} catch (Exception e) {
|
|
50
|
+
System.out.println(e.getMessage());
|
|
51
|
+
e.printStackTrace();
|
|
52
|
+
logError(getClass().getName(), e.getMessage());
|
|
53
|
+
this.errorMessage = e.getMessage();
|
|
54
|
+
throw new RuntimeException(e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private void logError(final String tag, final String content) {
|
|
59
|
+
if (content.length() > 4000) {
|
|
60
|
+
Log.e(tag, content.substring(0, 4000));
|
|
61
|
+
logError(tag, content.substring(4000));
|
|
62
|
+
} else {
|
|
63
|
+
Log.e(tag, content);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public String getErrorMessage() {
|
|
68
|
+
return this.errorMessage;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.provider.Settings;
|
|
5
|
+
import android.webkit.JavascriptInterface;
|
|
6
|
+
|
|
7
|
+
/* loaded from: JavaScriptInterface.class */
|
|
8
|
+
public class JavaScriptInterface {
|
|
9
|
+
private Activity activity;
|
|
10
|
+
|
|
11
|
+
JavaScriptInterface(final Activity activity) {
|
|
12
|
+
this.activity = activity;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@JavascriptInterface
|
|
16
|
+
public String getIdentifierForVendor() {
|
|
17
|
+
return Settings.Secure.getString(this.activity.getContentResolver(), "android_id");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
/* loaded from: OpCountry.class */
|
|
4
|
+
public enum OpCountry {
|
|
5
|
+
MX("https://sandbox-api.openpay.mx", "https://api.openpay.mx"),
|
|
6
|
+
COL("https://sandbox-api.openpay.co", "https://api.openpay.co"),
|
|
7
|
+
PE("https://sandbox-api.openpay.pe", "https://api.openpay.pe");
|
|
8
|
+
|
|
9
|
+
private final String urlSandbox;
|
|
10
|
+
private final String urlProduction;
|
|
11
|
+
|
|
12
|
+
OpCountry(String urlSandbox, String urlProduction) {
|
|
13
|
+
this.urlSandbox = urlSandbox;
|
|
14
|
+
this.urlProduction = urlProduction;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected String getUrlProduction() {
|
|
18
|
+
return this.urlProduction;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected String getUrlSandbox() {
|
|
22
|
+
return this.urlSandbox;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
import mx.openpay.android.exceptions.OpenpayServiceException;
|
|
4
|
+
import mx.openpay.android.exceptions.ServiceUnavailableException;
|
|
5
|
+
|
|
6
|
+
/* loaded from: OpenPayResult.class */
|
|
7
|
+
public class OpenPayResult<T> {
|
|
8
|
+
private OpenpayServiceException openpayServiceException;
|
|
9
|
+
private OperationResult<T> operationResult;
|
|
10
|
+
private ServiceUnavailableException serviceUnavailableException;
|
|
11
|
+
|
|
12
|
+
public OpenpayServiceException getOpenpayServiceException() {
|
|
13
|
+
return this.openpayServiceException;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void setOpenpayServiceException(final OpenpayServiceException openpayServiceException) {
|
|
17
|
+
this.openpayServiceException = openpayServiceException;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public OperationResult<T> getOperationResult() {
|
|
21
|
+
return this.operationResult;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public void setOperationResult(final OperationResult<T> operationResult) {
|
|
25
|
+
this.operationResult = operationResult;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public ServiceUnavailableException getServiceUnavailableException() {
|
|
29
|
+
return this.serviceUnavailableException;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void setServiceUnavailableException(final ServiceUnavailableException serviceUnavailableException) {
|
|
33
|
+
this.serviceUnavailableException = serviceUnavailableException;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
// import android.os.AsyncTask;
|
|
4
|
+
import android.os.Handler;
|
|
5
|
+
import android.os.Looper;
|
|
6
|
+
import java.util.concurrent.Executors;
|
|
7
|
+
import java.util.concurrent.ExecutorService;
|
|
8
|
+
import mx.openpay.android.exceptions.OpenpayServiceException;
|
|
9
|
+
import mx.openpay.android.exceptions.ServiceUnavailableException;
|
|
10
|
+
import mx.openpay.android.model.Card;
|
|
11
|
+
import mx.openpay.android.model.Token;
|
|
12
|
+
import mx.openpay.android.services.ServicesFactory;
|
|
13
|
+
import mx.openpay.android.services.TokenService;
|
|
14
|
+
|
|
15
|
+
/* loaded from: Openpay.class */
|
|
16
|
+
public class Openpay {
|
|
17
|
+
private TokenService tokenService;
|
|
18
|
+
private DeviceCollectorDefaultImpl deviceCollectorDefaultImpl;
|
|
19
|
+
private final ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
20
|
+
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
21
|
+
|
|
22
|
+
public Openpay(final String merchantId, final String apiKey, final Boolean productionMode) {
|
|
23
|
+
this(merchantId, apiKey, productionMode, OpCountry.MX);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public Openpay(final String merchantId, final String apiKey, final Boolean productionMode, final OpCountry opCountry) {
|
|
27
|
+
String baseUrl = opCountry.getUrlSandbox();
|
|
28
|
+
baseUrl = productionMode.booleanValue() ? opCountry.getUrlProduction() : baseUrl;
|
|
29
|
+
ServicesFactory servicesFactory = ServicesFactory.getInstance(baseUrl, merchantId, apiKey);
|
|
30
|
+
try {
|
|
31
|
+
this.tokenService = (TokenService) servicesFactory.getService(TokenService.class);
|
|
32
|
+
} catch (NoSuchMethodException e) {
|
|
33
|
+
e.printStackTrace();
|
|
34
|
+
}
|
|
35
|
+
this.deviceCollectorDefaultImpl = new DeviceCollectorDefaultImpl(baseUrl, merchantId);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public void createToken(final Card card, final OperationCallBack<Token> operationCallBack) {
|
|
39
|
+
executor.execute(() -> {
|
|
40
|
+
OpenPayResult<Token> result = new OpenPayResult<>();
|
|
41
|
+
try {
|
|
42
|
+
Token newToken = Openpay.this.tokenService.create(card);
|
|
43
|
+
result.setOperationResult(new OperationResult<>(newToken));
|
|
44
|
+
} catch (OpenpayServiceException e) {
|
|
45
|
+
result.setOpenpayServiceException(e);
|
|
46
|
+
} catch (ServiceUnavailableException e) {
|
|
47
|
+
result.setServiceUnavailableException(e);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Post result back to the main thread
|
|
51
|
+
mainHandler.post(() -> {
|
|
52
|
+
if (result.getOperationResult() != null) {
|
|
53
|
+
operationCallBack.onSuccess(result.getOperationResult());
|
|
54
|
+
} else if (result.getOpenpayServiceException() != null) {
|
|
55
|
+
operationCallBack.onError(result.getOpenpayServiceException());
|
|
56
|
+
} else if (result.getServiceUnavailableException() != null) {
|
|
57
|
+
operationCallBack.onCommunicationError(result.getServiceUnavailableException());
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* JADX WARN: Type inference failed for: r0v0, types: [mx.openpay.android.Openpay$1] */
|
|
64
|
+
// public void createToken(final Card card, final OperationCallBack<Token> operationCallBack) {
|
|
65
|
+
// new AsyncTask<Void, Void, OpenPayResult<Token>>() { // from class: mx.openpay.android.Openpay.1
|
|
66
|
+
// /* JADX INFO: Access modifiers changed from: protected */
|
|
67
|
+
// @Override // android.os.AsyncTask
|
|
68
|
+
// public OpenPayResult<Token> doInBackground(final Void... params) {
|
|
69
|
+
// OpenPayResult<Token> openPayResult = new OpenPayResult<>();
|
|
70
|
+
// try {
|
|
71
|
+
// Token newToken = Openpay.this.tokenService.create(card);
|
|
72
|
+
// openPayResult.setOperationResult(new OperationResult<>(newToken));
|
|
73
|
+
// } catch (OpenpayServiceException e) {
|
|
74
|
+
// openPayResult.setOpenpayServiceException(e);
|
|
75
|
+
// } catch (ServiceUnavailableException e2) {
|
|
76
|
+
// openPayResult.setServiceUnavailableException(e2);
|
|
77
|
+
// }
|
|
78
|
+
// return openPayResult;
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
// /* JADX INFO: Access modifiers changed from: protected */
|
|
82
|
+
// @Override // android.os.AsyncTask
|
|
83
|
+
// public void onPostExecute(final OpenPayResult<Token> result) {
|
|
84
|
+
// if (result.getOperationResult() != null) {
|
|
85
|
+
// operationCallBack.onSuccess(result.getOperationResult());
|
|
86
|
+
// } else if (result.getOpenpayServiceException() != null) {
|
|
87
|
+
// operationCallBack.onError(result.getOpenpayServiceException());
|
|
88
|
+
// } else if (result.getServiceUnavailableException() != null) {
|
|
89
|
+
// operationCallBack.onCommunicationError(result.getServiceUnavailableException());
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
// }.execute(new Void[0]);
|
|
93
|
+
// }
|
|
94
|
+
|
|
95
|
+
public DeviceCollectorDefaultImpl getDeviceCollectorDefaultImpl() {
|
|
96
|
+
return this.deviceCollectorDefaultImpl;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
/* loaded from: OpenpayUrls.class */
|
|
4
|
+
public class OpenpayUrls {
|
|
5
|
+
protected static final String MX_URL_SANDBOX = "https://sandbox-api.openpay.mx";
|
|
6
|
+
protected static final String MX_URL_PRODUCTION = "https://api.openpay.mx";
|
|
7
|
+
protected static final String COL_URL_SANDBOX = "https://sandbox-api.openpay.co";
|
|
8
|
+
protected static final String COL_URL_PRODUCTION = "https://api.openpay.co";
|
|
9
|
+
protected static final String PE_URL_SANDBOX = "https://sandbox-api.openpay.pe";
|
|
10
|
+
protected static final String PE_URL_PRODUCTION = "https://api.openpay.pe";
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
import mx.openpay.android.exceptions.OpenpayServiceException;
|
|
4
|
+
import mx.openpay.android.exceptions.ServiceUnavailableException;
|
|
5
|
+
|
|
6
|
+
/* loaded from: OperationCallBack.class */
|
|
7
|
+
public interface OperationCallBack<T> {
|
|
8
|
+
void onError(final OpenpayServiceException error);
|
|
9
|
+
|
|
10
|
+
void onCommunicationError(final ServiceUnavailableException error);
|
|
11
|
+
|
|
12
|
+
void onSuccess(final OperationResult<T> operationResult);
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package mx.openpay.android;
|
|
2
|
+
|
|
3
|
+
/* loaded from: OperationResult.class */
|
|
4
|
+
public class OperationResult<T> {
|
|
5
|
+
private T result;
|
|
6
|
+
|
|
7
|
+
public OperationResult(final T result) {
|
|
8
|
+
this.result = result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public T getResult() {
|
|
12
|
+
return this.result;
|
|
13
|
+
}
|
|
14
|
+
}
|