iamport-react-native 1.6.4 → 2.0.0-rc.2

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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -320
  3. package/android/build.gradle +114 -24
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +1 -3
  6. package/android/src/main/java/com/iamportreactnative/IamportReactNativePackage.kt +17 -0
  7. package/android/src/main/java/com/iamportreactnative/IamportReactNativeViewManager.kt +20 -0
  8. package/iamport-react-native.podspec +19 -0
  9. package/ios/IamportReactNative-Bridging-Header.h +1 -0
  10. package/ios/IamportReactNative.xcodeproj/project.pbxproj +47 -20
  11. package/ios/IamportReactNativeViewManager.m +12 -0
  12. package/ios/IamportReactNativeViewManager.swift +32 -0
  13. package/lib/commonjs/components/Certification/index.js +154 -0
  14. package/lib/commonjs/components/Certification/index.js.map +1 -0
  15. package/lib/commonjs/components/ErrorOnParams/index.js +66 -0
  16. package/lib/commonjs/components/ErrorOnParams/index.js.map +1 -0
  17. package/lib/commonjs/components/Loading/index.js +50 -0
  18. package/lib/commonjs/components/Loading/index.js.map +1 -0
  19. package/lib/commonjs/components/Payment/index.js +288 -0
  20. package/lib/commonjs/components/Payment/index.js.map +1 -0
  21. package/lib/commonjs/constants/index.js +103 -0
  22. package/lib/commonjs/constants/index.js.map +1 -0
  23. package/{android/src/main/assets → lib/commonjs}/img/iamport-logo.png +0 -0
  24. package/lib/commonjs/index.js +36 -0
  25. package/lib/commonjs/index.js.map +1 -0
  26. package/lib/commonjs/styles.js +31 -0
  27. package/lib/commonjs/styles.js.map +1 -0
  28. package/lib/commonjs/utils/IamportUrl.js +334 -0
  29. package/lib/commonjs/utils/IamportUrl.js.map +1 -0
  30. package/lib/commonjs/utils/Validation.js +72 -0
  31. package/lib/commonjs/utils/Validation.js.map +1 -0
  32. package/lib/commonjs/utils/ValidationForPayment.js +143 -0
  33. package/lib/commonjs/utils/ValidationForPayment.js.map +1 -0
  34. package/lib/module/components/Certification/index.js +132 -0
  35. package/lib/module/components/Certification/index.js.map +1 -0
  36. package/lib/module/components/ErrorOnParams/index.js +55 -0
  37. package/lib/module/components/ErrorOnParams/index.js.map +1 -0
  38. package/lib/module/components/Loading/index.js +38 -0
  39. package/lib/module/components/Loading/index.js.map +1 -0
  40. package/lib/module/components/Payment/index.js +266 -0
  41. package/lib/module/components/Payment/index.js.map +1 -0
  42. package/lib/module/constants/index.js +98 -0
  43. package/lib/module/constants/index.js.map +1 -0
  44. package/lib/module/img/iamport-logo.png +0 -0
  45. package/lib/module/index.js +10 -0
  46. package/lib/module/index.js.map +1 -0
  47. package/lib/module/styles.js +21 -0
  48. package/lib/module/styles.js.map +1 -0
  49. package/lib/module/utils/IamportUrl.js +322 -0
  50. package/lib/module/utils/IamportUrl.js.map +1 -0
  51. package/{src → lib/module}/utils/Validation.js +25 -9
  52. package/lib/module/utils/Validation.js.map +1 -0
  53. package/{src → lib/module}/utils/ValidationForPayment.js +23 -13
  54. package/lib/module/utils/ValidationForPayment.js.map +1 -0
  55. package/lib/typescript/components/Certification/index.d.ts +10 -0
  56. package/lib/typescript/components/ErrorOnParams/index.d.ts +5 -0
  57. package/lib/typescript/components/Loading/index.d.ts +2 -0
  58. package/lib/typescript/components/Payment/index.d.ts +10 -0
  59. package/lib/typescript/constants/index.d.ts +76 -0
  60. package/lib/typescript/index.d.ts +9 -0
  61. package/lib/typescript/styles.d.ts +19 -0
  62. package/lib/typescript/utils/IamportUrl.d.ts +19 -0
  63. package/lib/typescript/utils/Validation.d.ts +58 -0
  64. package/lib/typescript/utils/ValidationForPayment.d.ts +7 -0
  65. package/package.json +98 -20
  66. package/src/components/Certification/index.tsx +112 -0
  67. package/src/components/ErrorOnParams/{index.js → index.tsx} +20 -25
  68. package/src/components/Loading/{index.js → index.tsx} +9 -10
  69. package/src/components/Payment/index.tsx +243 -0
  70. package/src/constants/index.ts +150 -0
  71. package/src/{index.js → index.tsx} +4 -1
  72. package/src/{styles.js → styles.ts} +3 -1
  73. package/src/utils/IamportUrl.ts +319 -0
  74. package/src/utils/Validation.ts +101 -0
  75. package/src/utils/ValidationForPayment.ts +146 -0
  76. package/IamportReactNative.podspec +0 -19
  77. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  78. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  79. package/android/gradlew +0 -172
  80. package/android/gradlew.bat +0 -84
  81. package/android/src/main/java/com/iamport/IamportModule.java +0 -88
  82. package/android/src/main/java/com/iamport/IamportPackage.java +0 -23
  83. package/ios/IamportReactNative.h +0 -11
  84. package/ios/IamportReactNative.m +0 -23
  85. package/ios/IamportReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  86. package/ios/IamportReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  87. package/ios/IamportReactNative.xcworkspace/contents.xcworkspacedata +0 -9
  88. package/manuals/CALLBACK.md +0 -68
  89. package/manuals/EXAMPLE.md +0 -175
  90. package/manuals/EXPO.md +0 -66
  91. package/manuals/INSTALL.md +0 -72
  92. package/manuals/SETTING.md +0 -72
  93. package/manuals/SUPPORT.md +0 -30
  94. package/manuals/TRANS.md +0 -122
  95. package/manuals/VERSION.md +0 -114
  96. package/manuals/assets/webview-peer-dependency.png +0 -0
  97. package/src/components/Certification/index.js +0 -99
  98. package/src/components/Payment/PaymentWebView.js +0 -285
  99. package/src/components/Payment/index.android.js +0 -51
  100. package/src/components/Payment/index.ios.js +0 -30
  101. package/src/constants/index.js +0 -83
  102. package/src/img/after-linking-iamport.png +0 -0
  103. package/src/img/after-linking-webview.png +0 -0
  104. package/src/img/allow-arbitrary.gif +0 -0
  105. package/src/img/android-studio-avd-manager.png +0 -0
  106. package/src/img/android-studio-build.png +0 -0
  107. package/src/img/app-scheme-registry.gif +0 -0
  108. package/src/img/expo-eject.png +0 -0
  109. package/src/img/ios-emulator-certification.png +0 -0
  110. package/src/img/ios-emulator-home.png +0 -0
  111. package/src/img/ios-emulator-payment.png +0 -0
  112. package/src/img/ios-trans-create-header-file-1.png +0 -0
  113. package/src/img/ios-trans-create-header-file-2.png +0 -0
  114. package/src/img/ios-trans-create-objectivec-file-1.png +0 -0
  115. package/src/img/ios-trans-create-objectivec-file-2.png +0 -0
  116. package/src/img/ios-trans-result.png +0 -0
  117. package/src/utils/IamportUrl.js +0 -103
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Hyukgyu Kwon
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 CHANGED
@@ -1,338 +1,43 @@
1
-
2
1
  # iamport-react-native
