pingpp-js 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # ChangeLog
2
2
 
3
+ ## 2.5.0
4
+
5
+ - withdraw 支持微信商家转账
6
+
7
+ ## 2.4.0
8
+
9
+ - transfer 支持微信商家转账
10
+
3
11
  ## 2.3.1
4
12
 
5
13
  - 更新纯签约支付宝地址为 `https`
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE HTML>
2
- <html>
2
+ <html lang="zh-CN">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <title>支付提示</title>
package/dist/pingpp.js CHANGED
@@ -1,2 +1,2 @@
1
- !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)});
2
- //# sourceMappingURL=pingpp.js.map
1
+ !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 r(l,t,i){function c(a,e){if(!t[a]){if(!l[a]){var n="function"==typeof require&&require;if(!e&&n)return n(a,!0);if(o)return o(a,!0);throw(e=new Error("Cannot find module '"+a+"'")).code="MODULE_NOT_FOUND",e}n=t[a]={exports:{}},l[a][0].call(n.exports,function(e){return c(l[a][1][e]||e)},n,n.exports,r,l,t,i)}return t[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 r={}.hasOwnProperty,l=e('./callbacks'),t=e('./utils');a.exports={signAgreement:function(e){var a;if('string'==typeof e)try{a=JSON.parse(e)}catch(e){return l.innerAgreementCallback('fail',l.error('json_decode_fail',e)),!1}else a=e;if(void 0===a)return l.innerAgreementCallback('fail',l.error('json_decode_fail')),!1;if(!r.call(a,'object')||'agreement'!==a.object||!r.call(a,'channel')||!r.call(a,'credential')||'object'!=typeof a.credential)return l.innerAgreementCallback('fail',l.error('invalid_object')),!1;if(!r.call(a.credential,a.channel))return l.innerAgreementCallback('fail',l.error('invalid_credential')),!1;var n,e=a.credential[a.channel];return'string'==typeof e?n=e:r.call(e,'credential')&&'string'==typeof e.credential&&(n=e.credential),void 0===n?(l.innerAgreementCallback('fail',l.error('invalid_credential')),!1):('alipay'===a.channel.substring(0,6)&&t.deviceDetectorMobile()&&(e=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(e.search.substring(1)))),setTimeout(function(){t.redirectTo(n)},0),!0)}}},{"./callbacks":2,"./utils":57}],2:[function(n,e,a){e.exports={userCallback:void 0,urlReturnCallback:void 0,urlReturnChannels:['alipay_pc_direct'],userAgreementCallback:void 0,userTransferCallback:void 0,userWithdrawalCallback: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)},innerTransferCallback:function(e,a){'function'==typeof this.userTransferCallback&&(void 0===a&&(a=this.error()),this.userTransferCallback(e,a),this.userTransferCallback=void 0)},innerWithdrawalCallback:function(e,a){'function'==typeof this.userWithdrawalCallback&&(void 0===a&&(a=this.error()),this.userWithdrawalCallback(e,a),this.userWithdrawalCallback=void 0,n('./withdrawal_elements').clear())}}},{"./payment_elements":52,"./withdrawal_elements":60}],3:[function(e,a,n){var r=e('../utils'),l=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?r.redirectTo(a,e.channel):l.innerCallback('fail',l.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":57}],4:[function(e,a,n){arguments[4][3][0].apply(n,arguments)},{"../callbacks":2,"../utils":57,dup:3}],5:[function(e,a,n){var r=e('../callbacks'),l={}.hasOwnProperty;a.exports={PINGPP_NOTIFY_URL_BASE:'https://notify.pingxx.com/notify',handleCharge:function(e){e=e.credential[e.channel];e||l.call(e,'orderInfo')?this.callpay(e.orderInfo):r.innerCallback('fail',r.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),r.innerCallback('fail',r.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};l.call(e,'memo')&&(a.memo=e.memo),l.call(e,'result')&&(a.result=e.result),'9000'==e.resultCode?r.innerCallback('success',r.error('',a)):'6001'==e.resultCode?r.innerCallback('cancel',r.error('用户取消支付',a)):r.innerCallback('fail',r.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?r.innerCallback('success'):r.innerCallback('fail',r.error('testmode_notify_fail'))},fail:function(){r.innerCallback('fail',r.error('network_err'))}})}}},{"../callbacks":2}],6:[function(e,a,n){var r=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):r.innerCallback('fail',r.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?r.innerCallback('success'):6001==e.resultCode?r.innerCallback('cancel',r.error('用户取消支付')):r.innerCallback('fail',r.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?r.innerCallback('success'):r.innerCallback('fail',r.error('testmode_notify_fail'))},fail:function(){r.innerCallback('fail',r.error('network_err'))}})}}},{"../callbacks":2}],7:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty;a.exports={ALIPAY_PC_DIRECT_URL:'https://mapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,e=e.credential[a],n=this.ALIPAY_PC_DIRECT_URL,e=(l.call(e,'channel_url')&&(n=e.channel_url),l.call(e,'_input_charset')||l.call(e,'service')&&'create_direct_pay_by_user'===e.service&&(e._input_charset='utf-8'),r.stringifyData(e,a,!0));r.redirectTo(n+'?'+e,a)}}},{"../utils":57}],8:[function(e,a,n){var r={}.hasOwnProperty,l=e('../callbacks');a.exports={handleCharge:function(e){e=e.credential[e.channel];r.call(e,'transaction_no')?this.tradePay(e.transaction_no):l.innerCallback('fail',l.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?l.innerCallback('success'):'6001'==e.resultCode?l.innerCallback('cancel',l.error(e.result)):l.innerCallback('fail',l.error(e.result))})})}}},{"../callbacks":2}],9:[function(e,a,n){var r=e('./commons/redirect_base');a.exports={handleCharge:function(e){r.handleCharge(e)}}},{"./commons/redirect_base":25}],10:[function(e,a,n){var r=e('../utils'),l=e('../mods'),t={}.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,e=e.credential[a],n=this.ALIPAY_WAP_URL,e=(t.call(e,'req_data')?n=this.ALIPAY_WAP_URL_OLD:t.call(e,'channel_url')&&(n=e.channel_url),t.call(e,'_input_charset')||(t.call(e,'service')&&'alipay.wap.create.direct.pay.by.user'===e.service||t.call(e,'req_data'))&&(e._input_charset='utf-8'),r.stringifyData(e,a,!0)),n=n+'?'+e,e=l.getExtraModule('ap');r.inWeixin()&&void 0!==e?e.pay(n):r.redirectTo(n,a)}}},{"../mods":51,"../utils":57}],11:[function(e,a,n){arguments[4][9][0].apply(n,arguments)},{"./commons/redirect_base":25,dup:9}],12:[function(e,a,n){var r=e('../utils'),l=e('../callbacks'),t={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.channel,e=e.credential[a];t.call(e,'url')?r.redirectTo(e.url+'?'+r.stringifyData(e,a),a):l.innerCallback('fail',l.error('invalid_credential','missing_field:url'))}}},{"../callbacks":2,"../utils":57}],13:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty;a.exports={ALIPAY_PC_DIRECT_URL:'https://intlmapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,e=e.credential[a],n=this.ALIPAY_PC_DIRECT_URL,e=(l.call(e,'channel_url')&&(n=e.channel_url),l.call(e,'_input_charset')||l.call(e,'service')&&'create_forex_trade'===e.service&&(e._input_charset='utf-8'),r.stringifyData(e,a,!0));r.redirectTo(n+'?'+e,a)}}},{"../utils":57}],14:[function(e,a,n){var r=e('../utils'),l=e('../mods'),t={}.hasOwnProperty;a.exports={ALIPAY_WAP_URL:'https://intlmapi.alipay.com/gateway.do',handleCharge:function(e){var a=e.channel,e=e.credential[a],n=this.ALIPAY_WAP_URL,e=(t.call(e,'channel_url')&&(n=e.channel_url),t.call(e,'_input_charset')||t.call(e,'service')&&'create_forex_trade_wap'===e.service&&(e._input_charset='utf-8'),r.stringifyData(e,a,!0)),n=n+'?'+e,e=l.getExtraModule('ap');r.inWeixin()&&void 0!==e?e.pay(n):r.redirectTo(n,a)}}},{"../mods":51,"../utils":57}],15:[function(e,a,n){var l=e('../callbacks'),r=e('../utils'),t=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'],r=0;r<n.length;r++)if(!c.call(a,n[r]))return void l.innerCallback('fail',l.error('invalid_credential','missing_field_'+n[r]));t.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(t,'jsApiParameters')&&WeixinJSBridge.invoke('getBrandWCPayRequest',t.jsApiParameters,function(e){delete t.jsApiParameters,'get_brand_wcpay_request:ok'==e.err_msg?l.innerCallback('success'):'get_brand_wcpay_request:cancel'==e.err_msg?l.innerCallback('cancel'):l.innerCallback('fail',l.error('wx_result_fail',e.err_msg))})},runTestMode:function(e){confirm('模拟付款?')&&(e='/charges/'+e.id,r.request(this.PINGPP_NOTIFY_URL_BASE+e+'?livemode=false','GET',null,function(e,a){200<=a&&a<400&&'success'==e?l.innerCallback('success'):l.innerCallback('fail',l.error('testmode_notify_fail','http_code:'+a+';response:'+e))},function(){l.innerCallback('fail',l.error('network_err'))}))}}},{"../callbacks":2,"../mods":51,"../stash":53,"../utils":57}],16:[function(e,a,n){arguments[4][9][0].apply(n,arguments)},{"./commons/redirect_base":25,dup:9}],17:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty,t=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];l.call(e,'orderinfo')?(e=this.CCB_WAP_URL_BASE+e.orderinfo,r.redirectTo(e,a)):t.innerCallback('fail',t.error('invalid_credential','missing_field:orderinfo'))}}},{"../callbacks":2,"../utils":57}],18:[function(e,a,n){var r=e('../utils'),l=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?r.redirectTo(a,e.channel):l.innerCallback('fail',l.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":57}],19:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":57,dup:18}],20:[function(e,a,n){var r=e('../utils'),l=e('../callbacks');a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?r.redirectTo(a,e.channel):l.innerCallback('fail',l.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":57}],21:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":57,dup:18}],22:[function(e,a,n){arguments[4][18][0].apply(n,arguments)},{"../callbacks":2,"../utils":57,dup:18}],23:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty;a.exports={handleCharge:function(e){var a,n=e.channel,e=e.credential[n];l.call(e,'channel_url')&&(a=e.channel_url,delete e.channel_url),r.formSubmit(a,'post',e)}}},{"../utils":57}],24:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty;a.exports={CMB_WALLET_URL:'https://netpay.cmbchina.com/netpayment/BaseHttp.dll?MB_EUserPay',handleCharge:function(e){var e=e.credential[e.channel],a=this.CMB_WALLET_URL;l.call(e,'ChannelUrl')&&(a=e.ChannelUrl,delete e.ChannelUrl),l.call(e,'channelVersion')&&delete e.channelVersion,r.formSubmit(a,'post',e)}}},{"../utils":57}],25:[function(e,a,n){var r=e('../../utils'),l=e('../../callbacks'),t={}.hasOwnProperty;a.exports={handleCharge:function(e){var a,n=e.credential[e.channel];if('string'==typeof n)a=n;else{if(!t.call(n,'url'))return void l.innerCallback('fail',l.error('invalid_credential','credential format is incorrect'));a=n.url}r.redirectTo(a,e.channel)}}},{"../../callbacks":2,"../../utils":57}],26:[function(e,a,n){var r=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];r.formSubmit(this.CP_B2B_URL,'post',e)}}},{"../utils":57}],27:[function(e,a,n){var r,o,l=e('../../stash'),t={}.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){e=o.ALPHA.indexOf(e.charAt(a));if(-1===e)throw o.makeDOMException();return e},decode:function(e){var a,n,r=o.getbyte64,l=(e=''+e).length;if(0===l)return e;if(l%4!=0)throw o.makeDOMException();a=0,e.charAt(l-1)===o.PADCHAR&&(a=1,e.charAt(l-2)===o.PADCHAR&&(a=2),l-=4);for(var t=[],i=0;i<l;i+=4)n=r(e,i)<<18|r(e,i+1)<<12|r(e,i+2)<<6|r(e,i+3),t.push(String.fromCharCode(n>>16,n>>8&255,255&n));switch(a){case 1:n=r(e,i)<<18|r(e,i+1)<<12|r(e,i+2)<<6,t.push(String.fromCharCode(n>>16,n>>8&255));break;case 2:n=r(e,i)<<18|r(e,i+1)<<12,t.push(String.fromCharCode(n>>16))}return t.join('')},getbyte:function(e,a){e=e.charCodeAt(a);if(255<e)throw o.makeDOMException();return e},encode:function(e){if(1!==arguments.length)throw new SyntaxError('Not enough arguments');var a,n,r=o.PADCHAR,l=o.ALPHA,t=o.getbyte,i=[],c=(e=''+e).length-e.length%3;if(0===e.length)return e;for(a=0;a<c;a+=3)n=t(e,a)<<16|t(e,a+1)<<8|t(e,a+2),i.push(l.charAt(n>>18)),i.push(l.charAt(n>>12&63)),i.push(l.charAt(n>>6&63)),i.push(l.charAt(63&n));switch(e.length-c){case 1:n=t(e,a)<<16,i.push(l.charAt(n>>18)+l.charAt(n>>12&63)+r+r);break;case 2:n=t(e,a)<<16|t(e,a+1)<<8,i.push(l.charAt(n>>18)+l.charAt(n>>12&63)+l.charAt(n>>6&63)+r)}return i.join('')}},r={url:'pay.htm',pay:function(e){e=encodeURIComponent(o.encode(e));t.call(l,'APURL')&&(r.url=l.APURL),location.href=r.url+'?goto='+e},decode:function(e){return o.decode(decodeURIComponent(e))}},a.exports=r},{"../../stash":53}],28:[function(e,a,n){e=e('./wx_lite');a.exports=e},{"./wx_lite":38}],29:[function(e,a,n){var r=e('./commons/redirect_base'),l=e('../callbacks'),t=e('../utils'),i={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.extra;i.call(a,'pay_channel')?'wx'!==(a=a.pay_channel)||t.inWeixin()?'alipay'!==a||t.inAlipay()?r.handleCharge(e):l.innerCallback('fail',l.error('Not in the Alipay browser')):l.innerCallback('fail',l.error('Not in the WeChat browser')):l.innerCallback('fail',l.error('invalid_charge','charge 格式不正确'))}}},{"../callbacks":2,"../utils":57,"./commons/redirect_base":25}],30:[function(e,a,n){var r=e('../utils'),l={}.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 e=e.credential[e.channel],a=this.JDPAY_H5_URL;l.call(e,'channelUrl')?(a=e.channelUrl,delete e.channelUrl):l.call(e,'merchantRemark')&&(a=this.JDPAY_WAP_URL_OLD),r.formSubmit(a,'post',e)}}},{"../utils":57}],31:[function(e,a,n){var r=e('../utils'),l={}.hasOwnProperty;a.exports={handleCharge:function(e){e=e.credential[e.channel];l.call(e,'bankUrl')&&(request_url=e.bankUrl,delete e.bankUrl),r.formSubmit(request_url,'post',e)}}},{"../utils":57}],32:[function(e,a,n){arguments[4][31][0].apply(n,arguments)},{"../utils":57,dup:31}],33:[function(e,a,n){var r=e('../utils');a.exports={handleCharge:function(e){var a=e.credential[e.channel];r.redirectTo(a,e.channel)}}},{"../utils":57}],34:[function(e,a,n){var r=e('../callbacks'),l=e('../utils'),t=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')?(t.tokenId=e.token_id,l.loadUrlJs(this.ID,this.SRC_URL,this.callpay)):r.innerCallback('fail',r.error('invalid_credential','missing_token_id'))},callpay:function(){if('undefined'!=typeof mqq){if(0==mqq.QQVersion)return r.innerCallback('fail',r.error('Not in the QQ client')),void delete t.tokenId;mqq.tenpay.pay({tokenId:t.tokenId},function(e){0==e.resultCode?r.innerCallback('success'):r.innerCallback('fail',r.error(e.retmsg))})}else r.innerCallback('fail',r.error('network_err'));delete t.tokenId}}},{"../callbacks":2,"../stash":53,"../utils":57}],35:[function(e,a,n){arguments[4][23][0].apply(n,arguments)},{"../utils":57,dup:23}],36:[function(e,a,n){var r=e('../utils');a.exports={UPACP_PC_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){e=e.credential[e.channel];r.formSubmit(this.UPACP_PC_URL,'post',e)}}},{"../utils":57}],37:[function(e,a,n){var r=e('../utils');a.exports={UPACP_WAP_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){e=e.credential[e.channel];r.formSubmit(this.UPACP_WAP_URL,'post',e)}}},{"../utils":57}],38:[function(e,a,n){var l=e('../stash'),t=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'],r=0;r<n.length;r++)if(!i.call(a,n[r]))return void t.innerCallback('fail',t.error('invalid_credential','missing_field_'+n[r]));l.jsApiParameters=a,this.callpay()},wxLiteEnabled:function(){return'undefined'!=typeof wx&&wx.requestPayment},callpay:function(){var e;this.wxLiteEnabled()?(delete(e=l.jsApiParameters).appId,e.complete=function(e){'requestPayment:ok'===e.errMsg&&t.innerCallback('success'),'requestPayment:cancel'!==e.errMsg&&'requestPayment:fail cancel'!==e.errMsg||t.innerCallback('cancel',t.error('用户取消支付')),'undefined'!==e.err_code&&'undefined'!==e.err_desc&&t.innerCallback('fail',t.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?t.innerCallback('success'):t.innerCallback('fail',t.error('testmode_notify_fail'))},fail:function(){t.innerCallback('fail',t.error('network_err'))}})}}},{"../callbacks":2,"../stash":53}],39:[function(e,a,n){arguments[4][28][0].apply(n,arguments)},{"./wx_lite":38,dup:28}],40:[function(e,a,n){arguments[4][15][0].apply(n,arguments)},{"../callbacks":2,"../mods":51,"../stash":53,"../utils":57,dup:15}],41:[function(e,a,n){e=e('./wx_pub');a.exports=e},{"./wx_pub":40}],42:[function(e,a,n){var r=e('../utils'),l=e('../callbacks'),t={}.hasOwnProperty;a.exports={handleCharge:function(e){var a=e.credential[e.channel];'string'==typeof a?r.redirectTo(a,e.channel):'object'==typeof a&&t.call(a,'url')?r.redirectTo(a.url,e.channel):l.innerCallback('fail',l.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":2,"../utils":57}],43:[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,r=e.credential[n],l=['merchantaccount','encryptkey','data'],t=0;t<l.length;t++)if(!o.call(r,l[t]))return void c.innerCallback('fail',c.error('invalid_credential','missing_field_'+l[t]));a=o.call(r,'mode')&&'test'==r.mode?this.YEEPAY_WAP_TEST_URL:this.YEEPAY_WAP_URL,i.redirectTo(a+'?'+i.stringifyData(r,n,!0),e.channel)}}},{"../callbacks":2,"../utils":57}],44:[function(e,a,n){e=e('./wx_lite');a.exports=e},{"./wx_lite":38}],45:[function(e,a,n){arguments[4][44][0].apply(n,arguments)},{"./wx_lite":38,dup:44}],46:[function(e,a,n){arguments[4][41][0].apply(n,arguments)},{"./wx_pub":40,dup:41}],47:[function(e,a,n){arguments[4][41][0].apply(n,arguments)},{"./wx_pub":40,dup:41}],48:[function(e,a,n){a.exports={Error:function(e,a){this.message=e,this.extra=a}}},{}],49:[function(e,a,n){var r=e('./stash'),l=e('./utils');a.exports={init:function(){var e=this;l.documentReady(function(){try{l.inWxLite()||l.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=l.randomString();try{localStorage.setItem('pingpp_uid',e)}catch(e){}}r.puid=e}}}},{"./stash":53,"./utils":57}],50:[function(e,a,n){function PingppSDK(){e('./init').init()}var r=e('./version').v,l={}.hasOwnProperty,t=(PingppSDK.prototype.version=r,a.exports=new PingppSDK,e('./testmode')),i=e('./callbacks'),c=e('./errors').Error,o=e('./mods'),s=e('./stash'),d=e('./payment_elements'),u=e('./transfer_elements'),p=e('./withdrawal_elements');PingppSDK.prototype.createPayment=function(e,a,n,r){'function'==typeof a&&(i.userCallback=a);try{d.init(e)}catch(e){if(e instanceof c)return void i.innerCallback('fail',i.error(e.message,e.extra));throw e}if(l.call(d,'id'))if(l.call(d,'channel')){l.call(d,'app')&&('string'==typeof d.app?s.app_id=d.app:'object'==typeof d.app&&'string'==typeof d.app.id&&(s.app_id=d.app.id));a=d.channel;if(l.call(d,'credential'))if(d.paid&&0===d.actual_amount)i.innerCallback('success');else if(d.credential)if(l.call(d.credential,a)){if(l.call(d,'livemode'))return void 0===(e=o.getChannelModule(a))?(console.error('channel module "'+a+'" is undefined'),void i.innerCallback('fail',i.error('invalid_channel','channel module "'+a+'" is undefined'))):void(!1===d.livemode?(l.call(e,'runTestMode')?e:t).runTestMode(d):(void 0!==n&&(s.signature=n),'boolean'==typeof r&&(s.debug=r),e.handleCharge(d)));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)},PingppSDK.prototype.createTransfer=function(e,a){"function"==typeof a&&(i.userTransferCallback=a);try{u.init(e)}catch(e){if(e instanceof c)return void i.innerTransferCallback("fail",i.error(e.message,e.extra));throw e}if(l.call(u,"id"))if(l.call(u,"channel")){l.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(l.call(u,"extra"))if("paid"===u.status)i.innerTransferCallback("success");else if(u.extra)if(l.call(u,"livemode")){const n=o.getTransferChannelModule(a);if(void 0===n)return console.error('transfer channel module "'+a+'" is undefined'),void i.innerTransferCallback("fail",i.error("invalid_channel",'transfer channel module "'+a+'" is undefined'));!1===u.livemode?i.innerTransferCallback("fail",i.error("invalid_transfer","testmode_not_supported")):n.handleTransfer(u)}else i.innerTransferCallback("fail",i.error("invalid_transfer","no_livemode_field"));else i.innerTransferCallback("fail",i.error("invalid_credential","credential_is_undefined"));else i.innerTransferCallback("fail",i.error("invalid_transfer","no_credential"))}else i.innerTransferCallback("fail",i.error("invalid_transfer","no_channel"));else i.innerTransferCallback("fail",i.error("invalid_transfer","no_transfer_id"))},PingppSDK.prototype.createWithdrawal=function(e,a){"function"==typeof a&&(i.userWithdrawalCallback=a);try{p.init(e)}catch(e){if(e instanceof c)return void i.innerWithdrawalCallback("fail",i.error(e.message,e.extra));throw e}if(l.call(p,"id"))if(l.call(p,"channel")){l.call(p,"app")&&("string"==typeof p.app?s.app_id=p.app:"object"==typeof p.app&&"string"==typeof p.app.id&&(s.app_id=p.app.id));a=p.channel;if(l.call(p,"extra"))if("succeeded"===p.status)i.innerWithdrawalCallback("success");else if(p.extra)if(l.call(p,"livemode")){const n=o.getWithdrawalChannelModule(a);if(void 0===n)return console.error('withdrawal channel module "'+a+'" is undefined'),void i.innerWithdrawalCallback("fail",i.error("invalid_channel",'withdrawal channel module "'+a+'" is undefined'));!1===p.livemode?i.innerWithdrawalCallback("fail",i.error("invalid_withdrawal","testmode_not_supported")):n.handleWithdrawal(p)}else i.innerWithdrawalCallback("fail",i.error("invalid_withdrawal","no_livemode_field"));else i.innerWithdrawalCallback("fail",i.error("invalid_credential","credential_is_undefined"));else i.innerWithdrawalCallback("fail",i.error("invalid_withdrawal","no_credential"))}else i.innerWithdrawalCallback("fail",i.error("invalid_withdrawal","no_channel"));else i.innerWithdrawalCallback("fail",i.error("invalid_withdrawal","no_withdrawal_id"))}},{"./callbacks":2,"./errors":48,"./init":49,"./mods":51,"./payment_elements":52,"./stash":53,"./testmode":54,"./transfer_elements":56,"./version":58,"./withdrawal_elements":60}],51:[function(e,a,n){var r={}.hasOwnProperty,l={};(a.exports=l).channels={abc_pay:e('./channels/abc_pay'),abc_pub:e('./channels/abc_pub'),alipay:e('./channels/alipay'),alipay_lite:e('./channels/alipay_lite'),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'),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_lite:e('./channels/yeepay_wx_lite'),yeepay_wx_lite_ofl:e('./channels/yeepay_wx_lite_ofl'),yeepay_wx_pub:e('./channels/yeepay_wx_pub'),yeepay_wx_pub_ofl:e('./channels/yeepay_wx_pub_ofl')},l.extras={ap:e('./channels/extras/ap'),agreement:e('./agreement')},l.transferChannels={wx_pub:e('./transfer_channels/wx_pub')},l.withdrawalChannels={wx_pub:e('./withdrawal_channels/wx_pub')},l.getChannelModule=function(e){if(r.call(l.channels,e))return l.channels[e]},l.getTransferChannelModule=function(e){if(r.call(l.transferChannels,e))return l.transferChannels[e]},l.getWithdrawalChannelModule=function(e){if(r.call(l.withdrawalChannels,e))return l.withdrawalChannels[e]},l.getExtraModule=function(e){if(r.call(l.extras,e))return l.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/paypal":33,"./channels/qpay_pub":34,"./channels/upacp_b2b":35,"./channels/upacp_pc":36,"./channels/upacp_wap":37,"./channels/wx_lite":38,"./channels/wx_lite_pab":39,"./channels/wx_pub":40,"./channels/wx_pub_pab":41,"./channels/wx_wap":42,"./channels/yeepay_wap":43,"./channels/yeepay_wx_lite":44,"./channels/yeepay_wx_lite_ofl":45,"./channels/yeepay_wx_pub":46,"./channels/yeepay_wx_pub_ofl":47,"./transfer_channels/wx_pub":55,"./withdrawal_channels/wx_pub":59}],52:[function(e,a,n){var t=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 t('json_decode_fail',e)}else a=e;if(void 0===a)throw new t('json_decode_fail');if(i.call(a,'object')&&'order'==a.object){a.or_id=a.id,a.order_no=a.merchant_order_no;var r=a.charge_essentials;if(a.channel=r.channel,a.credential=r.credential,a.extra=r.extra,i.call(a,'charge')&&null!=a.charge)a.id=a.charge;else if(i.call(r,'id')&&null!=r.id)a.id=r.id;else if(i.call(a,'charges'))for(var l=0;l<a.charges.data.length;l++)if(a.charges.data[l].channel===r.channel){a.id=a.charges.data[l].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 r=e('./utils'),l={}.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};l.call(e,'order_no')?a.order_no=e.order_no:l.call(e,
2
+ 'orderNo')&&(a.order_no=e.orderNo),l.call(e,'time_expire')?a.time_expire=e.time_expire:l.call(e,'timeExpire')&&(a.time_expire=e.timeExpire),l.call(e,'extra')&&(a.extra=encodeURIComponent(JSON.stringify(e.extra))),r.redirectTo(this.PINGPP_MOCK_URL+'?'+r.stringifyData(a),e.channel)}}},{"./utils":57}],55:[function(e,a,n){var l=e('../callbacks'),t=e('../stash'),r=e('../mods'),i={}.hasOwnProperty;a.exports={handleTransfer:function(a){const n={};var r=['appId','mchId','package'];for(let e=0;e<r.length;e++){if(!i.call(a.extra,r[e]))return l.innerTransferCallback('fail',l.error('invalid_credential','missing_field_'+r[e])),void console.error(r[e]);n[r[e]]=a.extra[r[e]]}t.jsApiParameters=n,this.callTransfer()},callTransfer:function(){const e=this,a=r.getExtraModule('wx_jssdk');var n;void 0!==a&&a.jssdkEnabled()?a.callpay():'undefined'==typeof WeixinJSBridge?(n=function(){e.jsApiCall()},'undefined'==typeof document?l.innerTransferCallback("fail",l.error("invalid_environment","document_is_undefined")):document.addEventListener?document.addEventListener('WeixinJSBridgeReady',n,!1):document.attachEvent&&(document.attachEvent('WeixinJSBridgeReady',n),document.attachEvent('onWeixinJSBridgeReady',n))):this.jsApiCall()},jsApiCall:function(){i.call(t,'jsApiParameters')&&WeixinJSBridge.invoke('requestMerchantTransfer',t.jsApiParameters,function(e){delete t.jsApiParameters,'requestMerchantTransfer:ok'===e.err_msg?l.innerTransferCallback("success"):'requestMerchantTransfer:cancel'===e.err_msg?l.innerTransferCallback("cancel"):l.innerTransferCallback("fail",l.error("wx_result_fail",e.err_msg))})}}},{"../callbacks":2,"../mods":51,"../stash":53}],56:[function(e,a,n){var r=e('./errors').Error,l={}.hasOwnProperty;a.exports={id:null,channel:null,app:null,extra:null,livemode:null,order_no:null,time_expire:null,status:null,init:function(e){let a;if('string'==typeof e)try{a=JSON.parse(e)}catch(e){throw new r('json_decode_fail',e)}else a=e;if(void 0===a)throw new r('json_decode_fail');for(var n in this)l.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}],57:[function(e,a,n){var r=e('./callbacks'),o={}.hasOwnProperty,s=a.exports={stringifyData:function(e,a,n){void 0===n&&(n=!1);var r,l=[];for(r in e)!o.call(e,r)||'function'==typeof e[r]||'bfb_wap'==a&&'url'==r||'yeepay_wap'==a&&'mode'==r||'channel_url'!=r&&l.push(r+'='+(n?encodeURIComponent(e[r]):e[r]));return l.join('&')},request:function(e,a,n,r,l,t){if('undefined'==typeof XMLHttpRequest)console.log('Function XMLHttpRequest is undefined.');else{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!==t)for(var c in t)o.call(t,c)&&i.setRequestHeader(c,t[c]);'POST'===a?(i.setRequestHeader('Content-type','application/json; charset=utf-8'),i.send(JSON.stringify(n))):i.send(),void 0===r&&(r=function(){}),void 0===l&&(l=function(){}),i.onreadystatechange=function(){4==i.readyState&&r(i.responseText,i.status,i)},i.onerror=function(e){l(i,0,e)}}},formSubmit:function(e,a,n){if('undefined'==typeof window)console.log('Not a browser, form submit url: '+e);else{var r,l,t=document.createElement('form');for(r in t.setAttribute('method',a),t.setAttribute('action',e),n)o.call(n,r)&&((l=document.createElement('input')).setAttribute('type','hidden'),l.setAttribute('name',r),l.setAttribute('value',n[r]),t.appendChild(l));document.body.appendChild(t),t.submit()}},randomString:function(e){void 0===e&&(e=32);for(var a='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',n=a.length,r='',l=0;l<e;l++)r+=a.charAt(Math.floor(Math.random()*n));return r},redirectTo:function(e,a){r.shouldReturnUrlByCallback(a)?r.triggerUrlReturnCallback(null,e):'undefined'==typeof window?console.log('Not a browser, redirect url: '+e):window.location.href=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 r=document.getElementsByTagName('head')[0],l=null;null==document.getElementById(e)?((l=document.createElement('script')).setAttribute('type','text/javascript'),l.setAttribute('src',a),l.setAttribute('id',e),l.async=!0,null!=n&&(l.onload=l.onreadystatechange=function(){if(l.ready)return!1;l.readyState&&'loaded'!=l.readyState&&'complete'!=l.readyState||(l.ready=!0,n())}),r.appendChild(l)):null!=n&&n()},deviceDetectorMobile:function(){return/Mobi/.test(window.navigator.userAgent)}}},{"./callbacks":2}],58:[function(e,a,n){a.exports={v:'2.5.0'}},{}],59:[function(e,a,n){var l=e('../callbacks'),t=e('../stash'),r=e('../mods'),i={}.hasOwnProperty;a.exports={handleWithdrawal:function(a){const n={};var r=['appId','mchId','package'];for(let e=0;e<r.length;e++){if(!i.call(a.extra,r[e]))return l.innerWithdrawalCallback('fail',l.error('invalid_credential','missing_field_'+r[e])),void console.error(r[e]);n[r[e]]=a.extra[r[e]]}t.jsApiParameters=n,this.callWithdrawal()},callWithdrawal:function(){const e=this,a=r.getExtraModule('wx_jssdk');var n;void 0!==a&&a.jssdkEnabled()?a.callpay():'undefined'==typeof WeixinJSBridge?(n=function(){e.jsApiCall()},'undefined'==typeof document?l.innerWithdrawalCallback("fail",l.error("invalid_environment","document_is_undefined")):document.addEventListener?document.addEventListener('WeixinJSBridgeReady',n,!1):document.attachEvent&&(document.attachEvent('WeixinJSBridgeReady',n),document.attachEvent('onWeixinJSBridgeReady',n))):this.jsApiCall()},jsApiCall:function(){i.call(t,'jsApiParameters')&&WeixinJSBridge.invoke('requestMerchantTransfer',t.jsApiParameters,function(e){delete t.jsApiParameters,'requestMerchantTransfer:ok'===e.err_msg?l.innerWithdrawalCallback("success"):'requestMerchantTransfer:cancel'===e.err_msg?l.innerWithdrawalCallback("cancel"):l.innerWithdrawalCallback("fail",l.error("wx_result_fail",e.err_msg))})}}},{"../callbacks":2,"../mods":51,"../stash":53}],60:[function(e,a,n){var r=e('./errors').Error,l={}.hasOwnProperty;a.exports={id:null,object:null,channel:null,app:null,extra:null,livemode:null,order_no:null,status:null,amount:null,description:null,failure_msg:null,time_canceled:null,time_succeeded:null,init:function(e){var a,n;if('string'==typeof e)try{a=JSON.parse(e)}catch(e){throw new r('json_decode_fail',e)}else a=e;if(void 0===a)throw new r('json_decode_fail');for(n in this)l.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}]},{},[50])(50)});
package/gulpfile.js CHANGED
@@ -48,9 +48,9 @@ function build(cb) {
48
48
  b.bundle()
49
49
  .pipe(source(destJsFile))
50
50
  .pipe(buffer())
51
- .pipe(sourcemaps.init({
52
- loadMaps: true
53
- }))
51
+ // .pipe(sourcemaps.init({
52
+ // loadMaps: true
53
+ // }))
54
54
  .pipe(uglify({
55
55
  mangle: {
56
56
  reserved: ['PingppSDK']
@@ -61,7 +61,7 @@ function build(cb) {
61
61
  }
62
62
  }))
63
63
  .on('error', gutil.log)
64
- .pipe(sourcemaps.write('./'))
64
+ // .pipe(sourcemaps.write('./'))
65
65
  .pipe(dest(distDir));
66
66
 
67
67
  cb();
@@ -93,13 +93,13 @@ function clean(cb) {
93
93
  var makeChannelModulesContent = function() {
94
94
  var channelPool = fs.readdirSync(channelsDirPath, 'utf8');
95
95
  var allChannels = _.map(channelPool, function(ch) {
96
- if (ch.substr(0, 1) == '.' || ch.substr(-3) != '.js') {
96
+ if (ch.slice(0, 1) === '.' || ch.slice(-3) !== '.js') {
97
97
  return undefined;
98
98
  }
99
- return ch.substr(0, ch.length - 3);
99
+ return ch.slice(0, -3);
100
100
  });
101
101
  allChannels = _.remove(allChannels, function(ch) {
102
- return typeof ch != 'undefined';
102
+ return typeof ch !== 'undefined';
103
103
  });
104
104
  var enabledChannels;
105
105
  if (hasOwn.call(cmdOptions, 'channels') && cmdOptions.channels.length > 0) {
@@ -132,18 +132,14 @@ var makeChannelModulesContent = function() {
132
132
 
133
133
  var makeLibModulesContent = function() {
134
134
  var extraBaseDir = './channels/extras/';
135
- var extranames = [];
136
- if (hasOwn.call(cmdOptions, 'alipay_in_weixin') &&
137
- cmdOptions.alipay_in_weixin) {
138
- extranames.push('ap');
139
- }
135
+ var extranames = [
136
+ 'ap',
137
+ ['agreement', './agreement']
138
+ ];
140
139
  if (hasOwn.call(cmdOptions, 'wx_jssdk') &&
141
140
  cmdOptions.wx_jssdk) {
142
141
  extranames.push('wx_jssdk');
143
142
  }
144
- if (hasOwn.call(cmdOptions, 'agreement')) {
145
- extranames.push(['agreement', './agreement']);
146
- }
147
143
 
148
144
  return {
149
145
  replacement: modnames2text(extranames, extraBaseDir)
@@ -190,6 +186,7 @@ exports.test = function(cb) {
190
186
  test.run();
191
187
  cb();
192
188
  };
189
+
193
190
  exports.build = series(clean, modules, build);
194
191
  exports.watch = series(clean, build, watchFiles);
195
192
  exports.default = series(build);
package/mods.js.tmpl CHANGED
@@ -10,6 +10,14 @@ mods.extras = {
10
10
  <<REPLACE-EXTRAS>>
11
11
  };
12
12
 
13
+ mods.transferChannels = {
14
+ wx_pub: require('./transfer_channels/wx_pub'),
15
+ }
16
+
17
+ mods.withdrawalChannels = {
18
+ wx_pub: require('./withdrawal_channels/wx_pub'),
19
+ }
20
+
13
21
  mods.getChannelModule = function(channel) {
14
22
  if (hasOwn.call(mods.channels, channel)) {
15
23
  return mods.channels[channel];
@@ -17,6 +25,20 @@ mods.getChannelModule = function(channel) {
17
25
  return undefined;
18
26
  };
19
27
 
28
+ mods.getTransferChannelModule = function(channel) {
29
+ if (hasOwn.call(mods.transferChannels, channel)) {
30
+ return mods.transferChannels[channel];
31
+ }
32
+ return undefined;
33
+ };
34
+
35
+ mods.getWithdrawalChannelModule = function(channel) {
36
+ if (hasOwn.call(mods.withdrawalChannels, channel)) {
37
+ return mods.withdrawalChannels[channel];
38
+ }
39
+ return undefined;
40
+ };
41
+
20
42
  mods.getExtraModule = function(name) {
21
43
  if (hasOwn.call(mods.extras, name)) {
22
44
  return mods.extras[name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pingpp-js",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "Ping++ HTML5 SDK",
5
5
  "main": "src/main.js",
6
6
  "homepage": "https://www.pingxx.com",
@@ -22,13 +22,14 @@
22
22
  "gulp-sourcemaps": "^2.6.4",
23
23
  "gulp-uglify": "^3.0.1",
24
24
  "gulp-util": "^3.0.8",
25
- "lodash": "^4.17.11",
25
+ "lodash": "^4.18.1",
26
26
  "minimist": "1.2.6",
27
27
  "vinyl-buffer": "^1.0.1",
28
28
  "vinyl-source-stream": "^2.0.0"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "npm install && gulp",
32
+ "build:modules": "npm install && gulp build --alipay_in_weixin",
32
33
  "test": "gulp && gulp test"
33
34
  },
34
35
  "author": "Afon",
package/release.md ADDED
@@ -0,0 +1,109 @@
1
+ # 发布流程(GitHub)
2
+
3
+ > 目标:把内部 GitLab 上 `master` 的最新代码发布到 GitHub,**不暴露内部 GitLab 的 commit 历史**,同时**保留 GitHub 上 `master` 已有的历史**。
4
+
5
+ ## 核心思路
6
+
7
+ 不需要创建 `release/x.y.z` 分支。直接基于:
8
+
9
+ - **父提交**:GitHub 当前的 `master`
10
+ - **文件树**:本地内部 `master` 的最新文件树
11
+
12
+ 生成一个新 commit 并推到 GitHub `master`。这样 `master` 只新增一个无内部历史的发布 commit,文件内容却是最新的。
13
+
14
+ ## 前置条件
15
+
16
+ - 本地有两个远程:
17
+ - `gitlab`:内部 GitLab 仓库
18
+ - `github`:GitHub 仓库
19
+ - 如果之前只有 `origin` 指向 GitLab,可以先改名:
20
+
21
+ ```bash
22
+ git remote rename origin gitlab
23
+ ```
24
+
25
+ ## 推荐流程(无 release 分支)
26
+
27
+ ```bash
28
+ VERSION="2.5.0"
29
+
30
+ # 1. 确保本地 master 是最新的内部代码
31
+ git checkout master
32
+ git pull gitlab master
33
+
34
+ # 2. 取回 GitHub 当前 master
35
+ git fetch github master
36
+
37
+ # 3. 生成新 commit:父提交是 github/master,文件树是本地 master
38
+ NEW_COMMIT=$(git -c user.name="Release Bot" \
39
+ -c user.email="release@example.com" \
40
+ commit-tree \
41
+ -p github/master \
42
+ -m "Release ${VERSION}" \
43
+ master^{tree})
44
+
45
+ echo "new commit: ${NEW_COMMIT}"
46
+
47
+ # 4. 推送到 GitHub master(fast-forward,不需要 --force)
48
+ git push github "${NEW_COMMIT}:master"
49
+ ```
50
+
51
+ ## 验证
52
+
53
+ ```bash
54
+ # GitHub master 应该指向新 commit
55
+ git ls-remote --heads github master
56
+
57
+ # 查看 master 历史(应只看到新增的 Release commit + 原有历史)
58
+ git log --oneline -5 github/master
59
+
60
+ # 确认新 commit 只有一个 parent,且 parent 是原 GitHub master
61
+ git cat-file -p <new-commit-sha> | grep parent
62
+ ```
63
+
64
+ ## 可选:保留 release 分支
65
+
66
+ 如果你希望 GitHub 上也保留一个 `release/x.y.z` 分支(例如用于 review 或标记),可以先创建孤儿分支并推送,再用同样的 `commit-tree` 方法更新 `master`:
67
+
68
+ ```bash
69
+ VERSION="2.5.0"
70
+
71
+ git checkout master
72
+ git pull gitlab master
73
+
74
+ # 创建并推送 release 分支
75
+ git checkout --orphan "release/${VERSION}"
76
+ git add -A
77
+ git commit -m "Release ${VERSION}"
78
+ git push github "release/${VERSION}"
79
+
80
+ # 更新 master
81
+ git fetch github master
82
+ NEW_COMMIT=$(git -c user.name="Release Bot" \
83
+ -c user.email="release@example.com" \
84
+ commit-tree \
85
+ -p github/master \
86
+ -m "Release ${VERSION}" \
87
+ "release/${VERSION}^{tree}")
88
+ git push github "${NEW_COMMIT}:master"
89
+ ```
90
+
91
+ ## 常见问题
92
+
93
+ ### 想强制覆盖 GitHub master(清空旧历史)
94
+
95
+ 如果不介意丢掉 GitHub 上旧的历史,可以直接:
96
+
97
+ ```bash
98
+ git checkout master
99
+ git pull gitlab master
100
+ git push github master --force
101
+ ```
102
+
103
+ ### 发布分支已存在
104
+
105
+ 如果本地已有同名 release 分支,先删除再重建:
106
+
107
+ ```bash
108
+ git branch -D "release/${VERSION}"
109
+ ```
package/src/callbacks.js CHANGED
@@ -1,5 +1,4 @@
1
1
  module.exports = {
2
-
3
2
  userCallback: undefined,
4
3
 
5
4
  urlReturnCallback: undefined,
@@ -10,7 +9,11 @@ module.exports = {
10
9
 
11
10
  userAgreementCallback: undefined,
12
11
 
13
- innerCallback: function(result, err) {
12
+ userTransferCallback: undefined,
13
+
14
+ userWithdrawalCallback: undefined,
15
+
16
+ innerCallback: function (result, err) {
14
17
  if (typeof this.userCallback === 'function') {
15
18
  if (typeof err === 'undefined') {
16
19
  err = this.error();
@@ -22,12 +25,12 @@ module.exports = {
22
25
  }
23
26
  },
24
27
 
25
- error: function(msg, extra) {
26
- msg = (typeof msg === 'undefined') ? '' : msg;
27
- extra = (typeof extra === 'undefined') ? '' : extra;
28
+ error: function (msg, extra) {
29
+ msg = typeof msg === 'undefined' ? '' : msg;
30
+ extra = typeof extra === 'undefined' ? '' : extra;
28
31
  return {
29
32
  msg: msg,
30
- extra: extra
33
+ extra: extra,
31
34
  };
32
35
  },
33
36
 
@@ -44,7 +47,7 @@ module.exports = {
44
47
  return this.urlReturnChannels.indexOf(channel) !== -1;
45
48
  },
46
49
 
47
- innerAgreementCallback: function(result, err) {
50
+ innerAgreementCallback: function (result, err) {
48
51
  if (typeof this.userAgreementCallback === 'function') {
49
52
  if (typeof err === 'undefined') {
50
53
  err = this.error();
@@ -52,5 +55,27 @@ module.exports = {
52
55
  this.userAgreementCallback(result, err);
53
56
  this.userAgreementCallback = undefined;
54
57
  }
55
- }
58
+ },
59
+
60
+ innerTransferCallback: function (result, err) {
61
+ if (typeof this.userTransferCallback === 'function') {
62
+ if (typeof err === 'undefined') {
63
+ err = this.error();
64
+ }
65
+ this.userTransferCallback(result, err);
66
+ this.userTransferCallback = undefined;
67
+ }
68
+ },
69
+
70
+ innerWithdrawalCallback: function (result, err) {
71
+ if (typeof this.userWithdrawalCallback === 'function') {
72
+ if (typeof err === 'undefined') {
73
+ err = this.error();
74
+ }
75
+ this.userWithdrawalCallback(result, err);
76
+ this.userWithdrawalCallback = undefined;
77
+ var withdrawal_elements = require('./withdrawal_elements');
78
+ withdrawal_elements.clear();
79
+ }
80
+ },
56
81
  };