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.
- package/LICENSE +21 -0
- package/README.md +25 -320
- package/android/build.gradle +114 -24
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/iamportreactnative/IamportReactNativePackage.kt +17 -0
- package/android/src/main/java/com/iamportreactnative/IamportReactNativeViewManager.kt +20 -0
- package/iamport-react-native.podspec +19 -0
- package/ios/IamportReactNative-Bridging-Header.h +1 -0
- package/ios/IamportReactNative.xcodeproj/project.pbxproj +47 -20
- package/ios/IamportReactNativeViewManager.m +12 -0
- package/ios/IamportReactNativeViewManager.swift +32 -0
- package/lib/commonjs/components/Certification/index.js +154 -0
- package/lib/commonjs/components/Certification/index.js.map +1 -0
- package/lib/commonjs/components/ErrorOnParams/index.js +66 -0
- package/lib/commonjs/components/ErrorOnParams/index.js.map +1 -0
- package/lib/commonjs/components/Loading/index.js +50 -0
- package/lib/commonjs/components/Loading/index.js.map +1 -0
- package/lib/commonjs/components/Payment/index.js +288 -0
- package/lib/commonjs/components/Payment/index.js.map +1 -0
- package/lib/commonjs/constants/index.js +103 -0
- package/lib/commonjs/constants/index.js.map +1 -0
- package/{android/src/main/assets → lib/commonjs}/img/iamport-logo.png +0 -0
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/styles.js +31 -0
- package/lib/commonjs/styles.js.map +1 -0
- package/lib/commonjs/utils/IamportUrl.js +334 -0
- package/lib/commonjs/utils/IamportUrl.js.map +1 -0
- package/lib/commonjs/utils/Validation.js +72 -0
- package/lib/commonjs/utils/Validation.js.map +1 -0
- package/lib/commonjs/utils/ValidationForPayment.js +143 -0
- package/lib/commonjs/utils/ValidationForPayment.js.map +1 -0
- package/lib/module/components/Certification/index.js +132 -0
- package/lib/module/components/Certification/index.js.map +1 -0
- package/lib/module/components/ErrorOnParams/index.js +55 -0
- package/lib/module/components/ErrorOnParams/index.js.map +1 -0
- package/lib/module/components/Loading/index.js +38 -0
- package/lib/module/components/Loading/index.js.map +1 -0
- package/lib/module/components/Payment/index.js +266 -0
- package/lib/module/components/Payment/index.js.map +1 -0
- package/lib/module/constants/index.js +98 -0
- package/lib/module/constants/index.js.map +1 -0
- package/lib/module/img/iamport-logo.png +0 -0
- package/lib/module/index.js +10 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/styles.js +21 -0
- package/lib/module/styles.js.map +1 -0
- package/lib/module/utils/IamportUrl.js +322 -0
- package/lib/module/utils/IamportUrl.js.map +1 -0
- package/{src → lib/module}/utils/Validation.js +25 -9
- package/lib/module/utils/Validation.js.map +1 -0
- package/{src → lib/module}/utils/ValidationForPayment.js +23 -13
- package/lib/module/utils/ValidationForPayment.js.map +1 -0
- package/lib/typescript/components/Certification/index.d.ts +10 -0
- package/lib/typescript/components/ErrorOnParams/index.d.ts +5 -0
- package/lib/typescript/components/Loading/index.d.ts +2 -0
- package/lib/typescript/components/Payment/index.d.ts +10 -0
- package/lib/typescript/constants/index.d.ts +76 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/styles.d.ts +19 -0
- package/lib/typescript/utils/IamportUrl.d.ts +19 -0
- package/lib/typescript/utils/Validation.d.ts +58 -0
- package/lib/typescript/utils/ValidationForPayment.d.ts +7 -0
- package/package.json +98 -20
- package/src/components/Certification/index.tsx +112 -0
- package/src/components/ErrorOnParams/{index.js → index.tsx} +20 -25
- package/src/components/Loading/{index.js → index.tsx} +9 -10
- package/src/components/Payment/index.tsx +243 -0
- package/src/constants/index.ts +150 -0
- package/src/{index.js → index.tsx} +4 -1
- package/src/{styles.js → styles.ts} +3 -1
- package/src/utils/IamportUrl.ts +319 -0
- package/src/utils/Validation.ts +101 -0
- package/src/utils/ValidationForPayment.ts +146 -0
- package/IamportReactNative.podspec +0 -19
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradlew +0 -172
- package/android/gradlew.bat +0 -84
- package/android/src/main/java/com/iamport/IamportModule.java +0 -88
- package/android/src/main/java/com/iamport/IamportPackage.java +0 -23
- package/ios/IamportReactNative.h +0 -11
- package/ios/IamportReactNative.m +0 -23
- package/ios/IamportReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/IamportReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/IamportReactNative.xcworkspace/contents.xcworkspacedata +0 -9
- package/manuals/CALLBACK.md +0 -68
- package/manuals/EXAMPLE.md +0 -175
- package/manuals/EXPO.md +0 -66
- package/manuals/INSTALL.md +0 -72
- package/manuals/SETTING.md +0 -72
- package/manuals/SUPPORT.md +0 -30
- package/manuals/TRANS.md +0 -122
- package/manuals/VERSION.md +0 -114
- package/manuals/assets/webview-peer-dependency.png +0 -0
- package/src/components/Certification/index.js +0 -99
- package/src/components/Payment/PaymentWebView.js +0 -285
- package/src/components/Payment/index.android.js +0 -51
- package/src/components/Payment/index.ios.js +0 -30
- package/src/constants/index.js +0 -83
- package/src/img/after-linking-iamport.png +0 -0
- package/src/img/after-linking-webview.png +0 -0
- package/src/img/allow-arbitrary.gif +0 -0
- package/src/img/android-studio-avd-manager.png +0 -0
- package/src/img/android-studio-build.png +0 -0
- package/src/img/app-scheme-registry.gif +0 -0
- package/src/img/expo-eject.png +0 -0
- package/src/img/ios-emulator-certification.png +0 -0
- package/src/img/ios-emulator-home.png +0 -0
- package/src/img/ios-emulator-payment.png +0 -0
- package/src/img/ios-trans-create-header-file-1.png +0 -0
- package/src/img/ios-trans-create-header-file-2.png +0 -0
- package/src/img/ios-trans-create-objectivec-file-1.png +0 -0
- package/src/img/ios-trans-create-objectivec-file-2.png +0 -0
- package/src/img/ios-trans-result.png +0 -0
- package/src/utils/IamportUrl.js +0 -103
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { WebView } from 'react-native-webview';
|
|
5
|
-
import { View, Linking, Platform, NativeModules } from 'react-native';
|
|
6
|
-
|
|
7
|
-
import Loading from '../Loading';
|
|
8
|
-
import ErrorOnParams from '../ErrorOnParams';
|
|
9
|
-
|
|
10
|
-
import IamportUrl from '../../utils/IamportUrl.js';
|
|
11
|
-
import ValidationForPayment from '../../utils/ValidationForPayment.js';
|
|
12
|
-
import { viewStyles } from '../../styles';
|
|
13
|
-
import {
|
|
14
|
-
PAY_METHOD,
|
|
15
|
-
CURRENCY,
|
|
16
|
-
WEBVIEW_SOURCE_HTML,
|
|
17
|
-
SMILEPAY_URL,
|
|
18
|
-
} from '../../constants';
|
|
19
|
-
|
|
20
|
-
const { RNCWebView } = NativeModules;
|
|
21
|
-
|
|
22
|
-
export function PaymentWebView({
|
|
23
|
-
userCode,
|
|
24
|
-
tierCode,
|
|
25
|
-
data,
|
|
26
|
-
loading,
|
|
27
|
-
callback,
|
|
28
|
-
open3rdPartyApp,
|
|
29
|
-
}) {
|
|
30
|
-
const [webviewSource, setWebviewSource] = useState({ html: WEBVIEW_SOURCE_HTML });
|
|
31
|
-
const [isWebViewLoaded, setIsWebViewLoaded] = useState(false);
|
|
32
|
-
const [showLoading, setShowLoading] = useState(true);
|
|
33
|
-
const [isInicisTransPaid, setIsInicisTransPaid] = useState(false);
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const { pg } = data;
|
|
37
|
-
if (pg.startsWith('smilepay') && Platform.OS === 'ios') {
|
|
38
|
-
/**
|
|
39
|
-
* [feature/smilepay] IOS - 스마일페이 대비 코드 작성
|
|
40
|
-
* 스마일페이 결제창을 iframe 방식으로 띄우기 때문에 WKWebView에서 서드 파티 쿠키가 허용되지 않아
|
|
41
|
-
* WKWebView의 baseUrl을 강제로 스마일페이 URL로 적용
|
|
42
|
-
*/
|
|
43
|
-
setWebviewSource({ ...webviewSource, baseUrl: SMILEPAY_URL });
|
|
44
|
-
}
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
function handleOpenURL(event) {
|
|
49
|
-
const { pg, pay_method } = data;
|
|
50
|
-
if (pay_method === 'trans') {
|
|
51
|
-
const { url } = event;
|
|
52
|
-
const iamportUrl = new IamportUrl(url);
|
|
53
|
-
/**
|
|
54
|
-
* [IOS] 웹 표준 이니시스 - 실시간 계좌이체 대비
|
|
55
|
-
* 아래 로직대로 동작해야 최종적으로 결제가 승인된 후 콜백 함수가 호출됨
|
|
56
|
-
* 1. 사파리 앱에서 복귀(app_scheme://imp_uid=%26merchant_uid=%26m_redirect_url=)
|
|
57
|
-
* 2. 최종 결제 승인을 위해 이니시스가 HTTP 리퀘스트 호출
|
|
58
|
-
* 3. "다음" 버튼이 있는 최종 화면으로 이동
|
|
59
|
-
* 4. "다음" 버튼을 클릭
|
|
60
|
-
* 5. 1번과 마찬가지로 app_scheme://imp_uid=%26merchant_uid=%26m_redirect_url=로 HTTP 리퀘스트 호출
|
|
61
|
-
* 6. 콜백 함수 호출
|
|
62
|
-
* 따라서 현재 handleOpenURL이 트리거 되는 사유가 1번 때문인지 5번 때문인지 구분이 필요하여
|
|
63
|
-
* 이를 위한 isInicisTransPaid 플래그 추가
|
|
64
|
-
*/
|
|
65
|
-
if (pg.startsWith('html5_inicis') && Platform.OS === 'ios') {
|
|
66
|
-
if (isInicisTransPaid) {
|
|
67
|
-
this.xdm.injectJavaScript(`
|
|
68
|
-
window.location.href = "${IamportUrl.M_REDIRECT_URL}?${iamportUrl.getInicisTransQuery()}";
|
|
69
|
-
`);
|
|
70
|
-
} else {
|
|
71
|
-
setIsInicisTransPaid(true);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/* 나이스 - 실시간 계좌이체 대비 */
|
|
76
|
-
if (pg.startsWith('nice')) {
|
|
77
|
-
this.xdm.injectJavaScript(`
|
|
78
|
-
window.location.href = "${IamportUrl.NICE_TRANS_URL}?${iamportUrl.getStringifiedQuery()}";
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
Linking.addEventListener('url', handleOpenURL);
|
|
84
|
-
|
|
85
|
-
return function cleanup() {
|
|
86
|
-
Linking.removeEventListener('url', handleOpenURL);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
function onLoadEnd() {
|
|
91
|
-
if (!isWebViewLoaded) {
|
|
92
|
-
// html이 load되고 최초 한번만 inject javascript
|
|
93
|
-
data.m_redirect_url = IamportUrl.M_REDIRECT_URL;
|
|
94
|
-
if (data.pg === 'eximbay') {
|
|
95
|
-
data.popup = false;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (tierCode) {
|
|
99
|
-
this.xdm.injectJavaScript(`
|
|
100
|
-
setTimeout(function() { IMP.agency("${userCode}", "${tierCode}"); });
|
|
101
|
-
`);
|
|
102
|
-
} else {
|
|
103
|
-
this.xdm.injectJavaScript(`
|
|
104
|
-
setTimeout(function() { IMP.init("${userCode}"); });
|
|
105
|
-
`);
|
|
106
|
-
}
|
|
107
|
-
this.xdm.injectJavaScript(`
|
|
108
|
-
setTimeout(function() {
|
|
109
|
-
IMP.request_pay(${JSON.stringify(data)}, function(response) {
|
|
110
|
-
window.ReactNativeWebView.postMessage(JSON.stringify(response));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
`);
|
|
114
|
-
setIsWebViewLoaded(true);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// only for Android
|
|
118
|
-
if (removeLoadingNeeded()) {
|
|
119
|
-
setShowLoading(false);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function removeLoadingNeeded() {
|
|
124
|
-
const isAndroid = Platform.OS === 'android';
|
|
125
|
-
if (showLoading && isAndroid) {
|
|
126
|
-
// 로딩상태. 안드로이드 플랫폼
|
|
127
|
-
if (isWebViewLoaded) {
|
|
128
|
-
// 웹뷰 로드 끝. 리디렉션 방식
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
// 웹뷰 로드 중. iframe 방식
|
|
132
|
-
return isIframeWayPayment();
|
|
133
|
-
}
|
|
134
|
-
// IOS
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function isIframeWayPayment() {
|
|
139
|
-
const { pg, pay_method, customer_uid } = data;
|
|
140
|
-
if (pg.startsWith('html5_inicis') && customer_uid) {
|
|
141
|
-
// 이니시스 빌링결제
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
if (pg.startsWith('mobilians') && pay_method === 'phone') {
|
|
145
|
-
// 모빌리언스 휴대폰 소액결제
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
if (
|
|
149
|
-
pg.startsWith('danal') || // 다날 일반결제
|
|
150
|
-
pg.startsWith('danal_tpay') || // 다날 휴대폰 소액결제
|
|
151
|
-
pg.startsWith('smilepay') || // 스마일페이
|
|
152
|
-
pg.startsWith('payco') || // 페이코
|
|
153
|
-
pg.startsWith('bluewalnut') // 블루월넛
|
|
154
|
-
) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/* PG사가 callback을 지원하는 경우, 결제결과를 받아 callback을 실행한다 */
|
|
161
|
-
function onMessage(e) {
|
|
162
|
-
const { data } = e.nativeEvent;
|
|
163
|
-
/**
|
|
164
|
-
* [v1.6.0] 다날의 경우 response에 주문명(name)이 포함되어 있는데
|
|
165
|
-
* 주문명에 %가 들어갈 경우, decodeURIComponent시 URI malformed 에러가 발생하는 것 대비해
|
|
166
|
-
* 우선 encodeURIComponent를 한 후, decodeURIComponent가 끝나면
|
|
167
|
-
* 최종적으로 decodeURIComponent를 한 번 더 한다
|
|
168
|
-
*/
|
|
169
|
-
let response = encodeURIComponent(data);
|
|
170
|
-
while(decodeURIComponent(response) !== data) {
|
|
171
|
-
response = decodeURIComponent(response);
|
|
172
|
-
}
|
|
173
|
-
response = decodeURIComponent(response);
|
|
174
|
-
response = JSON.parse(response);
|
|
175
|
-
callback(response);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function onShouldStartLoadWithRequest(request) {
|
|
179
|
-
const { url, lockIdentifier } = request;
|
|
180
|
-
const iamportUrl = new IamportUrl(url);
|
|
181
|
-
if (iamportUrl.isAppUrl()) {
|
|
182
|
-
if (lockIdentifier === 0 /* && react-native-webview 버전이 v10.8.3 이상 */) {
|
|
183
|
-
/**
|
|
184
|
-
* [feature/react-native-webview] 웹뷰 첫 렌더링시 lockIdentifier === 0
|
|
185
|
-
* 이때 무조건 onShouldStartLoadWithRequest를 true 처리하기 때문에
|
|
186
|
-
* Error Loading Page 에러가 발생하므로
|
|
187
|
-
* 강제로 lockIdentifier를 1로 변환시키도록 아래 네이티브 코드 호출
|
|
188
|
-
*/
|
|
189
|
-
RNCWebView.onShouldStartLoadWithRequestCallback(false, lockIdentifier);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/* 3rd-party 앱 오픈 */
|
|
193
|
-
open3rdPartyApp(iamportUrl);
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
if (iamportUrl.isPaymentOver()) {
|
|
197
|
-
callback(iamportUrl.getQuery());
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
if (isWebViewLoaded && showLoading && iamportUrl.isIframeLoaded()) {
|
|
201
|
-
/**
|
|
202
|
-
* only for IOS
|
|
203
|
-
* iframe이 load되면(url이 about:blank 또는 https://service.iamport.kr이 아니면)
|
|
204
|
-
* webview의 loading 상태를 해제한다
|
|
205
|
-
*/
|
|
206
|
-
setShowLoading(false);
|
|
207
|
-
}
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const validation = new ValidationForPayment(userCode, loading, callback, data);
|
|
212
|
-
if (validation.getIsValid()) {
|
|
213
|
-
const { wrapper, loadingContainer, webViewContainer } = viewStyles;
|
|
214
|
-
return (
|
|
215
|
-
<View style={wrapper}>
|
|
216
|
-
<View style={webViewContainer}>
|
|
217
|
-
<WebView
|
|
218
|
-
ref={(xdm) => this.xdm = xdm}
|
|
219
|
-
useWebKit
|
|
220
|
-
source={webviewSource}
|
|
221
|
-
onLoadEnd={onLoadEnd}
|
|
222
|
-
onMessage={onMessage}
|
|
223
|
-
originWhitelist={['*']} // https://github.com/facebook/react-native/issues/19986
|
|
224
|
-
sharedCookiesEnabled
|
|
225
|
-
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
226
|
-
/>
|
|
227
|
-
</View>
|
|
228
|
-
{
|
|
229
|
-
showLoading &&
|
|
230
|
-
<View style={loadingContainer}>
|
|
231
|
-
{loading || <Loading />}
|
|
232
|
-
</View>
|
|
233
|
-
}
|
|
234
|
-
</View>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return <ErrorOnParams message={validation.getMessage()} />;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
PaymentWebView.propTypes = {
|
|
242
|
-
userCode: PropTypes.string.isRequired,
|
|
243
|
-
tierCode: PropTypes.string,
|
|
244
|
-
data: PropTypes.shape({
|
|
245
|
-
pg: PropTypes.string,
|
|
246
|
-
pay_method: PropTypes.oneOf(PAY_METHOD),
|
|
247
|
-
currency: PropTypes.oneOf(CURRENCY),
|
|
248
|
-
notice_url: PropTypes.oneOfType([
|
|
249
|
-
PropTypes.string,
|
|
250
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
251
|
-
]),
|
|
252
|
-
display: PropTypes.shape({
|
|
253
|
-
card_quota: PropTypes.arrayOf(PropTypes.number),
|
|
254
|
-
}),
|
|
255
|
-
merchant_uid: PropTypes.string.isRequired,
|
|
256
|
-
amount: PropTypes.oneOfType([
|
|
257
|
-
PropTypes.string.isRequired,
|
|
258
|
-
PropTypes.number.isRequired,
|
|
259
|
-
]),
|
|
260
|
-
buyer_tel: PropTypes.string.isRequired,
|
|
261
|
-
app_scheme: PropTypes.string.isRequired,
|
|
262
|
-
escrow: PropTypes.bool,
|
|
263
|
-
name: PropTypes.string,
|
|
264
|
-
tax_free: PropTypes.number,
|
|
265
|
-
buyer_name: PropTypes.string,
|
|
266
|
-
buyer_email: PropTypes.string,
|
|
267
|
-
buyer_addr: PropTypes.string,
|
|
268
|
-
buyer_postcode: PropTypes.string,
|
|
269
|
-
custom_data: PropTypes.object,
|
|
270
|
-
vbank_due: PropTypes.string,
|
|
271
|
-
popup: PropTypes.bool,
|
|
272
|
-
digital: PropTypes.bool,
|
|
273
|
-
}),
|
|
274
|
-
callback: PropTypes.func.isRequired,
|
|
275
|
-
loading: PropTypes.shape({
|
|
276
|
-
message: PropTypes.string,
|
|
277
|
-
image: PropTypes.oneOfType([
|
|
278
|
-
PropTypes.string,
|
|
279
|
-
PropTypes.number,
|
|
280
|
-
]),
|
|
281
|
-
}),
|
|
282
|
-
open3rdPartyApp: PropTypes.func.isRequired,
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
export default PaymentWebView;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Linking, NativeModules } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import PaymentWebView from './PaymentWebView';
|
|
6
|
-
|
|
7
|
-
const { Iamport } = NativeModules;
|
|
8
|
-
|
|
9
|
-
export function Payment({ userCode, tierCode, data, loading, callback }) {
|
|
10
|
-
async function open3rdPartyApp(iamportUrl) {
|
|
11
|
-
const url = iamportUrl.getUrl();
|
|
12
|
-
try {
|
|
13
|
-
/* 3rd-party 앱 오픈 */
|
|
14
|
-
const appUrl = await Iamport.getAppUrl(url);
|
|
15
|
-
Linking.openURL(appUrl)
|
|
16
|
-
.catch(async () => {
|
|
17
|
-
/* 앱 미설치시 마켓 오픈 */
|
|
18
|
-
try {
|
|
19
|
-
const marketUrl = await Iamport.getMarketUrl(url);
|
|
20
|
-
Linking.openURL(marketUrl);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
handleOpen3rdPartyAppError(e);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
} catch (e) {
|
|
26
|
-
handleOpen3rdPartyAppError(e);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleOpen3rdPartyAppError(e) {
|
|
31
|
-
const { code, message } = e;
|
|
32
|
-
callback({
|
|
33
|
-
imp_success: false,
|
|
34
|
-
error_code: code,
|
|
35
|
-
error_msg: message,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<PaymentWebView
|
|
41
|
-
userCode={userCode}
|
|
42
|
-
tierCode={tierCode}
|
|
43
|
-
data={data}
|
|
44
|
-
loading={loading}
|
|
45
|
-
callback={callback}
|
|
46
|
-
open3rdPartyApp={open3rdPartyApp}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default Payment;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Linking } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import PaymentWebView from './PaymentWebView';
|
|
6
|
-
|
|
7
|
-
export function Payment({ userCode, tierCode, data, loading, callback }) {
|
|
8
|
-
|
|
9
|
-
function open3rdPartyApp(iamportUrl) {
|
|
10
|
-
// 앱 오픈
|
|
11
|
-
Linking.openURL(iamportUrl.getAppUrl())
|
|
12
|
-
.catch(() => {
|
|
13
|
-
// 앱 미설치 경우, 마켓 URL로 연결
|
|
14
|
-
Linking.openURL(iamportUrl.getMarketUrl());
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<PaymentWebView
|
|
20
|
-
userCode={userCode}
|
|
21
|
-
tierCode={tierCode}
|
|
22
|
-
data={data}
|
|
23
|
-
loading={loading}
|
|
24
|
-
callback={callback}
|
|
25
|
-
open3rdPartyApp={open3rdPartyApp}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default Payment;
|
package/src/constants/index.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const PG = [
|
|
3
|
-
'html5_inicis',
|
|
4
|
-
'inicis',
|
|
5
|
-
'uplus',
|
|
6
|
-
'kcp',
|
|
7
|
-
'kcp_billing',
|
|
8
|
-
'nice',
|
|
9
|
-
'jtnet',
|
|
10
|
-
'kakao',
|
|
11
|
-
'kakaopay',
|
|
12
|
-
'danal',
|
|
13
|
-
'danal_tpay',
|
|
14
|
-
'kicc',
|
|
15
|
-
'settle',
|
|
16
|
-
'mobilians',
|
|
17
|
-
'payco',
|
|
18
|
-
'eximbay',
|
|
19
|
-
'paypal',
|
|
20
|
-
'naverco',
|
|
21
|
-
'naverpay',
|
|
22
|
-
'smilepay',
|
|
23
|
-
'chai',
|
|
24
|
-
'payple',
|
|
25
|
-
'alipay',
|
|
26
|
-
'bluewalnut',
|
|
27
|
-
'tosspay',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const PAY_METHOD = [
|
|
31
|
-
'card',
|
|
32
|
-
'trans',
|
|
33
|
-
'vbank',
|
|
34
|
-
'phone',
|
|
35
|
-
'samsung',
|
|
36
|
-
'kpay',
|
|
37
|
-
'cultureland',
|
|
38
|
-
'smartculture',
|
|
39
|
-
'happymoney',
|
|
40
|
-
'booknlife',
|
|
41
|
-
'kakaopay',
|
|
42
|
-
'lpay',
|
|
43
|
-
'payco',
|
|
44
|
-
'ssgpay',
|
|
45
|
-
'tosspay',
|
|
46
|
-
// 엑심베이 전용
|
|
47
|
-
'unionpay', // 유니온페이
|
|
48
|
-
'alipay', // 알리페이
|
|
49
|
-
'tenpay', // 텐페이
|
|
50
|
-
'wechat', // 위챗페이
|
|
51
|
-
'molpay', // 몰페이
|
|
52
|
-
'paysbuy', // 태국 paysbuy
|
|
53
|
-
];
|
|
54
|
-
const CURRENCY = ['KRW', 'USD', 'EUR', 'JPY'];
|
|
55
|
-
const LANGUAGE = ['ko', 'en'];
|
|
56
|
-
const EN_AVAILABLE_PG = ['inicis', 'html5_inicis', 'uplus', 'nice', 'eximbay'];
|
|
57
|
-
const CARRIERS = ['SKT', 'KTF', 'LGT', 'MVNO'];
|
|
58
|
-
|
|
59
|
-
const SMILEPAY_URL = 'https://www.mysmilepay.com';
|
|
60
|
-
|
|
61
|
-
const WEBVIEW_SOURCE_HTML = `
|
|
62
|
-
<html>
|
|
63
|
-
<head>
|
|
64
|
-
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
65
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
66
|
-
|
|
67
|
-
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js" ></script>
|
|
68
|
-
<script type="text/javascript" src="https://cdn.iamport.kr/js/iamport.payment-1.1.8.js"></script>
|
|
69
|
-
</head>
|
|
70
|
-
<body></body>
|
|
71
|
-
</html>
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
PG,
|
|
76
|
-
PAY_METHOD,
|
|
77
|
-
CURRENCY,
|
|
78
|
-
LANGUAGE,
|
|
79
|
-
EN_AVAILABLE_PG,
|
|
80
|
-
CARRIERS,
|
|
81
|
-
WEBVIEW_SOURCE_HTML,
|
|
82
|
-
SMILEPAY_URL,
|
|
83
|
-
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/img/expo-eject.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/utils/IamportUrl.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import queryString from 'query-string';
|
|
2
|
-
|
|
3
|
-
class IamportUrl {
|
|
4
|
-
static M_REDIRECT_URL = 'http://localhost/iamport';
|
|
5
|
-
static NICE_TRANS_URL = 'https://web.nicepay.co.kr/smart/bank/payTrans.jsp';
|
|
6
|
-
static IMP_SDK_URL = 'https://service.iamport.kr';
|
|
7
|
-
|
|
8
|
-
constructor(url) {
|
|
9
|
-
this.url = url;
|
|
10
|
-
|
|
11
|
-
const [scheme, path] = url.split('://');
|
|
12
|
-
this.scheme = scheme;
|
|
13
|
-
this.path = path;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getUrl() {
|
|
17
|
-
return this.url;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
isPaymentOver() {
|
|
21
|
-
return this.url.includes(IamportUrl.M_REDIRECT_URL);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
isAppUrl() {
|
|
25
|
-
return this.scheme !== 'http' && this.scheme !== 'https' && this.scheme !== 'about:blank';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
isIframeLoaded() {
|
|
29
|
-
return this.url !== 'about:blank' && !this.url.startsWith(IamportUrl.IMP_SDK_URL);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getAppUrl() {
|
|
33
|
-
return this.scheme === 'itmss' ? `https://${this.path}` : this.url;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getMarketUrl() {
|
|
37
|
-
switch (this.scheme) {
|
|
38
|
-
case 'kftc-bankpay': // 뱅크페이
|
|
39
|
-
return 'https://itunes.apple.com/kr/app/id398456030';
|
|
40
|
-
case 'ispmobile': // ISP/페이북
|
|
41
|
-
return 'https://itunes.apple.com/kr/app/id369125087';
|
|
42
|
-
case 'hdcardappcardansimclick': // 현대카드 앱카드
|
|
43
|
-
return 'https://itunes.apple.com/kr/app/id702653088';
|
|
44
|
-
case 'shinhan-sr-ansimclick': // 신한 앱카드
|
|
45
|
-
return 'https://itunes.apple.com/app/id572462317';
|
|
46
|
-
case 'kb-acp': // KB국민 앱카드
|
|
47
|
-
return 'https://itunes.apple.com/kr/app/id695436326';
|
|
48
|
-
case 'mpocket.online.ansimclick': // 삼성앱카드
|
|
49
|
-
return 'https://itunes.apple.com/kr/app/id535125356';
|
|
50
|
-
case 'lottesmartpay': // 롯데 모바일결제
|
|
51
|
-
return 'https://itunes.apple.com/kr/app/id668497947';
|
|
52
|
-
case 'lotteappcard': // 롯데 앱카드
|
|
53
|
-
return 'https://itunes.apple.com/kr/app/id688047200';
|
|
54
|
-
case 'cloudpay': // 하나1Q페이(앱카드)
|
|
55
|
-
return 'https://itunes.apple.com/kr/app/id847268987';
|
|
56
|
-
case 'citimobileapp': // 시티은행 앱카드
|
|
57
|
-
return 'https://itunes.apple.com/kr/app/id1179759666';
|
|
58
|
-
case 'payco': // 페이코
|
|
59
|
-
return 'https://itunes.apple.com/kr/app/id924292102';
|
|
60
|
-
case 'kakaotalk': // 카카오톡
|
|
61
|
-
return 'https://itunes.apple.com/kr/app/id362057947';
|
|
62
|
-
case 'lpayapp': // 롯데 L.pay
|
|
63
|
-
return 'https://itunes.apple.com/kr/app/id1036098908';
|
|
64
|
-
case 'wooripay': // 우리페이
|
|
65
|
-
return 'https://itunes.apple.com/kr/app/id1201113419';
|
|
66
|
-
case 'nhallonepayansimclick': // NH농협카드 올원페이(앱카드)
|
|
67
|
-
return 'https://itunes.apple.com/kr/app/id1177889176';
|
|
68
|
-
case 'hanawalletmembers': // 하나카드(하나멤버스 월렛)
|
|
69
|
-
return 'https://itunes.apple.com/kr/app/id1038288833';
|
|
70
|
-
case 'shinsegaeeasypayment': // 신세계 SSGPAY
|
|
71
|
-
return 'https://itunes.apple.com/app/id666237916';
|
|
72
|
-
case 'naversearchthirdlogin': // 네이버페이 앱 로그인
|
|
73
|
-
return 'https://itunes.apple.com/kr/app/id393499958';
|
|
74
|
-
default:
|
|
75
|
-
return this.url;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
getQuery() {
|
|
80
|
-
const decodedUrl = decodeURIComponent(this.url);
|
|
81
|
-
const extractedQuery = queryString.extract(decodedUrl);
|
|
82
|
-
const query = queryString.parse(extractedQuery);
|
|
83
|
-
return query;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getStringifiedQuery() {
|
|
87
|
-
const decodedUrl = decodeURIComponent(this.url);
|
|
88
|
-
return queryString.extract(decodedUrl);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getInicisTransQuery() {
|
|
92
|
-
const { m_redirect_url, imp_uid, merchant_uid } = this.getQuery();
|
|
93
|
-
const inicisTransQuery = { imp_uid };
|
|
94
|
-
if (m_redirect_url.includes(IamportUrl.M_REDIRECT_URL)) {
|
|
95
|
-
inicisTransQuery.merchant_uid = typeof merchant_uid === 'object' ? merchant_uid[0] : merchant_uid;
|
|
96
|
-
} else {
|
|
97
|
-
inicisTransQuery.merchant_uid = merchant_uid;
|
|
98
|
-
}
|
|
99
|
-
return queryString.stringify(inicisTransQuery);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default IamportUrl;
|