-
Notifications
You must be signed in to change notification settings - Fork 176
/
pingpp.js
2 lines (2 loc) · 31.2 KB
/
pingpp.js
1
2
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pingpp=e()}(function(){return function t(r,l,i){function c(a,e){if(!l[a]){if(!r[a]){var n="function"==typeof require&&require;if(!e&&n)return n(a,!0);if(o)return o(a,!0);throw(n=new Error("Cannot find module '"+a+"'")).code="MODULE_NOT_FOUND",n}n=l[a]={exports:{}},r[a][0].call(n.exports,function(e){return c(r[a][1][e]||e)},n,n.exports,t,r,l,i)}return l[a].exports}for(var o="function"==typeof require&&require,e=0;e<i.length;e++)c(i[e]);return c}({1:[function(e,a,n){var t={}.hasOwnProperty,r=e('./callbacks'),l=e('./utils');a.exports={signAgreement:function(e){if('string'==typeof e)try{a=JSON.parse(e)}catch(e){return r.innerAgreementCallback('fail',r.error('json_decode_fail',e)),!1}else a=e;if(void 0===a)return r.innerAgreementCallback('fail',r.error('json_decode_fail')),!1;if(!t.call(a,'object')||'agreement'!==a.object||!t.call(a,'channel')||!t.call(a,'credential')||'object'!=typeof a.credential)return r.innerAgreementCallback('fail',r.error('invalid_object')),!1;if(!t.call(a.credential,a.channel))return r.innerAgreementCallback('fail',r.error('invalid_credential')),!1;var a,n,e=a.credential[a.channel];return'string'==typeof e?n=e:t.call(e,'credential')&&'string'==typeof e.credential&&(n=e.credential),void 0===n?(r.innerAgreementCallback('fail',r.error('invalid_credential')),!1):('alipay'===a.channel.substring(0,6)&&l.deviceDetectorMobile()&&(a=new URL(n),n='https://d.alipay.com/i/index.htm?iframeSrc='+encodeURIComponent("alipays://platformapi/startapp?appId=60000157&appClearTop=false&startMultApp=YES&sign_params="+encodeURIComponent(a.search.substring(1)))),setTimeout(function(){l.redirectTo(n)},0),!0)}}},{"./callbacks":2,"./utils":55}],2:[function(n,e,a){e.exports={userCallback:void 0,urlReturnCallback:void 0,urlReturnChannels:['alipay_pc_direct'],userAgreementCallback:void 0,innerCallback:function(e,a){'function'==typeof this.userCallback&&(void 0===a&&(a=this.error()),this.userCallback(e,a),this.userCallback=void 0,n('./payment_elements').clear())},error:function(e,a){return{msg:e=void 0===e?'':e,extra:a=void 0===a?'':a}},triggerUrlReturnCallback:function(e,a){'function'==typeof this.urlReturnCallback&&this.urlReturnCallback(e,a)},shouldReturnUrlByCallback:function(e){return'function'==typeof this.urlReturnCallback&&-1!==this.urlReturnChannels.indexOf(e)},innerAgreementCallback:function(e,a){'function'==typeof this.userAgreementCallback&&(void 0===a&&(a=this.error()),this.userAgreementCallback(e,a),this.userAgreementCallback=void 0)}}},{"./payment_elements":52}],3:[function(e,a,n){var t=e('../utils'),r=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?t.redirectTo(a,e.channel):r.innerCallback('fail',r.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":55}],4:[function(e,a,n){arguments[4][3][0].apply(n,arguments)},{"../callbacks":2,"../utils":55,dup:3}],5:[function(e,a,n){var t=e('../callbacks'),r={}.hasOwnProperty;a.exports={PINGPP_NOTIFY_URL_BASE:'https://notify.pingxx.com/notify',handleCharge:function(e){e=e.credential[e.channel];e||r.call(e,'orderInfo')?this.callpay(e.orderInfo):t.innerCallback('fail',t.error('invalid_credential','missing_alipay'))},alipayLiteEnabled:function(){return'undefined'!=typeof my&&my.tradePay},callpay:function(e){var a=this;if(this.alipayLiteEnabled())return this.alipayLitePay(e);if('undefined'!=typeof navigator&&/AlipayClient/.test(navigator.userAgent||navigator.swuserAgent))return this.waitAlipayJSBridgde(function(){a.alipayJsBridgePay(e)});var n='请在支付宝小程序或者支付宝应用内中打开';console.log(n),t.innerCallback('fail',t.error(n))},waitAlipayJSBridgde:function(e){window.AlipayJSBridge?e&&e():document.addEventListener('AlipayJSBridgeReady',e,!1)},alipayJsBridgePay:function(e){AlipayJSBridge.call('tradePay',{orderStr:e},this.alipayResultHandler)},alipayLitePay:function(e){var a={};a.orderStr=e,a.complete=this.alipayResultHandler,my.tradePay(a)},alipayResultHandler:function(e){var a={resultCode:e.resultCode};r.call(e,'memo')&&(a.memo=e.memo),r.call(e,'result')&&(a.result=e.result),'9000'==e.resultCode?t.innerCallback('success',t.error('',a)):'6001'==e.resultCode?t.innerCallback('cancel',t.error('用户取消支付',a)):t.innerCallback('fail',t.error('支付失败',a))},runTestMode:function(e){e='/charges/'+e.id;my.httpRequest({url:this.PINGPP_NOTIFY_URL_BASE+e+'?livemode=false',success:function(e){'success'==e.data?t.innerCallback('success'):t.innerCallback('fail',t.error('testmode_notify_fail'))},fail:function(){t.innerCallback('fail',t.error('network_err'))}})}}},{"../callbacks":2}],6:[function(e,a,n){var t=e('../callbacks');a.exports={PINGPP_NOTIFY_URL_BASE:'https://notify.pingxx.com/notify',handleCharge:function(e){e=e.credential[e.channel];e?this.callpay(e):t.innerCallback('fail',t.error('invalid_credential','missing_alipay_lite'))},alipayLiteEnabled:function(){return'undefined'!=typeof my&&my.tradePay},callpay:function(e){var a;this.alipayLiteEnabled()?((a={}).tradeNO=e,a.complete=function(e){9e3==e.resultCode?t.innerCallback('success'):6001==e.resultCode?t.innerCallback('cancel',t.error('用户取消支付')):t.innerCallback('fail',t.error('支付失败'))},my.tradePay(a)):console.log('请在支付宝小程序中打开')},runTestMode:function(e){e='/charges/'+e.id;my.httpRequest({url:this.PINGPP_NOTIFY_URL_BASE+e+'?livemode=false',success:function(e){'success'==e.data?t.innerCallback('success'):t.innerCallback('fail',t.error('testmode_notify_fail'))},fail:function(){t.innerCallback('fail',t.error('network_err'))}})}}},{"../callbacks":2}],7:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={ALIPAY_PC_DIRECT_URL:'https://mapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,n=e.credential[a],e=this.ALIPAY_PC_DIRECT_URL;r.call(n,'channel_url')&&(e=n.channel_url),r.call(n,'_input_charset')||r.call(n,'service')&&'create_direct_pay_by_user'===n.service&&(n._input_charset='utf-8');n=t.stringifyData(n,a,!0);t.redirectTo(e+'?'+n,a)}}},{"../utils":55}],8:[function(e,a,n){var t={}.hasOwnProperty,r=e('../callbacks');a.exports={handleCharge:function(e){e=e.credential[e.channel];t.call(e,'transaction_no')?this.tradePay(e.transaction_no):r.innerCallback('fail',r.error('invalid_credential','missing_field_transaction_no'))},ready:function(e){window.AlipayJSBridge?e&&e():document.addEventListener('AlipayJSBridgeReady',e,!1)},tradePay:function(e){this.ready(function(){AlipayJSBridge.call('tradePay',{tradeNO:e},function(e){'9000'==e.resultCode?r.innerCallback('success'):'6001'==e.resultCode?r.innerCallback('cancel',r.error(e.result)):r.innerCallback('fail',r.error(e.result))})})}}},{"../callbacks":2}],9:[function(e,a,n){var t=e('./commons/redirect_base');a.exports={handleCharge:function(e){t.handleCharge(e)}}},{"./commons/redirect_base":25}],10:[function(e,a,n){var t=e('../utils'),r=e('../mods'),l={}.hasOwnProperty;a.exports={ALIPAY_WAP_URL_OLD:'https://wappaygw.alipay.com/service/rest.htm',ALIPAY_WAP_URL:'https://mapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,n=e.credential[a],e=this.ALIPAY_WAP_URL;l.call(n,'req_data')?e=this.ALIPAY_WAP_URL_OLD:l.call(n,'channel_url')&&(e=n.channel_url),l.call(n,'_input_charset')||(l.call(n,'service')&&'alipay.wap.create.direct.pay.by.user'===n.service||l.call(n,'req_data'))&&(n._input_charset='utf-8');e=e+'?'+t.stringifyData(n,a,!0),n=r.getExtraModule('ap');t.inWeixin()&&void 0!==n?n.pay(e):t.redirectTo(e,a)}}},{"../mods":51,"../utils":55}],11:[function(e,a,n){arguments[4][9][0].apply(n,arguments)},{"./commons/redirect_base":25,dup:9}],12:[function(e,a,n){var t=e('../utils'),r=e('../callbacks'),l={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.channel,e=e.credential[a];l.call(e,'url')?t.redirectTo(e.url+'?'+t.stringifyData(e,a),a):r.innerCallback('fail',r.error('invalid_credential','missing_field:url'))}}},{"../callbacks":2,"../utils":55}],13:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={ALIPAY_PC_DIRECT_URL:'https://intlmapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,n=e.credential[a],e=this.ALIPAY_PC_DIRECT_URL;r.call(n,'channel_url')&&(e=n.channel_url),r.call(n,'_input_charset')||r.call(n,'service')&&'create_forex_trade'===n.service&&(n._input_charset='utf-8');n=t.stringifyData(n,a,!0);t.redirectTo(e+'?'+n,a)}}},{"../utils":55}],14:[function(e,a,n){var t=e('../utils'),r=e('../mods'),l={}.hasOwnProperty;a.exports={ALIPAY_WAP_URL:'https://intlmapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,n=e.credential[a],e=this.ALIPAY_WAP_URL;l.call(n,'channel_url')&&(e=n.channel_url),l.call(n,'_input_charset')||l.call(n,'service')&&'create_forex_trade_wap'===n.service&&(n._input_charset='utf-8');e=e+'?'+t.stringifyData(n,a,!0),n=r.getExtraModule('ap');t.inWeixin()&&void 0!==n?n.pay(e):t.redirectTo(e,a)}}},{"../mods":51,"../utils":55}],15:[function(e,a,n){var r=e('../callbacks'),t=e('../utils'),l=e('../stash'),i=e('../mods'),c={}.hasOwnProperty;a.exports={PINGPP_NOTIFY_URL_BASE:'https://notify.pingxx.com/notify',handleCharge:function(e){for(var a=e.credential[e.channel],n=['appId','timeStamp','nonceStr','package','signType','paySign'],t=0;t<n.length;t++)if(!c.call(a,n[t]))return void r.innerCallback('fail',r.error('invalid_credential','missing_field_'+n[t]));l.jsApiParameters=a,this.callpay()},callpay:function(){var e=this,a=i.getExtraModule('wx_jssdk');void 0!==a&&a.jssdkEnabled()?a.callpay():'undefined'==typeof WeixinJSBridge?(a=function(){e.jsApiCall()},document.addEventListener?document.addEventListener('WeixinJSBridgeReady',a,!1):document.attachEvent&&(document.attachEvent('WeixinJSBridgeReady',a),document.attachEvent('onWeixinJSBridgeReady',a))):this.jsApiCall()},jsApiCall:function(){c.call(l,'jsApiParameters')&&WeixinJSBridge.invoke('getBrandWCPayRequest',l.jsApiParameters,function(e){delete l.jsApiParameters,'get_brand_wcpay_request:ok'==e.err_msg?r.innerCallback('success'):'get_brand_wcpay_request:cancel'==e.err_msg?r.innerCallback('cancel'):r.innerCallback('fail',r.error('wx_result_fail',e.err_msg))})},runTestMode:function(e){confirm('模拟付款?')&&(e='/charges/'+e.id,t.request(this.PINGPP_NOTIFY_URL_BASE+e+'?livemode=false','GET',null,function(e,a){200<=a&&a<400&&'success'==e?r.innerCallback('success'):r.innerCallback('fail',r.error('testmode_notify_fail','http_code:'+a+';response:'+e))},function(){r.innerCallback('fail',r.error('network_err'))}))}}},{"../callbacks":2,"../mods":51,"../stash":53,"../utils":55}],16:[function(e,a,n){arguments[4][9][0].apply(n,arguments)},{"./commons/redirect_base":25,dup:9}],17:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty,l=e('../callbacks');a.exports={CCB_WAP_URL_BASE:'https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?',handleCharge:function(e){var a=e.channel,e=e.credential[a];r.call(e,'orderinfo')?(e=this.CCB_WAP_URL_BASE+e.orderinfo,t.redirectTo(e,a)):l.innerCallback('fail',l.error('invalid_credential','missing_field:orderinfo'))}}},{"../callbacks":2,"../utils":55}],18:[function(e,a,n){var t=e('../utils'),r=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?t.redirectTo(a,e.channel):r.innerCallback('fail',r.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":55}],19:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":55,dup:18}],20:[function(e,a,n){var t=e('../utils'),r=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?t.redirectTo(a,e.channel):r.innerCallback('fail',r.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":55}],21:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":55,dup:18}],22:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":55,dup:18}],23:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={handleCharge:function(e){var a,n=e.channel,n=e.credential[n];r.call(n,'channel_url')&&(a=n.channel_url,delete n.channel_url),t.formSubmit(a,'post',n)}}},{"../utils":55}],24:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={CMB_WALLET_URL:'https://netpay.cmbchina.com/netpayment/BaseHttp.dll?MB_EUserPay',handleCharge:function(e){var a=e.credential[e.channel],e=this.CMB_WALLET_URL;r.call(a,'ChannelUrl')&&(e=a.ChannelUrl,delete a.ChannelUrl),r.call(a,'channelVersion')&&delete a.channelVersion,t.formSubmit(e,'post',a)}}},{"../utils":55}],25:[function(e,a,n){var t=e('../../utils'),r=e('../../callbacks'),l={}.hasOwnProperty;a.exports={handleCharge:function(e){var a,n=e.credential[e.channel];if('string'==typeof n)a=n;else{if(!l.call(n,'url'))return void r.innerCallback('fail',r.error('invalid_credential','credential format is incorrect'));a=n.url}t.redirectTo(a,e.channel)}}},{"../../callbacks":2,"../../utils":55}],26:[function(e,a,n){var t=e('../utils');a.exports={CP_B2B_URL:'https://payment.chinapay.com/CTITS/service/rest/page/nref/000000000017/0/0/0/0/0',handleCharge:function(e){e=e.credential[e.channel];t.formSubmit(this.CP_B2B_URL,'post',e)}}},{"../utils":55}],27:[function(e,a,n){var t,o,r=e('../../stash'),l={}.hasOwnProperty;o={PADCHAR:'=',ALPHA:'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',makeDOMException:function(){try{return new DOMException(DOMException.INVALID_CHARACTER_ERR)}catch(e){var a=new Error('DOM Exception 5');return a.code=a.number=5,a.name=a.description='INVALID_CHARACTER_ERR',a.toString=function(){return'Error: '+a.name+': '+a.message},a}},getbyte64:function(e,a){a=o.ALPHA.indexOf(e.charAt(a));if(-1===a)throw o.makeDOMException();return a},decode:function(e){var a,n,t=o.getbyte64,r=(e=''+e).length;if(0===r)return e;if(r%4!=0)throw o.makeDOMException();a=0,e.charAt(r-1)===o.PADCHAR&&(a=1,e.charAt(r-2)===o.PADCHAR&&(a=2),r-=4);for(var l=[],i=0;i<r;i+=4)n=t(e,i)<<18|t(e,i+1)<<12|t(e,i+2)<<6|t(e,i+3),l.push(String.fromCharCode(n>>16,n>>8&255,255&n));switch(a){case 1:n=t(e,i)<<18|t(e,i+1)<<12|t(e,i+2)<<6,l.push(String.fromCharCode(n>>16,n>>8&255));break;case 2:n=t(e,i)<<18|t(e,i+1)<<12,l.push(String.fromCharCode(n>>16))}return l.join('')},getbyte:function(e,a){a=e.charCodeAt(a);if(255<a)throw o.makeDOMException();return a},encode:function(e){if(1!==arguments.length)throw new SyntaxError('Not enough arguments');var a,n,t=o.PADCHAR,r=o.ALPHA,l=o.getbyte,i=[],c=(e=''+e).length-e.length%3;if(0===e.length)return e;for(a=0;a<c;a+=3)n=l(e,a)<<16|l(e,a+1)<<8|l(e,a+2),i.push(r.charAt(n>>18)),i.push(r.charAt(n>>12&63)),i.push(r.charAt(n>>6&63)),i.push(r.charAt(63&n));switch(e.length-c){case 1:n=l(e,a)<<16,i.push(r.charAt(n>>18)+r.charAt(n>>12&63)+t+t);break;case 2:n=l(e,a)<<16|l(e,a+1)<<8,i.push(r.charAt(n>>18)+r.charAt(n>>12&63)+r.charAt(n>>6&63)+t)}return i.join('')}},(t={}).url='pay.htm',t.pay=function(e){e=encodeURIComponent(o.encode(e));l.call(r,'APURL')&&(t.url=r.APURL),location.href=t.url+'?goto='+e},t.decode=function(e){return o.decode(decodeURIComponent(e))},a.exports=t},{"../../stash":53}],28:[function(e,a,n){e=e('./wx_lite');a.exports=e},{"./wx_lite":39}],29:[function(e,a,n){var t=e('./commons/redirect_base'),r=e('../callbacks'),l=e('../utils'),i={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.extra;i.call(a,'pay_channel')?'wx'!==(a=a.pay_channel)||l.inWeixin()?'alipay'!==a||l.inAlipay()?t.handleCharge(e):r.innerCallback('fail',r.error('Not in the Alipay browser')):r.innerCallback('fail',r.error('Not in the WeChat browser')):r.innerCallback('fail',r.error('invalid_charge','charge 格式不正确'))}}},{"../callbacks":2,"../utils":55,"./commons/redirect_base":25}],30:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={JDPAY_WAP_URL_OLD:'https://m.jdpay.com/wepay/web/pay',JDPAY_H5_URL:'https://h5pay.jd.com/jdpay/saveOrder',JDPAY_PC_URL:'https://wepay.jd.com/jdpay/saveOrder',handleCharge:function(e){var a=e.credential[e.channel],e=this.JDPAY_H5_URL;r.call(a,'channelUrl')?(e=a.channelUrl,delete a.channelUrl):r.call(a,'merchantRemark')&&(e=this.JDPAY_WAP_URL_OLD),t.formSubmit(e,'post',a)}}},{"../utils":55}],31:[function(e,a,n){var t=e('../utils'),r={}.hasOwnProperty;a.exports={handleCharge:function(e){e=e.credential[e.channel];r.call(e,'bankUrl')&&(request_url=e.bankUrl,delete e.bankUrl),t.formSubmit(request_url,'post',e)}}},{"../utils":55}],32:[function(e,a,n){arguments[4][31][0].apply(n,arguments)},{"../utils":55,dup:31}],33:[function(e,a,n){var t=e('../utils');a.exports={handleCharge:function(e){var a=e.credential[e.channel],e=a.channelUrl;delete a.channelUrl,t.formSubmit(e,'post',a)}}},{"../utils":55}],34:[function(e,a,n){var t=e('../utils');a.exports={handleCharge:function(e){var a=e.credential[e.channel];t.redirectTo(a,e.channel)}}},{"../utils":55}],35:[function(e,a,n){var t=e('../callbacks'),r=e('../utils'),l=e('../stash'),i={}.hasOwnProperty;a.exports={SRC_URL:'https://open.mobile.qq.com/sdk/qqapi.js?_bid=152',ID:'mqq_api',handleCharge:function(e){e=e.credential[e.channel];i.call(e,'token_id')?(l.tokenId=e.token_id,r.loadUrlJs(this.ID,this.SRC_URL,this.callpay)):t.innerCallback('fail',t.error('invalid_credential','missing_token_id'))},callpay:function(){if('undefined'!=typeof mqq){if(0==mqq.QQVersion)return t.innerCallback('fail',t.error('Not in the QQ client')),void delete l.tokenId;mqq.tenpay.pay({tokenId:l.tokenId},function(e){0==e.resultCode?t.innerCallback('success'):t.innerCallback('fail',t.error(e.retmsg))})}else t.innerCallback('fail',t.error('network_err'));delete l.tokenId}}},{"../callbacks":2,"../stash":53,"../utils":55}],36:[function(e,a,n){arguments[4][23][0].apply(n,arguments)},{"../utils":55,dup:23}],37:[function(e,a,n){var t=e('../utils');a.exports={UPACP_PC_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){e=e.credential[e.channel];t.formSubmit(this.UPACP_PC_URL,'post',e)}}},{"../utils":55}],38:[function(e,a,n){var t=e('../utils');a.exports={UPACP_WAP_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){e=e.credential[e.channel];t.formSubmit(this.UPACP_WAP_URL,'post',e)}}},{"../utils":55}],39:[function(e,a,n){var r=e('../stash'),l=e('../callbacks'),i={}.hasOwnProperty;a.exports={PINGPP_NOTIFY_URL_BASE:'https://notify.pingxx.com/notify',handleCharge:function(e){for(var a=e.credential[e.channel],n=['appId','timeStamp','nonceStr','package','signType','paySign'],t=0;t<n.length;t++)if(!i.call(a,n[t]))return void l.innerCallback('fail',l.error('invalid_credential','missing_field_'+n[t]));r.jsApiParameters=a,this.callpay()},wxLiteEnabled:function(){return'undefined'!=typeof wx&&wx.requestPayment},callpay:function(){var e;this.wxLiteEnabled()?(delete(e=r.jsApiParameters).appId,e.complete=function(e){'requestPayment:ok'===e.errMsg&&l.innerCallback('success'),'requestPayment:cancel'!==e.errMsg&&'requestPayment:fail cancel'!==e.errMsg||l.innerCallback('cancel',l.error('用户取消支付')),'undefined'!==e.err_code&&'undefined'!==e.err_desc&&l.innerCallback('fail',l.error(e.err_desc,e))},wx.requestPayment(e)):console.log('请在微信小程序中打开')},runTestMode:function(e){e='/charges/'+e.id;wx.request({url:this.PINGPP_NOTIFY_URL_BASE+e+'?livemode=false',success:function(e){'success'==e.data?l.innerCallback('success'):l.innerCallback('fail',l.error('testmode_notify_fail'))},fail:function(){l.innerCallback('fail',l.error('network_err'))}})}}},{"../callbacks":2,"../stash":53}],40:[function(e,a,n){arguments[4][28][0].apply(n,arguments)},{"./wx_lite":39,dup:28}],41:[function(e,a,n){arguments[4][15][0].apply(n,arguments)},{"../callbacks":2,"../mods":51,"../stash":53,"../utils":55,dup:15}],42:[function(e,a,n){e=e('./wx_pub');a.exports=e},{"./wx_pub":41}],43:[function(e,a,n){var t=e('../utils'),r=e('../callbacks'),l={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?t.redirectTo(a,e.channel):'object'==typeof a&&l.call(a,'url')?t.redirectTo(a.url,e.channel):r.innerCallback('fail',r.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":55}],44:[function(e,a,n){var i=e('../utils'),c=e('../callbacks'),o={}.hasOwnProperty;a.exports={YEEPAY_WAP_URL:'https://ok.yeepay.com/paymobile/api/pay/request',YEEPAY_WAP_TEST_URL:'https://mobiletest.yeepay.com/paymobile/api/pay/request',handleCharge:function(e){for(var a,n=e.channel,t=e.credential[n],r=['merchantaccount','encryptkey','data'],l=0;l<r.length;l++)if(!o.call(t,r[l]))return void c.innerCallback('fail',c.error('invalid_credential','missing_field_'+r[l]));a=o.call(t,'mode')&&'test'==t.mode?this.YEEPAY_WAP_TEST_URL:this.YEEPAY_WAP_URL,i.redirectTo(a+'?'+i.stringifyData(t,n,!0),e.channel)}}},{"../callbacks":2,"../utils":55}],45:[function(e,a,n){e=e('./wx_lite');a.exports=e},{"./wx_lite":39}],46:[function(e,a,n){arguments[4][45][0].apply(n,arguments)},{"./wx_lite":39,dup:45}],47:[function(e,a,n){arguments[4][42][0].apply(n,arguments)},{"./wx_pub":41,dup:42}],48:[function(e,a,n){a.exports={Error:function(e,a){this.message=e,this.extra=a}}},{}],49:[function(e,a,n){var t=e('./stash'),r=e('./utils');a.exports={init:function(){var e=this;r.documentReady(function(){try{r.inWxLite()||r.inAlipayLite()||e.initPuid()}catch(e){}})},initPuid:function(){if('undefined'!=typeof window&&'undefined'!=typeof localStorage&&null!==localStorage){var e=localStorage.getItem('pingpp_uid');if(null===e){e=r.randomString();try{localStorage.setItem('pingpp_uid',e)}catch(e){}}t.puid=e}}}},{"./stash":53,"./utils":55}],50:[function(e,a,n){function PingppSDK(){e('./init').init()}var t=e('./version').v,r={}.hasOwnProperty;PingppSDK.prototype.version=t,a.exports=new PingppSDK;var l=e('./testmode'),i=e('./callbacks'),c=e('./errors').Error,o=e('./mods'),s=e('./stash'),u=e('./payment_elements');PingppSDK.prototype.createPayment=function(e,a,n,t){'function'==typeof a&&(i.userCallback=a);try{u.init(e)}catch(e){if(e instanceof c)return void i.innerCallback('fail',i.error(e.message,e.extra));throw e}if(r.call(u,'id'))if(r.call(u,'channel')){r.call(u,'app')&&('string'==typeof u.app?s.app_id=u.app:'object'==typeof u.app&&'string'==typeof u.app.id&&(s.app_id=u.app.id));a=u.channel;if(r.call(u,'credential'))if(u.paid&&0===u.actual_amount)i.innerCallback('success');else if(u.credential)if(r.call(u.credential,a))if(r.call(u,'livemode')){e=o.getChannelModule(a);if(void 0===e)return console.error('channel module "'+a+'" is undefined'),void i.innerCallback('fail',i.error('invalid_channel','channel module "'+a+'" is undefined'));!1!==u.livemode?(void 0!==n&&(s.signature=n),'boolean'==typeof t&&(s.debug=t),e.handleCharge(u)):(r.call(e,'runTestMode')?e:l).runTestMode(u)}else i.innerCallback('fail',i.error('invalid_charge','no_livemode_field'));else i.innerCallback('fail',i.error('invalid_credential','credential_is_incorrect'));else i.innerCallback('fail',i.error('invalid_credential','credential_is_undefined'));else i.innerCallback('fail',i.error('invalid_charge','no_credential'))}else i.innerCallback('fail',i.error('invalid_charge','no_channel'));else i.innerCallback('fail',i.error('invalid_charge','no_charge_id'))},PingppSDK.prototype.setAPURL=function(e){s.APURL=e},PingppSDK.prototype.setUrlReturnCallback=function(e,a){if('function'!=typeof e)throw'callback need to be a function';if(i.urlReturnCallback=e,void 0!==a){if(!Array.isArray(a))throw'channels need to be an array';i.urlReturnChannels=a}},PingppSDK.prototype.signAgreement=function(e,a){'function'==typeof a&&(i.userAgreementCallback=a);a=o.getExtraModule('agreement');return void 0===a?(console.error('module "agreement" is undefined'),i.innerCallback('fail',i.error('invalid_module','module "agreement" is undefined')),!1):a.signAgreement(e)}},{"./callbacks":2,"./errors":48,"./init":49,"./mods":51,"./payment_elements":52,"./stash":53,"./testmode":54,"./version":56}],51:[function(e,a,n){var t={}.hasOwnProperty,r={};(a.exports=r).channels={alipay:e('./channels/alipay'),alipay_lite:e('./channels/alipay_lite'),abc_pay:e('./channels/abc_pay'),abc_pub:e('./channels/abc_pub'),alipay_pc_direct:e('./channels/alipay_pc_direct'),alipay_qr:e('./channels/alipay_qr'),alipay_qr_lakala:e('./channels/alipay_qr_lakala'),alipay_wap:e('./channels/alipay_wap'),alipay_wap_lakala:e('./channels/alipay_wap_lakala'),bfb_wap:e('./channels/bfb_wap'),cb_alipay_pc_direct:e('./channels/cb_alipay_pc_direct'),cb_alipay_wap:e('./channels/cb_alipay_wap'),cb_wx_pub:e('./channels/cb_wx_pub'),ccb_qr:e('./channels/ccb_qr'),ccb_wap:e('./channels/ccb_wap'),chinaums_alipay_pub:e('./channels/chinaums_alipay_pub'),chinaums_alipay_wap:e('./channels/chinaums_alipay_wap'),chinaums_upacp_wap:e('./channels/chinaums_upacp_wap'),chinaums_wx_pub:e('./channels/chinaums_wx_pub'),chinaums_wx_wap:e('./channels/chinaums_wx_wap'),cmb_pc_qr:e('./channels/cmb_pc_qr'),cmb_wallet:e('./channels/cmb_wallet'),cp_b2b:e('./channels/cp_b2b'),isv_lite:e('./channels/isv_lite'),isv_wap:e('./channels/isv_wap'),jdpay_wap:e('./channels/jdpay_wap'),nucc_b2b_lakala:e('./channels/nucc_b2b_lakala'),nucc_b2c_lakala:e('./channels/nucc_b2c_lakala'),pab_pc:e('./channels/pab_pc'),paypal:e('./channels/paypal'),qpay_pub:e('./channels/qpay_pub'),upacp_b2b:e('./channels/upacp_b2b'),upacp_pc:e('./channels/upacp_pc'),upacp_wap:e('./channels/upacp_wap'),wx_lite:e('./channels/wx_lite'),wx_lite_pab:e('./channels/wx_lite_pab'),wx_pub:e('./channels/wx_pub'),wx_pub_pab:e('./channels/wx_pub_pab'),wx_wap:e('./channels/wx_wap'),yeepay_wap:e('./channels/yeepay_wap'),yeepay_wx_pub:e('./channels/yeepay_wx_pub'),yeepay_wx_pub_ofl:e('./channels/yeepay_wx_pub'),yeepay_wx_lite:e('./channels/yeepay_wx_lite'),yeepay_wx_lite_ofl:e('./channels/yeepay_wx_lite_ofl')},r.extras={ap:e('./channels/extras/ap'),agreement:e('./agreement')},r.getChannelModule=function(e){if(t.call(r.channels,e))return r.channels[e]},r.getExtraModule=function(e){if(t.call(r.extras,e))return r.extras[e]}},{"./agreement":1,"./channels/abc_pay":3,"./channels/abc_pub":4,"./channels/alipay":5,"./channels/alipay_lite":6,"./channels/alipay_pc_direct":7,"./channels/alipay_qr":8,"./channels/alipay_qr_lakala":9,"./channels/alipay_wap":10,"./channels/alipay_wap_lakala":11,"./channels/bfb_wap":12,"./channels/cb_alipay_pc_direct":13,"./channels/cb_alipay_wap":14,"./channels/cb_wx_pub":15,"./channels/ccb_qr":16,"./channels/ccb_wap":17,"./channels/chinaums_alipay_pub":18,"./channels/chinaums_alipay_wap":19,"./channels/chinaums_upacp_wap":20,"./channels/chinaums_wx_pub":21,"./channels/chinaums_wx_wap":22,"./channels/cmb_pc_qr":23,"./channels/cmb_wallet":24,"./channels/cp_b2b":26,"./channels/extras/ap":27,"./channels/isv_lite":28,"./channels/isv_wap":29,"./channels/jdpay_wap":30,"./channels/nucc_b2b_lakala":31,"./channels/nucc_b2c_lakala":32,"./channels/pab_pc":33,"./channels/paypal":34,"./channels/qpay_pub":35,"./channels/upacp_b2b":36,"./channels/upacp_pc":37,"./channels/upacp_wap":38,"./channels/wx_lite":39,"./channels/wx_lite_pab":40,"./channels/wx_pub":41,"./channels/wx_pub_pab":42,"./channels/wx_wap":43,"./channels/yeepay_wap":44,"./channels/yeepay_wx_lite":45,"./channels/yeepay_wx_lite_ofl":46,"./channels/yeepay_wx_pub":47}],52:[function(e,a,n){var l=e('./errors').Error,i={}.hasOwnProperty;a.exports={id:null,or_id:null,channel:null,app:null,credential:{},extra:null,livemode:null,order_no:null,time_expire:null,paid:!1,status:null,actual_amount:null,init:function(e){var a,n;if('string'==typeof e)try{a=JSON.parse(e)}catch(e){throw new l('json_decode_fail',e)}else a=e;if(void 0===a)throw new l('json_decode_fail');if(i.call(a,'object')&&'order'==a.object){a.or_id=a.id,a.order_no=a.merchant_order_no;var t=a.charge_essentials;if(a.channel=t.channel,a.credential=t.credential,a.extra=t.extra,i.call(a,'charge')&&null!=a.charge)a.id=a.charge;else if(i.call(t,'id')&&null!=t.id)a.id=t.id;else if(i.call(a,'charges'))for(var r=0;r<a.charges.data.length;r++)if(a.charges.data[r].channel===t.channel){a.id=a.charges.data[r].id;break}}else i.call(a,'object')&&'recharge'==a.object&&(a=a.charge);for(n in this)i.call(a,n)&&(this[n]=a[n]);return this},clear:function(){for(var e in this)'function'!=typeof this[e]&&(this[e]=null)}}},{"./errors":48}],53:[function(e,a,n){a.exports={}},{}],54:[function(e,a,n){var t=e('./utils'),r={}.hasOwnProperty;a.exports={PINGPP_MOCK_URL:'https://sissi.pingxx.com/mock.php',runTestMode:function(e){var a={ch_id:e.id,scheme:'http',channel:e.channel};r.call(e,'order_no')?a.order_no=e.order_no:r.call(e,'orderNo')&&(a.order_no=e.orderNo),r.call(e,'time_expire')?a.time_expire=e.time_expire:r.call(e,'timeExpire')&&(a.time_expire=e.timeExpire),r.call(e,'extra')&&(a.extra=encodeURIComponent(JSON.stringify(e.extra))),t.redirectTo(this.PINGPP_MOCK_URL+'?'+t.stringifyData(a),e.channel)}}},{"./utils":55}],55:[function(e,a,n){var t=e('./callbacks'),o={}.hasOwnProperty,s=a.exports={stringifyData:function(e,a,n){void 0===n&&(n=!1);var t,r=[];for(t in e)o.call(e,t)&&'function'!=typeof e[t]&&('bfb_wap'==a&&'url'==t||'yeepay_wap'==a&&'mode'==t||'channel_url'!=t&&r.push(t+'='+(n?encodeURIComponent(e[t]):e[t])));return r.join('&')},request:function(e,a,n,t,r,l){if('undefined'!=typeof XMLHttpRequest){var i=new XMLHttpRequest;if(void 0!==i.timeout&&(i.timeout=6e3),'GET'===(a=a.toUpperCase())&&'object'==typeof n&&n&&(e+='?'+s.stringifyData(n,'',!0)),i.open(a,e,!0),void 0!==l)for(var c in l)o.call(l,c)&&i.setRequestHeader(c,l[c]);'POST'===a?(i.setRequestHeader('Content-type','application/json; charset=utf-8'),i.send(JSON.stringify(n))):i.send(),void 0===t&&(t=function(){}),void 0===r&&(r=function(){}),i.onreadystatechange=function(){4==i.readyState&&t(i.responseText,i.status,i)},i.onerror=function(e){r(i,0,e)}}else console.log('Function XMLHttpRequest is undefined.')},formSubmit:function(e,a,n){if('undefined'!=typeof window){var t,r,l=document.createElement('form');for(t in l.setAttribute('method',a),l.setAttribute('action',e),n)o.call(n,t)&&((r=document.createElement('input')).setAttribute('type','hidden'),r.setAttribute('name',t),r.setAttribute('value',n[t]),l.appendChild(r));document.body.appendChild(l),l.submit()}else console.log('Not a browser, form submit url: '+e)},randomString:function(e){void 0===e&&(e=32);for(var a='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',n=a.length,t='',r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*n));return t},redirectTo:function(e,a){t.shouldReturnUrlByCallback(a)?t.triggerUrlReturnCallback(null,e):'undefined'!=typeof window?window.location.href=e:console.log('Not a browser, redirect url: '+e)},inWeixin:function(){return'undefined'!=typeof navigator&&-1!==navigator.userAgent.toLowerCase().indexOf('micromessenger')},inAlipay:function(){return'undefined'!=typeof navigator&&-1!==navigator.userAgent.toLowerCase().indexOf('alipayclient')},inWxLite:function(){return'undefined'!=typeof wx&&(wx.miniProgram||wx.requestPayment)},inAlipayLite:function(){return'undefined'!=typeof my&&my.tradePay},documentReady:function(e){'undefined'==typeof document||'loading'!=document.readyState?e():document.addEventListener('DOMContentLoaded',e)},loadUrlJs:function(e,a,n){var t=document.getElementsByTagName('head')[0],r=null;null==document.getElementById(e)?((r=document.createElement('script')).setAttribute('type','text/javascript'),r.setAttribute('src',a),r.setAttribute('id',e),r.async=!0,null!=n&&(r.onload=r.onreadystatechange=function(){if(r.ready)return!1;r.readyState&&'loaded'!=r.readyState&&'complete'!=r.readyState||(r.ready=!0,n())}),t.appendChild(r)):null!=n&&n()},deviceDetectorMobile:function(){return/Mobi/.test(window.navigator.userAgent)}}},{"./callbacks":2}],56:[function(e,a,n){a.exports={v:'2.3.1'}},{}]},{},[50])(50)});
//# sourceMappingURL=pingpp.js.map