3
- [ ![alt text](https://img.shields.io/badge/react-v16.8.6-orange.svg?longCache=true&style=flat-square) ](https://github.com/facebook/react/)
4
- [ ![alt text](https://img.shields.io/badge/react--native-v0.59.8-yellow.svg?longCache=true&style=flat-square) ](https://github.com/facebook/react-native)
5
- [ ![alt text](https://img.shields.io/badge/query--string-v6.1.0-green.svg?longCache=true&style=flat-square) ](https://github.com/sindresorhus/query-string)
6
- [ ![alt text](https://img.shields.io/badge/react--native--webview-v7.4.2-blue.svg?longCache=true&style=flat-square) ](https://github.com/react-native-community/react-native-webview)
7
-
8
- 아임포트 리액트 네이티브 모듈입니다. 웹 페이지를 리액트 네이티브에서 웹뷰로 띄워 재사용 하는 경우, [아임포트 리액트 네이티브 웹뷰](exampleForWebView/README.md) 문서를 참고해주세요.
9
- EXPO 환경인 경우, [엑스포에서 아임포트 연동하기](manuals/EXPO.md) 문서를 참고해주세요.
2
+ [![alt text](https://img.shields.io/npm/v/iamport-react-native)](https://www.npmjs.com/package/iamport-react-native)
10
3
 
11
- ## 목차
12
- - [버전정보](manuals/VERSION.md)
13
- - [지원정보](manuals/SUPPORT.md)
14
- - [설치하기](manuals/INSTALL.md)
15
- - 설정하기
16
- - [IOS 설정하기](manuals/SETTING.md)
17
- - AndroidX 설정하기
18
- - [실시간 계좌이체 설정하기](manuals/TRANS.md)
19
- - [예제](manuals/EXAMPLE.md)
20
- - [콜백 함수 설정하기](manuals/CALLBACK.md)
4
+ 아임포트 리액트 네이티브 모듈입니다.
21
5
 
22
- ## 버전정보
23
- 최신버전은 [v1.6.4](https://github.com/iamport/iamport-react-native/tree/master)입니다. 버전 히스토리는 [버전정보](manuals/VERSION.md)를 참고하세요.
6
+ ## 버전 정보
7
+ 최신버전은 [v2.0.0-rc.2](https://github.com/iamport/iamport-react-native/tree/v2.0.0-rc.2)입니다.
8
+ 버전 히스토리는 [버전 정보](./manuals/VERSION.md)를 참고하세요.
24
9
 
25
- ## 지원정보
26
- 아임포트 리액트 네이티브 모듈은 결제 및 휴대폰 본인인증 기능을 제공합니다. 결제시 지원하는 PG사와 결제수단에 대한 자세한 정보는 [지원정보](manuals/SUPPORT.md)를 참고하세요.
10
+ ## 지원 정보
11
+ 아임포트 리액트 네이티브 모듈은 결제 및 휴대폰 본인인증 기능을 제공합니다.
12
+ 결제시 지원하는 PG사와 결제수단에 따른 자세한 정보는 [지원 정보](./manuals/SUPPORT.md)를 참고하세요.
27
13
 
28
14
  ## 설치하기
29
- 아래 명령어를 통해 아임포트 모듈을 귀하의 리액트 네이티브 프로젝트에 추가할 수 있습니다. `react-native-webview` 모듈은 아임포트 모듈에 dependent하기 때문에 반드시 함께 설치해야 하며 **10.8.3 이상의 버전이 요구**됩니다. 보다 자세한 안내는 [설치하기](manuals/INSTALL.md)를 참고하세요.
30
-
31
- ```
32
- $ npm install iamport-react-native --save
33
- ```
34
-
35
- `iamport-react-native` 는 `v10.8.3` 이상의 `react-native-webview` 를 필요로 합니다.
36
- 위 명령어대로 iamport-react-native 플러그인을 설치했을 때 다음과 같은 Warning Message 가 나온다면 기존에 설치된 `react-native-webview` 플러그인을 업데이트해주세요.
37
-
38
- ![](manuals/assets/webview-peer-dependency.png)
39
-
40
-
41
- 아래 다음 명령어를 통해 아임포트 모듈을 귀하의 안드로이드/IOS 프로젝트에 추가할 수 있습니다.
42
-
43
- ```
44
- $ npm install -g react-native-cli
45
- $ react-native link iamport-react-native
46
- $ react-native link react-native-webview
47
- ```
15
+ 아래 명령어를 통해 아임포트 모듈을 귀하의 리액트 네이티브 프로젝트에 추가할 수 있습니다.
16
+ `react-native-webview` 모듈은 아임포트 모듈에 dependent하기 때문에 반드시 함께 설치해야 하며 **10.8.3 이상의 버전이 요구**됩니다.
17
+ 보다 자세한 안내는 [설치하기](./manuals/INSTALL.md)를 참고하세요.
48
18
 
49
19
  ## 설정하기
50
- ### IOS 설정하기
51
- IOS에서 아임포트 결제연동 모듈을 사용하기 위해서는 아래 3가지 항목을 설정해주셔야 합니다. 보다 자세한 설명은 [IOS 설정하기](manuals/SETTING.md)를 참고하세요.
52
-
53
- #### 1. App Scheme 등록
54
- 외부 결제 앱(예) 페이코, 신한 판 페이)에서 결제 후 돌아올 때 사용할 URL identifier를 설정해야합니다.
55
-
56
- ![](src/img/app-scheme-registry.gif)
57
-
58
-
59
- #### 2. 외부 앱 리스트 등록
60
- 3rd party앱(예) 간편결제 앱)을 실행할 수 있도록 외부 앱 리스트를 등록해야합니다.
61
-
62
- ```html
63
- <key>LSApplicationQueriesSchemes</key>
64
- <array>
65
- <string>kftc-bankpay</string> <!-- 계좌이체 -->
66
- <string>ispmobile</string> <!-- ISP모바일 -->
67
- <string>itms-apps</string> <!-- 앱스토어 -->
68
- <string>hdcardappcardansimclick</string> <!-- 현대카드-앱카드 -->
69
- <string>smhyundaiansimclick</string> <!-- 현대카드-공인인증서 -->
70
- <string>shinhan-sr-ansimclick</string> <!-- 신한카드-앱카드 -->
71
- <string>smshinhanansimclick</string> <!-- 신한카드-공인인증서 -->
72
- <string>kb-acp</string> <!-- 국민카드-앱카드 -->
73
- <string>mpocket.online.ansimclick</string> <!-- 삼성카드-앱카드 -->
74
- <string>ansimclickscard</string> <!-- 삼성카드-온라인결제 -->
75
- <string>ansimclickipcollect</string> <!-- 삼성카드-온라인결제 -->
76
- <string>vguardstart</string> <!-- 삼성카드-백신 -->
77
- <string>samsungpay</string> <!-- 삼성카드-삼성페이 -->
78
- <string>scardcertiapp</string> <!-- 삼성카드-공인인증서 -->
79
- <string>lottesmartpay</string> <!-- 롯데카드-모바일결제 -->
80
- <string>lotteappcard</string> <!-- 롯데카드-앱카드 -->
81
- <string>cloudpay</string> <!-- 하나카드-앱카드 -->
82
- <string>nhappcardansimclick</string> <!-- 농협카드-앱카드 -->
83
- <string>nonghyupcardansimclick</string> <!-- 농협카드-공인인증서 -->
84
- <string>citispay</string> <!-- 씨티카드-앱카드 -->
85
- <string>citicardappkr</string> <!-- 씨티카드-공인인증서 -->
86
- <string>citimobileapp</string> <!-- 씨티카드-간편결제 -->
87
- <string>kakaotalk</string> <!-- 카카오톡 -->
88
- <string>payco</string> <!-- 페이코 -->
89
- <string>lpayapp</string> <!-- 롯데 L페이 -->
90
- <string>hanamopmoasign</string> <!-- 하나카드 공인인증앱 -->
91
- <string>wooripay</string> <!-- 우리페이 -->
92
- <string>nhallonepayansimclick</string> <!-- NH 올원페이 -->
93
- <string>hanawalletmembers</string> <!-- 하나카드(하나멤버스 월렛) -->
94
- </array>
95
- ```
96
-
97
-
98
- #### 3. App Transport Security 설정
20
+ ### iOS 설정하기
21
+ iOS에서 아임포트 모듈을 사용하기 위해서는 추가적인 설정이 필요합니다.
22
+ 보다 자세한 설명은 [iOS 설정하기](./manuals/SETTING.md)를 참고하세요.
99
23
 
100
- ![](src/img/allow-arbitrary.gif)
101
-
102
- ```html
103
- <key>NSAppTransportSecurity</key>
104
- <dict>
105
- <key>NSAllowsArbitraryLoadsInWebContent</key>
106
- <true/>
107
- <key>NSAllowsArbitraryLoads</key>
108
- <true/>
109
- </dict>
110
- ```
111
-
112
- ## AndroidX 설정하기
113
- AndroidX를 사용하시는 경우 추가 설정이 필요합니다. AndroidX를 사용하려면, 컴파일 SDK를 Android 9.0(API 레벨 28)이상으로 설정하고 android/gradle.properties 파일에 아래 두 Android Gradle 플러그인 플래그를 `true`로 설정해야 합니다.
114
-
115
- ```
116
- // android/gradle.properties
117
- android.useAndroidX=true
118
- android.enableJetifier=true
119
- ```
120
-
121
- iamport-react-native 모듈은 네이티브 코드를 포함하기 때문에 이 또한 AndroidX로 변형해야 합니다. 이를 위해 [jetifier](https://github.com/mikehardy/jetifier)를 사용합니다. jetifier는 리액트 네이티브 버전 0.60 이상에서는 자동으로 포함되어 있기 때문에 0.59 이하 버전을 사용하는 경우에만 아래 코드를 실행해주세요.
122
-
123
- ```
124
- npm install --save-dev jetifier
125
- npx jetifier
126
- ```
24
+ ### Expo 설정하기
25
+ Expo 프로젝트에서 아임포트 모듈을 사용하기 위해서는 추가적인 설정이 필요합니다.
26
+ 보다 자세한 설명은 [Expo에서 아임포트 연동하기](./manuals/EXPO.md)를 참고하세요.
127
27
 
128
28
  ### 실시간 계좌이체 설정하기
129
- 웹 표준 이니시스와 나이스 정보통신은 뱅크페이 앱을 통해 실시간 계좌이체를 진행합니다. 뱅크페이에서 결제 인증 후 본래의 앱으로 복귀 해 다음단계로 진행을 하려면 별도 설정이 요구됩니다. 자세한 내용은 [실시간 계좌이체 설정하기](manuals/TRANS.md)를 참고해주세요.
130
-
29
+ 웹 표준 이니시스와 나이스 정보통신은 뱅크페이 앱을 통해 실시간 계좌이체를 진행합니다.
30
+ 뱅크페이에서 결제 인증 후 본래의 앱으로 복귀 해 다음단계로 진행을 하려면 별도 설정이 요구됩니다.
31
+ 자세한 내용은 [실시간 계좌이체 설정하기](./manuals/TRANS.md)를 참고하세요.
131
32
 
132
33
  ## 예제
133
- 아임포트 결제연동 모듈을 사용해 아래와 같이 일반/정기결제 및 휴대폰 본인인증 기능을 구현할 수 있습니다. 필요한 파라미터는 [예제](manuals/EXAMPLE.md)를 참고하세요.
134
-
135
- #### 일반/정기결제 예제
136
-
137
- ##### JavaScript
138
-
139
- ```javascript
140
- import React from 'react';
141
- /* 아임포트 모듈을 불러옵니다. */
142
- import IMP from 'iamport-react-native';
143
-
144
- /* 로딩 컴포넌트를 불러옵니다. */
145
- import Loading from './Loading';
146
-
147
- export function Payment({ navigation }) {
148
- /* [필수입력] 결제 종료 후, 라우터를 변경하고 결과를 전달합니다. */
149
- function callback(response) {
150
- navigation.replace('PaymentResult', response);
151
- }
152
-
153
- /* [필수입력] 결제에 필요한 데이터를 입력합니다. */
154
- const data = {
155
- pg: 'html5_inicis',
156
- pay_method: 'card',
157
- name: '아임포트 결제데이터 분석',
158
- merchant_uid: `mid_${new Date().getTime()}`,
159
- amount: '39000',
160
- buyer_name: '홍길동',
161
- buyer_tel: '01012345678',
162
- buyer_email: 'example@naver.com',
163
- buyer_addr: '서울시 강남구 신사동 661-16',
164
- buyer_postcode: '06018',
165
- app_scheme: 'example',
166
- // [Deprecated v1.0.3]: m_redirect_url
167
- };
168
-
169
- return (
170
- <IMP.Payment
171
- userCode={'iamport'} // 가맹점 식별코드
172
- tierCode={'AAA'} // 티어 코드: agency 기능 사용자에 한함
173
- loading={<Loading />} // 웹뷰 로딩 컴포넌트
174
- data={data} // 결제 데이터
175
- callback={callback} // 결제 종료 후 콜백
176
- />
177
- );
178
- }
179
-
180
- export default Payment;
181
- ```
182
-
183
- ##### TypeScript
184
-
185
- ```javascript
186
- import React from 'react';
187
- /* 아임포트 모듈을 불러옵니다. */
188
- import IMP from 'iamport-react-native';
189
-
190
- /* 로딩 컴포넌트를 불러옵니다. */
191
- import Loading from './Loading';
192
-
193
- export function IamportPayment() {
194
- function callback(response) {
195
- // navigation 을 이용해 결과 렌더링 Component로 이동
196
- }
197
-
198
- /* [필수입력] 결제에 필요한 데이터를 생성합니다. */
199
- const data = {
200
- pg: 'html5_inicis',
201
- pay_method: 'card',
202
- name: '아임포트 결제데이터 분석',
203
- merchant_uid: `mid_${new Date().getTime()}`,
204
- amount: '39000',
205
- buyer_name: '홍길동',
206
- buyer_tel: '01012345678',
207
- buyer_email: 'example@naver.com',
208
- buyer_addr: '서울시 강남구 신사동 661-16',
209
- buyer_postcode: '06018',
210
- app_scheme: 'example',
211
- // [Deprecated v1.0.3]: m_redirect_url
212
- };
213
-
214
- return (
215
- <IMP.Payment
216
- userCode={'iamport'} // 가맹점 식별코드
217
- tierCode={'AAA'} // 티어 코드: agency 기능 사용자에 한함
218
- loading={<Loading />} // 웹뷰 로딩 컴포넌트
219
- data={data} // 결제 데이터
220
- callback={callback} // 결제 종료 후 콜백
221
- />
222
- );
223
- }
224
-
225
- export default IamportPayment;
226
- ```
227
-
228
-
229
- #### 휴대폰 본인인증 예제
230
-
231
- ##### JavaScript
232
-
233
- ```javascript
234
- import React from 'react';
235
- /* 아임포트 모듈을 불러옵니다. */
236
- import IMP from 'iamport-react-native';
237
- /* 로딩 컴포넌트를 불러옵니다. */
238
- import Loading from './Loading';
239
-
240
- export function Certification({ navigation }) {
241
- /* [필수입력] 본인인증 종료 후, 라우터를 변경하고 결과를 전달합니다. */
242
- function callback(response) {
243
- navigation.replace('CertificationResult', response);
244
- }
245
-
246
- /* [필수입력] 본인인증에 필요한 데이터를 입력합니다. */
247
- const data = {
248
- merchant_uid: `mid_${new Date().getTime()}`,
249
- company: '아임포트',
250
- carrier: 'SKT',
251
- name: '홍길동',
252
- phone: '01012341234',
253
- min_age: '',
254
- };
255
-
256
- return (
257
- <IMP.Certification
258
- userCode={'iamport'} // 가맹점 식별코드
259
- tierCode={'AAA'} // 티어 코드: agency 기능 사용자에 한함
260
- loading={<Loading />} // 웹뷰 로딩 컴포넌트
261
- data={data} // 본인인증 데이터
262
- callback={callback} // 본인인증 종료 후 콜백
263
- />
264
- );
265
- }
266
-
267
- export default Certification;
268
- ```
269
-
270
- ##### TypeScript
271
-
272
- ```javascript
273
- import React from 'react';
274
- /* 아임포트 모듈을 불러옵니다. */
275
- import IMP from 'iamport-react-native';
276
-
277
- /* 로딩 컴포넌트를 불러옵니다. */
278
- import Loading from './Loading';
279
-
280
- export function IamportCertification() {
281
- function callback(response) {
282
- // navigation 을 이용해 결과 렌더링 Component로 이동
283
- }
284
-
285
- /* [필수입력] 본인인증에 필요한 데이터를 생성합니다. */
286
- const data = {
287
- merchant_uid: `mid_${new Date().getTime()}`,
288
- company: '아임포트',
289
- carrier: 'SKT',
290
- name: '홍길동',
291
- phone: '01012341234',
292
- min_age: 19,
293
- };
294
-
295
- return (
296
- <IMP.Certification
297
- userCode={'iamport'} // 가맹점 식별코드
298
- tierCode={'AAA'} // 티어 코드: agency 기능 사용자에 한함
299
- loading={<Loading />} // 웹뷰 로딩 컴포넌트
300
- data={data} // 본인인증 데이터
301
- callback={callback} // 본인인증 종료 후 콜백
302
- />
303
- );
304
- }
305
-
306
- export default IamportCertification;
307
- ```
308
-
309
- #### 웹뷰 로딩 컴포넌트 예제
310
- ```javascript
311
- import React from 'react';
312
- import { View, Text, StyleSheet } from 'react-native';
313
-
314
- export function Loading() {
315
- const { container } = styles;
316
- return (
317
- <View style={container}>
318
- <Text>잠시만 기다려주세요...</Text>
319
- </View>
320
- );
321
- }
322
-
323
- const styles = StyleSheet.create({
324
- container: {
325
- ...StyleSheet.absoluteFillObject,
326
- },
327
- });
328
-
329
- export default Loading;
330
- ```
34
+ 아임포트 결제연동 모듈을 사용해 아래와 같이 일반/정기결제 및 휴대폰 본인인증 기능을 구현할 수 있습니다.
35
+ 현재 구현된 예제들에 대한 설명 및 라이브러리 사용에 필요한 파라미터는 [예제](./manuals/EXAMPLE.md)를 참고하세요.
331
36
 
332
37
  ## 콜백 함수 설정하기
333
- 콜백 함수는 필수입력 필드로, 결제/본인인증 완료 후 라우트 이동을 위해 아래와 같이 로직을 작성할 수 있습니다. 콜백 함수에 대한 자세한 설명은 [콜백 설정하기](manuals/CALLBACK.md)를 참고하세요.
334
-
335
- ```javascript
38
+ 콜백 함수는 필수입력 필드로, 결제/본인인증 완료 후 routing을 통한 이동을 위해 아래와 같이 로직을 작성할 수 있습니다.
39
+ 콜백 함수에 대한 자세한 설명은 [콜백 설정하기](./manuals/CALLBACK.md)를 참고하세요.
40
+ ```js
336
41
  function callback(response) {
337
42
  navigation.replace('Result', response);
338
43
  }
@@ -1,40 +1,130 @@
1
-
2
1
  buildscript {
3
- repositories {
4
- jcenter()
5
- }
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['IamportReactNative_kotlinVersion']
6
4
 
7
- dependencies {
8
- classpath 'com.android.tools.build:gradle:1.3.1'
9
- }
10
- }
5
+ repositories {
6
+ google()
7
+ jcenter()
8
+ }
11
9
 
12
- def getExtOrDefault(name, fallback) {
13
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : fallback
10
+ dependencies {
11
+ classpath 'com.android.tools.build:gradle:3.2.1'
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
14
15
  }
15
16
 
16
17
  apply plugin: 'com.android.library'
18
+ apply plugin: 'kotlin-android'
19
+
20
+ def getExtOrDefault(name) {
21
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['IamportReactNative_' + name]
22
+ }
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['IamportReactNative_' + name]).toInteger()
26
+ }
17
27
 
18
28
  android {
19
- compileSdkVersion getExtOrDefault('compileSdkVersion', 26)
20
- buildToolsVersion getExtOrDefault('buildToolsVersion', "26.0.3")
21
-
22
- defaultConfig {
23
- minSdkVersion 16
24
- targetSdkVersion getExtOrDefault('targetSdkVersion', 22)
25
- versionCode 1
26
- versionName "1.0"
27
- }
28
- lintOptions {
29
- abortOnError false
29
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
30
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
31
+ defaultConfig {
32
+ minSdkVersion 16
33
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
34
+ versionCode 1
35
+ versionName "1.0"
36
+
37
+ }
38
+
39
+ buildTypes {
40
+ release {
41
+ minifyEnabled false
30
42
  }
43
+ }
44
+ lintOptions {
45
+ disable 'GradleCompatible'
46
+ }
47
+ compileOptions {
48
+ sourceCompatibility JavaVersion.VERSION_1_8
49
+ targetCompatibility JavaVersion.VERSION_1_8
50
+ }
31
51
  }
32
52
 
33
53
  repositories {
34
- mavenCentral()
54
+ mavenCentral()
55
+ jcenter()
56
+ google()
57
+
58
+ def found = false
59
+ def defaultDir = null
60
+ def androidSourcesName = 'React Native sources'
61
+
62
+ if (rootProject.ext.has('reactNativeAndroidRoot')) {
63
+ defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
64
+ } else {
65
+ defaultDir = new File(
66
+ projectDir,
67
+ '/../../../node_modules/react-native/android'
68
+ )
69
+ }
70
+
71
+ if (defaultDir.exists()) {
72
+ maven {
73
+ url defaultDir.toString()
74
+ name androidSourcesName
75
+ }
76
+
77
+ logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
78
+ found = true
79
+ } else {
80
+ def parentDir = rootProject.projectDir
81
+
82
+ 1.upto(5, {
83
+ if (found) return true
84
+ parentDir = parentDir.parentFile
85
+
86
+ def androidSourcesDir = new File(
87
+ parentDir,
88
+ 'node_modules/react-native'
89
+ )
90
+
91
+ def androidPrebuiltBinaryDir = new File(
92
+ parentDir,
93
+ 'node_modules/react-native/android'
94
+ )
95
+
96
+ if (androidPrebuiltBinaryDir.exists()) {
97
+ maven {
98
+ url androidPrebuiltBinaryDir.toString()
99
+ name androidSourcesName
100
+ }
101
+
102
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
103
+ found = true
104
+ } else if (androidSourcesDir.exists()) {
105
+ maven {
106
+ url androidSourcesDir.toString()
107
+ name androidSourcesName
108
+ }
109
+
110
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
111
+ found = true
112
+ }
113
+ })
114
+ }
115
+
116
+ if (!found) {
117
+ throw new GradleException(
118
+ "${project.name}: unable to locate React Native android sources. " +
119
+ "Ensure you have you installed React Native as a dependency in your project and try again."
120
+ )
121
+ }
35
122
  }
36
123
 
124
+ def kotlin_version = getExtOrDefault('kotlinVersion')
125
+
37
126
  dependencies {
38
- implementation 'com.facebook.react:react-native:+'
127
+ // noinspection GradleDynamicVersion
128
+ api 'com.facebook.react:react-native:+'
129
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.31"
39
130
  }
40
-
@@ -0,0 +1,4 @@
1
+ IamportReactNative_kotlinVersion=1.3.50
2
+ IamportReactNative_compileSdkVersion=29
3
+ IamportReactNative_buildToolsVersion=29.0.2
4
+ IamportReactNative_targetSdkVersion=29
@@ -1,6 +1,4 @@
1
-
2
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.iamport">
2
+ package="com.iamportreactnative">
4
3
 
5
4
  </manifest>
6
-
@@ -0,0 +1,17 @@
1
+ package com.iamportreactnative
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class IamportReactNativePackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return emptyList()
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return listOf(IamportReactNativeViewManager())
16
+ }
17
+ }
@@ -0,0 +1,20 @@
1
+ package com.iamportreactnative
2
+
3
+ import android.graphics.Color
4
+ import android.view.View
5
+ import com.facebook.react.uimanager.SimpleViewManager
6
+ import com.facebook.react.uimanager.ThemedReactContext
7
+ import com.facebook.react.uimanager.annotations.ReactProp
8
+
9
+ class IamportReactNativeViewManager : SimpleViewManager<View>() {
10
+ override fun getName() = "IamportReactNativeView"
11
+
12
+ override fun createViewInstance(reactContext: ThemedReactContext): View {
13
+ return View(reactContext)
14
+ }
15
+
16
+ @ReactProp(name = "color")
17
+ fun setColor(view: View, color: String) {
18
+ view.setBackgroundColor(Color.parseColor(color))
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "iamport-react-native"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "10.0" }
14
+ s.source = { :git => "https://github.com/iamport/iamport-react-native.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+
18
+ s.dependency "React-Core"
19
+ end
@@ -0,0 +1 @@
1
+ #import <React/RCTViewManager.h>