react-native-bootpay-api 13.13.44 → 13.13.46
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/README.md +37 -0
- package/lib/Bootpay.js +1 -1
- package/lib/BootpayCommerce.js +1 -1
- package/lib/BootpayWidget.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +2 -2
- package/src/Bootpay.tsx +2 -0
- package/src/BootpayCommerce.tsx +2 -0
- package/src/BootpayWidget.tsx +2 -0
- package/src/index.tsx +72 -0
package/README.md
CHANGED
|
@@ -321,6 +321,43 @@ const styles = StyleSheet.create({
|
|
|
321
321
|
```
|
|
322
322
|
|
|
323
323
|
|
|
324
|
+
## WebView 프리워밍 (iOS/Android)
|
|
325
|
+
|
|
326
|
+
WebView는 처음 생성 시 프로세스 초기화에 시간이 소요됩니다 (iOS: 3-7초, Android: 200-300ms).
|
|
327
|
+
Bootpay SDK는 **자동으로** 패키지 import 시 백그라운드에서 프로세스를 미리 초기화하여 첫 결제 화면 로딩 속도를 개선합니다.
|
|
328
|
+
|
|
329
|
+
### 자동 프리워밍
|
|
330
|
+
|
|
331
|
+
SDK import 시 자동으로 프리워밍이 수행됩니다. 개발자가 별도로 호출할 필요가 없습니다.
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
// 자동으로 warmUp이 수행됩니다
|
|
335
|
+
import { Bootpay } from 'react-native-bootpay-api';
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### 메모리 관리 (선택사항)
|
|
339
|
+
|
|
340
|
+
메모리 부족 시 프리워밍된 리소스를 해제할 수 있습니다:
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
import { releaseWarmUp } from 'react-native-bootpay-api';
|
|
344
|
+
|
|
345
|
+
// 메모리 정리가 필요할 때 (선택사항)
|
|
346
|
+
releaseWarmUp();
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### 효과
|
|
350
|
+
|
|
351
|
+
| 플랫폼 | 개선 효과 |
|
|
352
|
+
|--------|----------|
|
|
353
|
+
| iOS | WKWebView 프로세스 초기화 3-7초 단축 |
|
|
354
|
+
| Android | Chromium 엔진 초기화 200-300ms 단축 |
|
|
355
|
+
|
|
356
|
+
### 참고사항
|
|
357
|
+
|
|
358
|
+
- 프리워밍은 SDK import 시 자동으로 수행되므로 별도 설정이 필요 없습니다.
|
|
359
|
+
- 두 번째 결제부터는 ProcessPool/WebView 재사용으로 자동으로 빠릅니다.
|
|
360
|
+
|
|
324
361
|
## Documentation
|
|
325
362
|
|
|
326
363
|
[부트페이 개발매뉴얼](https://docs.bootpay.co.kr/?front=react-native&backend=nodejs)을 참조해주세요
|
package/lib/Bootpay.js
CHANGED
|
@@ -27,4 +27,4 @@ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault
|
|
|
27
27
|
`;};_this.getSDKVersion=function(){var os=_reactNative.Platform.OS;return`Bootpay.setVersion('${SDK_VERSION}', '${os}_react_native')`;};_this.getEnvironmentMode=function(){return DEBUG_MODE?"Bootpay.setEnvironmentMode('development');":'';};_this.getBootpayPlatform=function(){return _reactNative.Platform.OS==='ios'?"Bootpay.setDevice('IOS');":"Bootpay.setDevice('ANDROID');";};_this.removePaymentWindow=function(){_this.dismiss();};_this.getAnalyticsData=(0,_asyncToGenerator2.default)(function*(){var uuid=yield _UserInfo.default.getBootpayUUID();var bootpaySK=yield _UserInfo.default.getBootpaySK();var bootLastTime=yield _UserInfo.default.getBootpayLastTime();var elaspedTime=Date.now()-bootLastTime;if(DEBUG_MODE)console.log('analytics:',uuid,bootpaySK,bootLastTime);return`window.Bootpay.$analytics.setAnalyticsData({uuid:'${uuid}',sk:'${bootpaySK}',time:${elaspedTime}});`;});_this.requestPayment=function(){var _ref4=(0,_asyncToGenerator2.default)(function*(payload,items,user,extra){_this.bootpayRequest(payload,items,user,extra,'requestPayment');});return function(_x2,_x3,_x4,_x5){return _ref4.apply(this,arguments);};}();_this.requestSubscription=function(){var _ref5=(0,_asyncToGenerator2.default)(function*(payload,items,user,extra){_this.bootpayRequest(payload,items,user,extra,'requestSubscription');});return function(_x6,_x7,_x8,_x9){return _ref5.apply(this,arguments);};}();_this.requestAuthentication=function(){var _ref6=(0,_asyncToGenerator2.default)(function*(payload,items,user,extra){_this.bootpayRequest(payload,items,user,extra,'requestAuthentication');});return function(_x0,_x1,_x10,_x11){return _ref6.apply(this,arguments);};}();_this.bootpayRequest=function(){var _ref7=(0,_asyncToGenerator2.default)(function*(payload,items,user,extra,requestMethod){payload.application_id=_reactNative.Platform.OS==='ios'?_this.props.ios_application_id:_this.props.android_application_id;payload.items=items;payload.user=user;payload.user=Object.assign(new _BootpayTypes.User(),user);payload.extra=Object.assign(new _BootpayTypes.Extra(),extra);_this.payload=payload;_this.setState({visibility:true,script:`
|
|
28
28
|
${yield _this.getMountJavascript()}
|
|
29
29
|
${_this.generateScript(payload,requestMethod)}
|
|
30
|
-
`,firstLoad:false,showCloseButton:extra.show_close_button||false,spinner:false});_UserInfo.default.updateInfo();});return function(_x12,_x13,_x14,_x15,_x16){return _ref7.apply(this,arguments);};}();_this.webView=_react.default.createRef();return _this;}(0,_inherits2.default)(Bootpay,_Component);return(0,_createClass2.default)(Bootpay,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.setState({visibility:false,firstLoad:false,showCloseButton:false});_UserInfo.default.setBootpayLastTime(Date.now());}},{key:"componentDidMount",value:function componentDidMount(){this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);}},{key:"render",value:function render(){var _this2=this;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{animationType:"slide",transparent:false,visible:this.state.visibility,onRequestClose:this.closeDismiss,children:(0,_jsxRuntime.jsxs)(_reactNative.SafeAreaView,{style:{flex:1},children:[this.state.showCloseButton&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:this.closeDismiss,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{style:styles.overlay,source:require('../images/close.png')})}),(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:this.webView,originWhitelist:['*'],source:{uri:'https://webview.bootpay.co.kr/5.2.2'},injectedJavaScript:this.state.script,javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,onMessage:this.onMessage,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(nativeEvent.code===3){_this2.showProgressBar(false);if(_this2.props.onError)_this2.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});_this2.closeDismiss();}}})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({overlay:{width:25,height:25,right:5,alignSelf:'flex-end'}});
|
|
30
|
+
`,firstLoad:false,showCloseButton:extra.show_close_button||false,spinner:false});_UserInfo.default.updateInfo();});return function(_x12,_x13,_x14,_x15,_x16){return _ref7.apply(this,arguments);};}();_this.webView=_react.default.createRef();return _this;}(0,_inherits2.default)(Bootpay,_Component);return(0,_createClass2.default)(Bootpay,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.setState({visibility:false,firstLoad:false,showCloseButton:false});_UserInfo.default.setBootpayLastTime(Date.now());}},{key:"componentDidMount",value:function componentDidMount(){this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);}},{key:"render",value:function render(){var _this2=this;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{animationType:"slide",transparent:false,visible:this.state.visibility,onRequestClose:this.closeDismiss,children:(0,_jsxRuntime.jsxs)(_reactNative.SafeAreaView,{style:{flex:1},children:[this.state.showCloseButton&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:this.closeDismiss,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{style:styles.overlay,source:require('../images/close.png')})}),(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:this.webView,originWhitelist:['*'],source:{uri:'https://webview.bootpay.co.kr/5.2.2'},injectedJavaScript:this.state.script,javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,useSharedProcessPool:true,sharedCookiesEnabled:true,onMessage:this.onMessage,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(nativeEvent.code===3){_this2.showProgressBar(false);if(_this2.props.onError)_this2.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});_this2.closeDismiss();}}})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({overlay:{width:25,height:25,right:5,alignSelf:'flex-end'}});
|
package/lib/BootpayCommerce.js
CHANGED
|
@@ -11,4 +11,4 @@ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault
|
|
|
11
11
|
console.error('[BootpayCommerce] Script error:', e);
|
|
12
12
|
window.BootpayRNWebView.postMessage(JSON.stringify({event: 'error', message: e.message}));
|
|
13
13
|
}
|
|
14
|
-
`;_this.callJavaScript(fullScript);}};_this.onShouldStartLoadWithRequest=function(request){var url=request.url;if(DEBUG_MODE){console.log('[BootpayCommerce] onShouldStartLoadWithRequest:',url);}if(url.includes('api.bootpay.co.kr/v2/callback')){if(DEBUG_MODE){console.log('[BootpayCommerce] Callback URL detected, handling...');}_this.handleCallbackURL(url);return false;}if(url.startsWith('about:blank')){return true;}if(!url.startsWith('http://')&&!url.startsWith('https://')){if(DEBUG_MODE){console.log('[BootpayCommerce] Non-http scheme, should open external app:',url);}return false;}return true;};_this.parseQueryString=function(urlString){var result={};var queryIndex=urlString.indexOf('?');if(queryIndex===-1)return result;var queryString=urlString.substring(queryIndex+1);var pairs=queryString.split('&');for(var pair of pairs){var eqIndex=pair.indexOf('=');if(eqIndex>0){var key=pair.substring(0,eqIndex);var value=pair.substring(eqIndex+1);try{result[key]=decodeURIComponent(value);}catch(_unused){result[key]=value;}}}return result;};_this.handleCallbackURL=function(urlString){try{var params=_this.parseQueryString(urlString);var data={};for(var _ref of Object.entries(params)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var key=_ref2[0];var value=_ref2[1];if(key==='metadata'){try{data[key]=JSON.parse(value);}catch(_unused2){data[key]=value;}}else{data[key]=value;}}if(DEBUG_MODE){console.log('[BootpayCommerce] Callback data:',data);}var event=data.event||'';_this.showProgressBar(false);switch(event){case'done':if(_this.props.onDone){_this.props.onDone(data);}break;case'issued':if(_this.props.onIssued){_this.props.onIssued(data);}break;case'cancel':if(_this.props.onCancel){_this.props.onCancel(data);}break;case'error':if(_this.props.onError){_this.props.onError(data);}break;default:if(data.receipt_id){if(_this.props.onDone){_this.props.onDone(data);}}else{if(_this.props.onCancel){_this.props.onCancel(data);}}break;}_this.closeDismiss();}catch(error){console.error('[BootpayCommerce] Error parsing callback URL:',error);if(_this.props.onError){_this.props.onError({event:'error',message:'Failed to parse callback URL'});}_this.closeDismiss();}};_this.onMessage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(event){if(!event)return;try{var messageData=event.nativeEvent.data;if(messageData==='close'){_this.showProgressBar(false);_this.closeDismiss();return;}var data=typeof messageData==='string'?JSON.parse(messageData):messageData;var handleEvent=function handleEvent(_eventName,callback){_this.showProgressBar(false);if(callback)callback(data);_this.closeDismiss();};switch(data.event){case'cancel':handleEvent('cancel',_this.props.onCancel);break;case'error':handleEvent('error',_this.props.onError);break;case'done':handleEvent('done',_this.props.onDone);break;case'issued':handleEvent('issued',_this.props.onIssued);break;case'close':_this.showProgressBar(false);_this.closeDismiss();break;default:if(data.receipt_id){handleEvent('done',_this.props.onDone);}else{console.warn(`Unknown commerce event type: ${data.event}`);}break;}}catch(error){console.error('Error processing commerce message:',error);}});return function(_x){return _ref3.apply(this,arguments);};}();_this.webView=_react.default.createRef();return _this;}(0,_inherits2.default)(BootpayCommerce,_Component);return(0,_createClass2.default)(BootpayCommerce,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.setState({visibility:false,firstLoad:false,showCloseButton:true});}},{key:"componentDidMount",value:function componentDidMount(){this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);}},{key:"render",value:function render(){var _this2=this;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{animationType:"slide",transparent:false,visible:this.state.visibility,onRequestClose:this.closeDismiss,children:(0,_jsxRuntime.jsxs)(_reactNative.SafeAreaView,{style:{flex:1},children:[this.state.showCloseButton&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:this.closeDismiss,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{style:styles.overlay,source:require('../images/close.png')})}),(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:this.webView,originWhitelist:['*'],source:{uri:COMMERCE_URL},javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,onMessage:this.onMessage,onLoadEnd:this.onLoadEnd,onShouldStartLoadWithRequest:this.onShouldStartLoadWithRequest,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(nativeEvent.code===3){_this2.showProgressBar(false);if(_this2.props.onError)_this2.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});_this2.closeDismiss();}}})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({overlay:{width:25,height:25,right:5,alignSelf:'flex-end'}});
|
|
14
|
+
`;_this.callJavaScript(fullScript);}};_this.onShouldStartLoadWithRequest=function(request){var url=request.url;if(DEBUG_MODE){console.log('[BootpayCommerce] onShouldStartLoadWithRequest:',url);}if(url.includes('api.bootpay.co.kr/v2/callback')){if(DEBUG_MODE){console.log('[BootpayCommerce] Callback URL detected, handling...');}_this.handleCallbackURL(url);return false;}if(url.startsWith('about:blank')){return true;}if(!url.startsWith('http://')&&!url.startsWith('https://')){if(DEBUG_MODE){console.log('[BootpayCommerce] Non-http scheme, should open external app:',url);}return false;}return true;};_this.parseQueryString=function(urlString){var result={};var queryIndex=urlString.indexOf('?');if(queryIndex===-1)return result;var queryString=urlString.substring(queryIndex+1);var pairs=queryString.split('&');for(var pair of pairs){var eqIndex=pair.indexOf('=');if(eqIndex>0){var key=pair.substring(0,eqIndex);var value=pair.substring(eqIndex+1);try{result[key]=decodeURIComponent(value);}catch(_unused){result[key]=value;}}}return result;};_this.handleCallbackURL=function(urlString){try{var params=_this.parseQueryString(urlString);var data={};for(var _ref of Object.entries(params)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var key=_ref2[0];var value=_ref2[1];if(key==='metadata'){try{data[key]=JSON.parse(value);}catch(_unused2){data[key]=value;}}else{data[key]=value;}}if(DEBUG_MODE){console.log('[BootpayCommerce] Callback data:',data);}var event=data.event||'';_this.showProgressBar(false);switch(event){case'done':if(_this.props.onDone){_this.props.onDone(data);}break;case'issued':if(_this.props.onIssued){_this.props.onIssued(data);}break;case'cancel':if(_this.props.onCancel){_this.props.onCancel(data);}break;case'error':if(_this.props.onError){_this.props.onError(data);}break;default:if(data.receipt_id){if(_this.props.onDone){_this.props.onDone(data);}}else{if(_this.props.onCancel){_this.props.onCancel(data);}}break;}_this.closeDismiss();}catch(error){console.error('[BootpayCommerce] Error parsing callback URL:',error);if(_this.props.onError){_this.props.onError({event:'error',message:'Failed to parse callback URL'});}_this.closeDismiss();}};_this.onMessage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(event){if(!event)return;try{var messageData=event.nativeEvent.data;if(messageData==='close'){_this.showProgressBar(false);_this.closeDismiss();return;}var data=typeof messageData==='string'?JSON.parse(messageData):messageData;var handleEvent=function handleEvent(_eventName,callback){_this.showProgressBar(false);if(callback)callback(data);_this.closeDismiss();};switch(data.event){case'cancel':handleEvent('cancel',_this.props.onCancel);break;case'error':handleEvent('error',_this.props.onError);break;case'done':handleEvent('done',_this.props.onDone);break;case'issued':handleEvent('issued',_this.props.onIssued);break;case'close':_this.showProgressBar(false);_this.closeDismiss();break;default:if(data.receipt_id){handleEvent('done',_this.props.onDone);}else{console.warn(`Unknown commerce event type: ${data.event}`);}break;}}catch(error){console.error('Error processing commerce message:',error);}});return function(_x){return _ref3.apply(this,arguments);};}();_this.webView=_react.default.createRef();return _this;}(0,_inherits2.default)(BootpayCommerce,_Component);return(0,_createClass2.default)(BootpayCommerce,[{key:"componentWillUnmount",value:function componentWillUnmount(){this.setState({visibility:false,firstLoad:false,showCloseButton:true});}},{key:"componentDidMount",value:function componentDidMount(){this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);}},{key:"render",value:function render(){var _this2=this;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{animationType:"slide",transparent:false,visible:this.state.visibility,onRequestClose:this.closeDismiss,children:(0,_jsxRuntime.jsxs)(_reactNative.SafeAreaView,{style:{flex:1},children:[this.state.showCloseButton&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:this.closeDismiss,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{style:styles.overlay,source:require('../images/close.png')})}),(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:this.webView,originWhitelist:['*'],source:{uri:COMMERCE_URL},javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,useSharedProcessPool:true,sharedCookiesEnabled:true,onMessage:this.onMessage,onLoadEnd:this.onLoadEnd,onShouldStartLoadWithRequest:this.onShouldStartLoadWithRequest,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(nativeEvent.code===3){_this2.showProgressBar(false);if(_this2.props.onError)_this2.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});_this2.closeDismiss();}}})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({overlay:{width:25,height:25,right:5,alignSelf:'flex-end'}});
|
package/lib/BootpayWidget.js
CHANGED
|
@@ -100,4 +100,4 @@ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault
|
|
|
100
100
|
setTimeout(function() { waitForBootpayWidget(callback); }, 50);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
`;};_this.getWidgetPayloadForRender=function(){if(!_this.payload)return{};var payload=_this.payload;var result={};if(payload.application_id)result.application_id=payload.application_id;if(payload.pg)result.pg=payload.pg;if(payload.method)result.method=payload.method;if(payload.methods&&payload.methods.length>0){result.method=payload.methods;}if(payload.order_name)result.order_name=payload.order_name;if(payload.price!==undefined)result.price=payload.price;if(payload.tax_free!==undefined)result.tax_free=payload.tax_free;if(payload.order_id)result.order_id=payload.order_id;if(payload.subscription_id)result.subscription_id=payload.subscription_id;if(payload.metadata)result.metadata=payload.metadata;if(payload.extra)result.extra=payload.extra;if(payload.widget_use_terms!==undefined){result.use_terms=payload.widget_use_terms;}if(payload.widget_sandbox!==undefined){result.sandbox=payload.widget_sandbox;}if(payload.widget_key){result.key=payload.widget_key;result.widget=1;result.use_bootpay_inapp_sdk=true;}return result;};_this.getRenderWidgetJS=function(){if(!_this.payload)return'';var widgetPayload=_this.getWidgetPayloadForRender();return`BootpayWidget.render('#bootpay-widget', ${JSON.stringify(widgetPayload)});`;};_this.onLoadEnd=(0,_asyncToGenerator2.default)(function*(){if(DEBUG_MODE){console.log('[BootpayWidget] ===== onLoadEnd called =====');console.log('[BootpayWidget] payload:',_this.payload?'set':'null');console.log('[BootpayWidget] isReady:',_this.state.isReady);console.log('[BootpayWidget] webView ref:',_this.webView.current?'exists':'null');}});_this.onMessage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(event){var _data$detail;if(DEBUG_MODE){var _event$nativeEvent;console.log('[BootpayWidget] ===== onMessage received =====');console.log('[BootpayWidget] raw data:',event==null||(_event$nativeEvent=event.nativeEvent)==null?void 0:_event$nativeEvent.data);}if(!event)return;try{var data=JSON.parse(event.nativeEvent.data);if(DEBUG_MODE){console.log('[BootpayWidget] parsed data:',JSON.stringify(data));}switch(data.event){case'widgetReady':_this.setState({isReady:true},function(){if(_this.props.onWidgetReady){_this.props.onWidgetReady();}});break;case'widgetResize':if((_data$detail=data.detail)!=null&&_data$detail.height){var height=parseFloat(data.detail.height);if(Math.abs(height-_this.state.widgetHeight)>1){if(DEBUG_MODE){console.log('[BootpayWidget] Height changed:',_this.state.widgetHeight,'->',height);}_this.setState({widgetHeight:height});if(!_this.state.isFullScreen){_reactNative.Animated.timing(_this.animatedHeight,{toValue:height,duration:100,useNativeDriver:false}).start();}if(_this.props.onWidgetResize){_this.props.onWidgetResize(height);}}}break;case'widgetChangePayment':{var widgetData=data.detail||null;_this._widgetData=widgetData;if(_this.props.onWidgetChangePayment){_this.props.onWidgetChangePayment(widgetData);}}break;case'widgetChangeTerms':{var _widgetData=data.detail||null;_this._widgetData=_widgetData;if(_this.props.onWidgetChangeTerms){_this.props.onWidgetChangeTerms(_widgetData);}}break;case'bootpayWidgetFullSizeScreen':_this.goFullScreen();break;case'bootpayWidgetRevertScreen':_this.revertToWidget();break;case'cancel':_this._isProcessingPayment=false;_this.setState({paymentResult:'CANCEL'});if(_this.props.onCancel){_this.props.onCancel(data);}_this.closeDismiss();break;case'error':_this._isProcessingPayment=false;_this.setState({paymentResult:'ERROR'});if(_this.props.onError){_this.props.onError(data);}_this.closeDismiss();break;case'issued':_this._isProcessingPayment=false;if(_this.props.onIssued){_this.props.onIssued(data);}_this.closeDismiss();break;case'confirm':if(_this.props.onConfirm&&_this.props.onConfirm(data)){_this.transactionConfirm();}break;case'done':_this._isProcessingPayment=false;_this.setState({paymentResult:'DONE'});if(_this.props.onDone){_this.props.onDone(data);}_this.closeDismiss();break;case'close':console.log('[Fullscreen] close event received, _isProcessingPayment:',_this._isProcessingPayment);if(_this._isProcessingPayment){break;}_this.closeDismiss();break;default:if(DEBUG_MODE){console.warn('Unknown event:',data.event);}break;}}catch(error){if(DEBUG_MODE){console.error('Error parsing message:',error);}}});return function(_x5){return _ref3.apply(this,arguments);};}();_this.renderWebView=function(){return(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:_this.webView,originWhitelist:['*'],source:{uri:WIDGET_URL},javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,injectedJavaScript:_this.initialScript,onLoadStart:function onLoadStart(){if(DEBUG_MODE){console.log('[BootpayWidget] WebView onLoadStart');}},onLoad:function onLoad(){if(DEBUG_MODE){console.log('[BootpayWidget] WebView onLoad');}},onLoadEnd:_this.onLoadEnd,onMessage:_this.onMessage,style:styles.webview,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(DEBUG_MODE){console.error('[BootpayWidget] WebView error:',nativeEvent);}if(_this.props.onError){_this.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});}}});};_this.webView=_react.default.createRef();var _Dimensions$get=_reactNative.Dimensions.get('window'),width=_Dimensions$get.width,_height=_Dimensions$get.height;var initialHeight=props.height||200;_this.animatedTop=new _reactNative.Animated.Value(0);_this.animatedLeft=new _reactNative.Animated.Value(0);_this.animatedWidth=new _reactNative.Animated.Value(width);_this.animatedHeight=new _reactNative.Animated.Value(initialHeight);_this.swipeAnimatedValue=new _reactNative.Animated.Value(0);_this.state={isFullScreen:false,widgetHeight:initialHeight,isReady:false,paymentResult:'NONE',screenWidth:width,screenHeight:_height,isSwiping:false};_this.initialScript=_this.buildInitialScript();_this.panGesture=_reactNativeGestureHandler.Gesture.Pan().activeOffsetX(10).failOffsetX(-10).failOffsetY([-20,20]).onBegin(function(event){_this.swipeStartX=event.x;_this.isValidSwipe=event.x<70;if(DEBUG_MODE){console.log('[Gesture] onBegin x:',event.x,'isValid:',_this.isValidSwipe);}}).onStart(function(){if(_this.isValidSwipe){_this.setState({isSwiping:true});}}).onUpdate(function(event){if(_this.isValidSwipe&&event.translationX>0){_this.swipeAnimatedValue.setValue(event.translationX);}}).onEnd(function(event){if(!_this.isValidSwipe){_this.setState({isSwiping:false});return;}var screenWidth=_this.state.screenWidth;var translationX=event.translationX||0;if(DEBUG_MODE){console.log('[Gesture] onEnd translationX:',translationX,'threshold:',screenWidth*0.4);}if(translationX>screenWidth*0.4){_this._widgetRendered=false;_this.callJavaScript(`window.location.href = '${WIDGET_URL}';`);_reactNative.Animated.timing(_this.swipeAnimatedValue,{toValue:screenWidth,duration:200,useNativeDriver:true}).start(function(){_this.swipeAnimatedValue.setValue(0);_this.setState({isSwiping:false,isFullScreen:false,isReady:false});_this._isProcessingPayment=false;_this.removeBackHandler();if(_this.props.onClose){_this.props.onClose();}});}else{_reactNative.Animated.spring(_this.swipeAnimatedValue,{toValue:0,useNativeDriver:true}).start(function(){_this.setState({isSwiping:false});});}_this.isValidSwipe=false;}).onFinalize(function(){if(_this.state.isSwiping){_reactNative.Animated.spring(_this.swipeAnimatedValue,{toValue:0,useNativeDriver:true}).start(function(){_this.setState({isSwiping:false});});}_this.isValidSwipe=false;});return _this;}(0,_inherits2.default)(BootpayWidget,_Component);return(0,_createClass2.default)(BootpayWidget,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;if(DEBUG_MODE){console.log('[BootpayWidget] ===== componentDidMount =====');console.log('[BootpayWidget] WIDGET_URL:',WIDGET_URL);}this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);var subscription=_reactNative.Dimensions.addEventListener('change',function(_ref4){var window=_ref4.window;_this2.setState({screenWidth:window.width,screenHeight:window.height});});this._dimensionsSubscription=subscription;}},{key:"componentWillUnmount",value:function componentWillUnmount(){var _this$_dimensionsSubs;this.removeBackHandler();(_this$_dimensionsSubs=this._dimensionsSubscription)==null||_this$_dimensionsSubs.remove();_UserInfo.default.setBootpayLastTime(Date.now());}},{key:"render",value:function render(){var _this$state=this.state,isFullScreen=_this$state.isFullScreen,screenWidth=_this$state.screenWidth,screenHeight=_this$state.screenHeight;var _this$props=this.props,style=_this$props.style,widgetTop=_this$props.widgetTop;return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:[styles.gestureRootBase,isFullScreen?styles.gestureRootFullScreen:{top:widgetTop||0,height:this.state.widgetHeight,zIndex:1}],children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[styles.container,style,{flex:1,width:screenWidth},isFullScreen&&{transform:[{translateX:this.swipeAnimatedValue}]}],children:[isFullScreen&&(0,_jsxRuntime.jsx)(_reactNative.SafeAreaView,{style:styles.fullScreenHeader}),this.renderWebView(),isFullScreen&&_reactNative.Platform.OS==='ios'&&(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:this.panGesture,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.swipeEdge})})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({gestureRootBase:{position:'absolute',left:0,right:0},gestureRootFullScreen:{top:0,bottom:0,zIndex:9999},container:{width:'100%',backgroundColor:'#fff',overflow:'hidden'},hidden:{height:0,opacity:0},fullScreenHeader:{backgroundColor:'#fff'},swipeEdge:{position:'absolute',left:0,top:0,bottom:0,width:70,backgroundColor:DEBUG_MODE?'rgba(255, 0, 0, 0.1)':'transparent'},webview:{flex:1,backgroundColor:DEBUG_MODE?'#f0f0f0':'transparent',borderWidth:DEBUG_MODE?1:0,borderColor:'blue'}});var _default=exports.default=BootpayWidget;
|
|
103
|
+
`;};_this.getWidgetPayloadForRender=function(){if(!_this.payload)return{};var payload=_this.payload;var result={};if(payload.application_id)result.application_id=payload.application_id;if(payload.pg)result.pg=payload.pg;if(payload.method)result.method=payload.method;if(payload.methods&&payload.methods.length>0){result.method=payload.methods;}if(payload.order_name)result.order_name=payload.order_name;if(payload.price!==undefined)result.price=payload.price;if(payload.tax_free!==undefined)result.tax_free=payload.tax_free;if(payload.order_id)result.order_id=payload.order_id;if(payload.subscription_id)result.subscription_id=payload.subscription_id;if(payload.metadata)result.metadata=payload.metadata;if(payload.extra)result.extra=payload.extra;if(payload.widget_use_terms!==undefined){result.use_terms=payload.widget_use_terms;}if(payload.widget_sandbox!==undefined){result.sandbox=payload.widget_sandbox;}if(payload.widget_key){result.key=payload.widget_key;result.widget=1;result.use_bootpay_inapp_sdk=true;}return result;};_this.getRenderWidgetJS=function(){if(!_this.payload)return'';var widgetPayload=_this.getWidgetPayloadForRender();return`BootpayWidget.render('#bootpay-widget', ${JSON.stringify(widgetPayload)});`;};_this.onLoadEnd=(0,_asyncToGenerator2.default)(function*(){if(DEBUG_MODE){console.log('[BootpayWidget] ===== onLoadEnd called =====');console.log('[BootpayWidget] payload:',_this.payload?'set':'null');console.log('[BootpayWidget] isReady:',_this.state.isReady);console.log('[BootpayWidget] webView ref:',_this.webView.current?'exists':'null');}});_this.onMessage=function(){var _ref3=(0,_asyncToGenerator2.default)(function*(event){var _data$detail;if(DEBUG_MODE){var _event$nativeEvent;console.log('[BootpayWidget] ===== onMessage received =====');console.log('[BootpayWidget] raw data:',event==null||(_event$nativeEvent=event.nativeEvent)==null?void 0:_event$nativeEvent.data);}if(!event)return;try{var data=JSON.parse(event.nativeEvent.data);if(DEBUG_MODE){console.log('[BootpayWidget] parsed data:',JSON.stringify(data));}switch(data.event){case'widgetReady':_this.setState({isReady:true},function(){if(_this.props.onWidgetReady){_this.props.onWidgetReady();}});break;case'widgetResize':if((_data$detail=data.detail)!=null&&_data$detail.height){var height=parseFloat(data.detail.height);if(Math.abs(height-_this.state.widgetHeight)>1){if(DEBUG_MODE){console.log('[BootpayWidget] Height changed:',_this.state.widgetHeight,'->',height);}_this.setState({widgetHeight:height});if(!_this.state.isFullScreen){_reactNative.Animated.timing(_this.animatedHeight,{toValue:height,duration:100,useNativeDriver:false}).start();}if(_this.props.onWidgetResize){_this.props.onWidgetResize(height);}}}break;case'widgetChangePayment':{var widgetData=data.detail||null;_this._widgetData=widgetData;if(_this.props.onWidgetChangePayment){_this.props.onWidgetChangePayment(widgetData);}}break;case'widgetChangeTerms':{var _widgetData=data.detail||null;_this._widgetData=_widgetData;if(_this.props.onWidgetChangeTerms){_this.props.onWidgetChangeTerms(_widgetData);}}break;case'bootpayWidgetFullSizeScreen':_this.goFullScreen();break;case'bootpayWidgetRevertScreen':_this.revertToWidget();break;case'cancel':_this._isProcessingPayment=false;_this.setState({paymentResult:'CANCEL'});if(_this.props.onCancel){_this.props.onCancel(data);}_this.closeDismiss();break;case'error':_this._isProcessingPayment=false;_this.setState({paymentResult:'ERROR'});if(_this.props.onError){_this.props.onError(data);}_this.closeDismiss();break;case'issued':_this._isProcessingPayment=false;if(_this.props.onIssued){_this.props.onIssued(data);}_this.closeDismiss();break;case'confirm':if(_this.props.onConfirm&&_this.props.onConfirm(data)){_this.transactionConfirm();}break;case'done':_this._isProcessingPayment=false;_this.setState({paymentResult:'DONE'});if(_this.props.onDone){_this.props.onDone(data);}_this.closeDismiss();break;case'close':console.log('[Fullscreen] close event received, _isProcessingPayment:',_this._isProcessingPayment);if(_this._isProcessingPayment){break;}_this.closeDismiss();break;default:if(DEBUG_MODE){console.warn('Unknown event:',data.event);}break;}}catch(error){if(DEBUG_MODE){console.error('Error parsing message:',error);}}});return function(_x5){return _ref3.apply(this,arguments);};}();_this.renderWebView=function(){return(0,_jsxRuntime.jsx)(_reactNativeWebviewBootpay.default,{ref:_this.webView,originWhitelist:['*'],source:{uri:WIDGET_URL},javaScriptEnabled:true,javaScriptCanOpenWindowsAutomatically:true,useSharedProcessPool:true,sharedCookiesEnabled:true,injectedJavaScript:_this.initialScript,onLoadStart:function onLoadStart(){if(DEBUG_MODE){console.log('[BootpayWidget] WebView onLoadStart');}},onLoad:function onLoad(){if(DEBUG_MODE){console.log('[BootpayWidget] WebView onLoad');}},onLoadEnd:_this.onLoadEnd,onMessage:_this.onMessage,style:styles.webview,onError:function onError(syntheticEvent){var nativeEvent=syntheticEvent.nativeEvent;if(DEBUG_MODE){console.error('[BootpayWidget] WebView error:',nativeEvent);}if(_this.props.onError){_this.props.onError({event:'error',code:nativeEvent.code,message:nativeEvent.description});}}});};_this.webView=_react.default.createRef();var _Dimensions$get=_reactNative.Dimensions.get('window'),width=_Dimensions$get.width,_height=_Dimensions$get.height;var initialHeight=props.height||200;_this.animatedTop=new _reactNative.Animated.Value(0);_this.animatedLeft=new _reactNative.Animated.Value(0);_this.animatedWidth=new _reactNative.Animated.Value(width);_this.animatedHeight=new _reactNative.Animated.Value(initialHeight);_this.swipeAnimatedValue=new _reactNative.Animated.Value(0);_this.state={isFullScreen:false,widgetHeight:initialHeight,isReady:false,paymentResult:'NONE',screenWidth:width,screenHeight:_height,isSwiping:false};_this.initialScript=_this.buildInitialScript();_this.panGesture=_reactNativeGestureHandler.Gesture.Pan().activeOffsetX(10).failOffsetX(-10).failOffsetY([-20,20]).onBegin(function(event){_this.swipeStartX=event.x;_this.isValidSwipe=event.x<70;if(DEBUG_MODE){console.log('[Gesture] onBegin x:',event.x,'isValid:',_this.isValidSwipe);}}).onStart(function(){if(_this.isValidSwipe){_this.setState({isSwiping:true});}}).onUpdate(function(event){if(_this.isValidSwipe&&event.translationX>0){_this.swipeAnimatedValue.setValue(event.translationX);}}).onEnd(function(event){if(!_this.isValidSwipe){_this.setState({isSwiping:false});return;}var screenWidth=_this.state.screenWidth;var translationX=event.translationX||0;if(DEBUG_MODE){console.log('[Gesture] onEnd translationX:',translationX,'threshold:',screenWidth*0.4);}if(translationX>screenWidth*0.4){_this._widgetRendered=false;_this.callJavaScript(`window.location.href = '${WIDGET_URL}';`);_reactNative.Animated.timing(_this.swipeAnimatedValue,{toValue:screenWidth,duration:200,useNativeDriver:true}).start(function(){_this.swipeAnimatedValue.setValue(0);_this.setState({isSwiping:false,isFullScreen:false,isReady:false});_this._isProcessingPayment=false;_this.removeBackHandler();if(_this.props.onClose){_this.props.onClose();}});}else{_reactNative.Animated.spring(_this.swipeAnimatedValue,{toValue:0,useNativeDriver:true}).start(function(){_this.setState({isSwiping:false});});}_this.isValidSwipe=false;}).onFinalize(function(){if(_this.state.isSwiping){_reactNative.Animated.spring(_this.swipeAnimatedValue,{toValue:0,useNativeDriver:true}).start(function(){_this.setState({isSwiping:false});});}_this.isValidSwipe=false;});return _this;}(0,_inherits2.default)(BootpayWidget,_Component);return(0,_createClass2.default)(BootpayWidget,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;if(DEBUG_MODE){console.log('[BootpayWidget] ===== componentDidMount =====');console.log('[BootpayWidget] WIDGET_URL:',WIDGET_URL);}this.closeDismiss=(0,_lodash.debounce)(this.closeDismiss,30);var subscription=_reactNative.Dimensions.addEventListener('change',function(_ref4){var window=_ref4.window;_this2.setState({screenWidth:window.width,screenHeight:window.height});});this._dimensionsSubscription=subscription;}},{key:"componentWillUnmount",value:function componentWillUnmount(){var _this$_dimensionsSubs;this.removeBackHandler();(_this$_dimensionsSubs=this._dimensionsSubscription)==null||_this$_dimensionsSubs.remove();_UserInfo.default.setBootpayLastTime(Date.now());}},{key:"render",value:function render(){var _this$state=this.state,isFullScreen=_this$state.isFullScreen,screenWidth=_this$state.screenWidth,screenHeight=_this$state.screenHeight;var _this$props=this.props,style=_this$props.style,widgetTop=_this$props.widgetTop;return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:[styles.gestureRootBase,isFullScreen?styles.gestureRootFullScreen:{top:widgetTop||0,height:this.state.widgetHeight,zIndex:1}],children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[styles.container,style,{flex:1,width:screenWidth},isFullScreen&&{transform:[{translateX:this.swipeAnimatedValue}]}],children:[isFullScreen&&(0,_jsxRuntime.jsx)(_reactNative.SafeAreaView,{style:styles.fullScreenHeader}),this.renderWebView(),isFullScreen&&_reactNative.Platform.OS==='ios'&&(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:this.panGesture,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.swipeEdge})})]})});}}]);}(_react.Component);var styles=_reactNative.StyleSheet.create({gestureRootBase:{position:'absolute',left:0,right:0},gestureRootFullScreen:{top:0,bottom:0,zIndex:9999},container:{width:'100%',backgroundColor:'#fff',overflow:'hidden'},hidden:{height:0,opacity:0},fullScreenHeader:{backgroundColor:'#fff'},swipeEdge:{position:'absolute',left:0,top:0,bottom:0,width:70,backgroundColor:DEBUG_MODE?'rgba(255, 0, 0, 0.1)':'transparent'},webview:{flex:1,backgroundColor:DEBUG_MODE?'#f0f0f0':'transparent',borderWidth:DEBUG_MODE?1:0,borderColor:'blue'}});var _default=exports.default=BootpayWidget;
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Bootpay",{enumerable:true,get:function get(){return _Bootpay.Bootpay;}});Object.defineProperty(exports,"BootpayCommerce",{enumerable:true,get:function get(){return _BootpayCommerce.BootpayCommerce;}});Object.defineProperty(exports,"BootpayCommerceProps",{enumerable:true,get:function get(){return _CommerceTypes.BootpayCommerceProps;}});Object.defineProperty(exports,"BootpayEventData",{enumerable:true,get:function get(){return _BootpayTypes.BootpayEventData;}});Object.defineProperty(exports,"BootpayTypesProps",{enumerable:true,get:function get(){return _BootpayTypes.BootpayTypesProps;}});Object.defineProperty(exports,"BootpayWidget",{enumerable:true,get:function get(){return _BootpayWidget.BootpayWidget;}});Object.defineProperty(exports,"BootpayWidgetProps",{enumerable:true,get:function get(){return _WidgetTypes.BootpayWidgetProps;}});Object.defineProperty(exports,"CommerceEventData",{enumerable:true,get:function get(){return _CommerceTypes.CommerceEventData;}});Object.defineProperty(exports,"CommerceExtra",{enumerable:true,get:function get(){return _CommerceTypes.CommerceExtra;}});Object.defineProperty(exports,"CommercePayload",{enumerable:true,get:function get(){return _CommerceTypes.CommercePayload;}});Object.defineProperty(exports,"CommerceProduct",{enumerable:true,get:function get(){return _CommerceTypes.CommerceProduct;}});Object.defineProperty(exports,"CommerceUser",{enumerable:true,get:function get(){return _CommerceTypes.CommerceUser;}});Object.defineProperty(exports,"Extra",{enumerable:true,get:function get(){return _BootpayTypes.Extra;}});Object.defineProperty(exports,"Item",{enumerable:true,get:function get(){return _BootpayTypes.Item;}});Object.defineProperty(exports,"Payload",{enumerable:true,get:function get(){return _BootpayTypes.Payload;}});Object.defineProperty(exports,"User",{enumerable:true,get:function get(){return _BootpayTypes.User;}});Object.defineProperty(exports,"WidgetChangePaymentCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetChangePaymentCallback;}});Object.defineProperty(exports,"WidgetChangeTermsCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetChangeTermsCallback;}});Object.defineProperty(exports,"WidgetData",{enumerable:true,get:function get(){return _WidgetTypes.WidgetData;}});Object.defineProperty(exports,"WidgetExtra",{enumerable:true,get:function get(){return _WidgetTypes.WidgetExtra;}});Object.defineProperty(exports,"WidgetPayload",{enumerable:true,get:function get(){return _WidgetTypes.WidgetPayload;}});Object.defineProperty(exports,"WidgetPayloadExtra",{enumerable:true,get:function get(){return _WidgetTypes.WidgetPayloadExtra;}});Object.defineProperty(exports,"WidgetReadyCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetReadyCallback;}});Object.defineProperty(exports,"WidgetResizeCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetResizeCallback;}});Object.defineProperty(exports,"WidgetTerm",{enumerable:true,get:function get(){return _WidgetTypes.WidgetTerm;}});var _Bootpay=require("./Bootpay");var _BootpayWidget=require("./BootpayWidget");var _BootpayCommerce=require("./BootpayCommerce");var _BootpayTypes=require("./BootpayTypes");var _WidgetTypes=require("./WidgetTypes");var _CommerceTypes=require("./CommerceTypes");
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Bootpay",{enumerable:true,get:function get(){return _Bootpay.Bootpay;}});Object.defineProperty(exports,"BootpayCommerce",{enumerable:true,get:function get(){return _BootpayCommerce.BootpayCommerce;}});Object.defineProperty(exports,"BootpayCommerceProps",{enumerable:true,get:function get(){return _CommerceTypes.BootpayCommerceProps;}});Object.defineProperty(exports,"BootpayEventData",{enumerable:true,get:function get(){return _BootpayTypes.BootpayEventData;}});Object.defineProperty(exports,"BootpayTypesProps",{enumerable:true,get:function get(){return _BootpayTypes.BootpayTypesProps;}});Object.defineProperty(exports,"BootpayWidget",{enumerable:true,get:function get(){return _BootpayWidget.BootpayWidget;}});Object.defineProperty(exports,"BootpayWidgetProps",{enumerable:true,get:function get(){return _WidgetTypes.BootpayWidgetProps;}});Object.defineProperty(exports,"CommerceEventData",{enumerable:true,get:function get(){return _CommerceTypes.CommerceEventData;}});Object.defineProperty(exports,"CommerceExtra",{enumerable:true,get:function get(){return _CommerceTypes.CommerceExtra;}});Object.defineProperty(exports,"CommercePayload",{enumerable:true,get:function get(){return _CommerceTypes.CommercePayload;}});Object.defineProperty(exports,"CommerceProduct",{enumerable:true,get:function get(){return _CommerceTypes.CommerceProduct;}});Object.defineProperty(exports,"CommerceUser",{enumerable:true,get:function get(){return _CommerceTypes.CommerceUser;}});Object.defineProperty(exports,"Extra",{enumerable:true,get:function get(){return _BootpayTypes.Extra;}});Object.defineProperty(exports,"Item",{enumerable:true,get:function get(){return _BootpayTypes.Item;}});Object.defineProperty(exports,"Payload",{enumerable:true,get:function get(){return _BootpayTypes.Payload;}});Object.defineProperty(exports,"User",{enumerable:true,get:function get(){return _BootpayTypes.User;}});Object.defineProperty(exports,"WidgetChangePaymentCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetChangePaymentCallback;}});Object.defineProperty(exports,"WidgetChangeTermsCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetChangeTermsCallback;}});Object.defineProperty(exports,"WidgetData",{enumerable:true,get:function get(){return _WidgetTypes.WidgetData;}});Object.defineProperty(exports,"WidgetExtra",{enumerable:true,get:function get(){return _WidgetTypes.WidgetExtra;}});Object.defineProperty(exports,"WidgetPayload",{enumerable:true,get:function get(){return _WidgetTypes.WidgetPayload;}});Object.defineProperty(exports,"WidgetPayloadExtra",{enumerable:true,get:function get(){return _WidgetTypes.WidgetPayloadExtra;}});Object.defineProperty(exports,"WidgetReadyCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetReadyCallback;}});Object.defineProperty(exports,"WidgetResizeCallback",{enumerable:true,get:function get(){return _WidgetTypes.WidgetResizeCallback;}});Object.defineProperty(exports,"WidgetTerm",{enumerable:true,get:function get(){return _WidgetTypes.WidgetTerm;}});exports.warmUp=exports.releaseWarmUp=void 0;var _reactNative=require("react-native");var _Bootpay=require("./Bootpay");var _BootpayWidget=require("./BootpayWidget");var _BootpayCommerce=require("./BootpayCommerce");var _BootpayTypes=require("./BootpayTypes");var _WidgetTypes=require("./WidgetTypes");var _CommerceTypes=require("./CommerceTypes");var BPCWebViewModule=_reactNative.NativeModules.BPCWebViewModule;var _autoWarmUpCalled=false;var _autoWarmUp=function _autoWarmUp(){if(_autoWarmUpCalled)return;_autoWarmUpCalled=true;if(_reactNative.Platform.OS!=='ios'&&_reactNative.Platform.OS!=='android')return;try{if(BPCWebViewModule!=null&&BPCWebViewModule.warmUp){BPCWebViewModule.warmUp();if(__DEV__){console.log('[Bootpay] WebView auto warm-up initiated');}}}catch(e){}};var warmUp=exports.warmUp=function warmUp(){if(BPCWebViewModule!=null&&BPCWebViewModule.warmUp){BPCWebViewModule.warmUp();}};var releaseWarmUp=exports.releaseWarmUp=function releaseWarmUp(){if(BPCWebViewModule!=null&&BPCWebViewModule.releaseWarmUp){BPCWebViewModule.releaseWarmUp();}};_autoWarmUp();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bootpay-api",
|
|
3
|
-
"version": "13.13.
|
|
3
|
+
"version": "13.13.46",
|
|
4
4
|
"description": "React Native를 위한 bootpay 라이브러리 입니다.",
|
|
5
5
|
"main": "index.tsx",
|
|
6
6
|
"main-internal": "src/index.tsx",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-native-device-info": "^15.0.1",
|
|
43
43
|
"react-native-gesture-handler": "^2.20.0",
|
|
44
44
|
"react-native-keychain": "^10.0.0",
|
|
45
|
-
"react-native-webview-bootpay": "13.13.
|
|
45
|
+
"react-native-webview-bootpay": "13.13.49"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/cli": "^7.26.0",
|
package/src/Bootpay.tsx
CHANGED
|
@@ -317,6 +317,8 @@ export class Bootpay extends Component<BootpayTypesProps> {
|
|
|
317
317
|
injectedJavaScript={this.state.script}
|
|
318
318
|
javaScriptEnabled
|
|
319
319
|
javaScriptCanOpenWindowsAutomatically
|
|
320
|
+
useSharedProcessPool={true}
|
|
321
|
+
sharedCookiesEnabled={true}
|
|
320
322
|
onMessage={this.onMessage}
|
|
321
323
|
onError={(syntheticEvent) => {
|
|
322
324
|
const { nativeEvent } = syntheticEvent;
|
package/src/BootpayCommerce.tsx
CHANGED
|
@@ -394,6 +394,8 @@ export class BootpayCommerce extends Component<BootpayCommerceProps> {
|
|
|
394
394
|
source={{ uri: COMMERCE_URL }}
|
|
395
395
|
javaScriptEnabled
|
|
396
396
|
javaScriptCanOpenWindowsAutomatically
|
|
397
|
+
useSharedProcessPool={true}
|
|
398
|
+
sharedCookiesEnabled={true}
|
|
397
399
|
onMessage={this.onMessage}
|
|
398
400
|
onLoadEnd={this.onLoadEnd}
|
|
399
401
|
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
|
package/src/BootpayWidget.tsx
CHANGED
|
@@ -967,6 +967,8 @@ export class BootpayWidget extends Component<
|
|
|
967
967
|
source={{ uri: WIDGET_URL }}
|
|
968
968
|
javaScriptEnabled
|
|
969
969
|
javaScriptCanOpenWindowsAutomatically
|
|
970
|
+
useSharedProcessPool={true}
|
|
971
|
+
sharedCookiesEnabled={true}
|
|
970
972
|
injectedJavaScript={this.initialScript}
|
|
971
973
|
onLoadStart={() => {
|
|
972
974
|
if (DEBUG_MODE) {
|
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
1
2
|
import { Bootpay } from './Bootpay';
|
|
2
3
|
import { BootpayWidget } from './BootpayWidget';
|
|
3
4
|
import { BootpayCommerce } from './BootpayCommerce';
|
|
@@ -30,6 +31,77 @@ import {
|
|
|
30
31
|
BootpayCommerceProps,
|
|
31
32
|
} from './CommerceTypes';
|
|
32
33
|
|
|
34
|
+
const BPCWebViewModule = NativeModules.BPCWebViewModule;
|
|
35
|
+
|
|
36
|
+
// 자동 warmUp 상태 관리
|
|
37
|
+
let _autoWarmUpCalled = false;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 내부 자동 warmUp 함수
|
|
41
|
+
* 패키지 import 시 자동으로 호출되어 WebView 프로세스를 미리 초기화합니다.
|
|
42
|
+
*/
|
|
43
|
+
const _autoWarmUp = (): void => {
|
|
44
|
+
if (_autoWarmUpCalled) return;
|
|
45
|
+
_autoWarmUpCalled = true;
|
|
46
|
+
|
|
47
|
+
// iOS/Android에서만 동작
|
|
48
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') return;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
if (BPCWebViewModule?.warmUp) {
|
|
52
|
+
BPCWebViewModule.warmUp();
|
|
53
|
+
if (__DEV__) {
|
|
54
|
+
console.log('[Bootpay] WebView auto warm-up initiated');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// warmUp 실패해도 결제 기능에는 영향 없음
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* WebView 프로세스를 미리 초기화하여 첫 결제 화면 로딩 속도를 개선합니다.
|
|
64
|
+
*
|
|
65
|
+
* iOS: WKWebView의 첫 생성 시 GPU, Networking, WebContent 프로세스 초기화에 3-7초 소요
|
|
66
|
+
* Android: Chromium 엔진 초기화에 200-300ms 소요
|
|
67
|
+
*
|
|
68
|
+
* 참고: SDK import 시 자동으로 warmUp이 호출되므로, 일반적으로 명시적 호출이 필요하지 않습니다.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* // 자동 warmUp이 기본 동작이므로, 별도 호출 불필요
|
|
73
|
+
* // 필요한 경우에만 명시적으로 호출
|
|
74
|
+
* import { warmUp } from 'react-native-bootpay-api';
|
|
75
|
+
* warmUp();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export const warmUp = (): void => {
|
|
79
|
+
if (BPCWebViewModule?.warmUp) {
|
|
80
|
+
BPCWebViewModule.warmUp();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 프리워밍된 WebView 리소스를 해제합니다.
|
|
86
|
+
* 메모리가 부족할 때 호출할 수 있습니다.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* import { releaseWarmUp } from 'react-native-bootpay-api';
|
|
91
|
+
*
|
|
92
|
+
* // 메모리 정리가 필요할 때
|
|
93
|
+
* releaseWarmUp();
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const releaseWarmUp = (): void => {
|
|
97
|
+
if (BPCWebViewModule?.releaseWarmUp) {
|
|
98
|
+
BPCWebViewModule.releaseWarmUp();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// 패키지 import 시 자동으로 warmUp 실행
|
|
103
|
+
_autoWarmUp();
|
|
104
|
+
|
|
33
105
|
export {
|
|
34
106
|
// 기존 결제 컴포넌트
|
|
35
107
|
Bootpay,
|