!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.pingpp=e()}}(function(){return function e(n,t,r){function a(o,c){if(!t[o]){if(!n[o]){var l="function"==typeof require&&require;if(!c&&l)return l(o,!0);if(i)return i(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var u=t[o]={exports:{}};n[o][0].call(u.exports,function(e){var t=n[o][1][e];return a(t?t:e)},u,u.exports,e,n,t,r)}return t[o].exports}for(var i="function"==typeof require&&require,o=0;or;r+=4)a=i(e,r)<<18|i(e,r+1)<<12|i(e,r+2)<<6|i(e,r+3),c.push(String.fromCharCode(a>>16,a>>8&255,255&a));switch(n){case 1:a=i(e,r)<<18|i(e,r+1)<<12|i(e,r+2)<<6,c.push(String.fromCharCode(a>>16,a>>8&255));break;case 2:a=i(e,r)<<18|i(e,r+1)<<12,c.push(String.fromCharCode(a>>16))}return c.join('')},t.getbyte=function(e,n){var r=e.charCodeAt(n);if(r>255)throw t.makeDOMException();return r},t.encode=function(e){if(1!==arguments.length)throw new SyntaxError('Not enough arguments');var n,r,a=t.PADCHAR,i=t.ALPHA,o=t.getbyte,c=[];e=''+e;var l=e.length-e.length%3;if(0===e.length)return e;for(n=0;l>n;n+=3)r=o(e,n)<<16|o(e,n+1)<<8|o(e,n+2),c.push(i.charAt(r>>18)),c.push(i.charAt(r>>12&63)),c.push(i.charAt(r>>6&63)),c.push(i.charAt(63&r));switch(e.length-l){case 1:r=o(e,n)<<16,c.push(i.charAt(r>>18)+i.charAt(r>>12&63)+a+a);break;case 2:r=o(e,n)<<16|o(e,n+1)<<8,c.push(i.charAt(r>>18)+i.charAt(r>>12&63)+i.charAt(r>>6&63)+a)}return c.join('')},e.url='pay.htm',e.pay=function(n){var i=encodeURIComponent(t.encode(n));a.call(r,'APURL')&&(e.url=r.APURL),location.href=e.url+'?goto='+i},e.decode=function(e){return t.decode(decodeURIComponent(e))},n.exports=e}()},{"../../stash":21}],8:[function(e,n,t){var r=e('./commons/redirect_base');n.exports={handleCharge:function(e){r.handleCharge(e)}}},{"./commons/redirect_base":5}],9:[function(e,n,t){arguments[4][8][0].apply(t,arguments)},{"./commons/redirect_base":5,dup:8}],10:[function(e,n,t){var r=e('../utils'),a={}.hasOwnProperty;n.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 n=e.credential[e.channel],t=this.JDPAY_H5_URL;a.call(n,'channelUrl')?(t=n.channelUrl,delete n.channelUrl):a.call(n,'merchantRemark')&&(t=this.JDPAY_WAP_URL_OLD),r.formSubmit(t,'post',n)}}},{"../utils":23}],11:[function(e,n,t){var r=e('../utils');n.exports={UPACP_PC_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){var n=e.credential[e.channel];r.formSubmit(this.UPACP_PC_URL,'post',n)}}},{"../utils":23}],12:[function(e,n,t){var r=e('../utils');n.exports={UPACP_WAP_URL:'https://gateway.95516.com/gateway/api/frontTransReq.do',handleCharge:function(e){var n=e.credential[e.channel];r.formSubmit(this.UPACP_WAP_URL,'post',n)}}},{"../utils":23}],13:[function(e,n,t){var r=e('../callbacks'),a=e('../utils'),i=e('../stash'),o=e('../mods'),c={}.hasOwnProperty;n.exports={PINGPP_NOTIFY_URL_BASE:'https://api.pingxx.com/notify/charges/',handleCharge:function(e){for(var n=e.credential[e.channel],t=['appId','timeStamp','nonceStr','package','signType','paySign'],a=0;a=200&&400>n&&'success'==e)r.innerCallback('success');else{var t='http_code:'+n+';response:'+e;r.innerCallback('fail',r.error('testmode_notify_fail',t))}},function(){r.innerCallback('fail',r.error('network_err'))})}}},{"../callbacks":1,"../mods":20,"../stash":21,"../utils":23}],14:[function(e,n,t){var r=e('../utils'),a=e('../callbacks'),i={}.hasOwnProperty;n.exports={handleCharge:function(e){var n=e.credential[e.channel];'string'==typeof n?r.redirectTo(n):'object'==typeof n&&i.call(n,'url')?r.redirectTo(n.url):a.innerCallback('fail',a.error('invalid_credential','credential 格式不正确'))}}},{"../callbacks":1,"../utils":23}],15:[function(e,n,t){var r=e('../utils'),a=e('../callbacks'),i={}.hasOwnProperty;n.exports={YEEPAY_WAP_URL:'https://ok.yeepay.com/paymobile/api/pay/request',YEEPAY_WAP_TEST_URL:'http://mobiletest.yeepay.com/paymobile/api/pay/request',handleCharge:function(e){for(var n=e.channel,t=e.credential[n],o=['merchantaccount','encryptkey','data'],c=0;c>16)+(n>>16)+(t>>16);return r<<16|65535&t}function t(e,n){return e<>>32-n}function r(n,r,a,i,o,c){return e(t(e(e(r,n),e(i,c)),o),a)}function a(e,n,t,a,i,o,c){return r(n&t|~n&a,e,n,i,o,c)}function i(e,n,t,a,i,o,c){return r(n&a|t&~a,e,n,i,o,c)}function o(e,n,t,a,i,o,c){return r(n^t^a,e,n,i,o,c)}function c(e,n,t,a,i,o,c){return r(t^(n|~a),e,n,i,o,c)}function l(n,t){n[t>>5]|=128<>>9<<4)+14]=t;var r,l,s,u,d,p=1732584193,f=-271733879,h=-1732584194,_=271733878;for(r=0;r>5]>>>n%32&255);return t}function u(e){var n,t=[];for(t[(e.length>>2)-1]=void 0,n=0;n>5]|=(255&e.charCodeAt(n/8))<16&&(a=l(a,8*e.length)),t=0;16>t;t+=1)i[t]=909522486^a[t],o[t]=1549556828^a[t];return r=l(i.concat(u(n)),512+8*n.length),s(l(o.concat(r),640))}function f(e){var n,t,r='0123456789abcdef',a='';for(t=0;t>>4&15)+r.charAt(15&n);return a}function h(e){return unescape(encodeURIComponent(e))}function _(e){return d(h(e))}function y(e){return f(_(e))}function m(e,n){return p(h(e),h(n))}function g(e,n){return f(m(e,n))}function v(e,n,t){return n?t?m(n,e):g(n,e):t?_(e):y(e)}n.exports=v}()},{}],19:[function(e,n,t){var r=e('./version').v,a=e('./testmode'),i=e('./callbacks'),o=e('./mods'),c=e('./stash'),l=e('./collection'),s={}.hasOwnProperty,PingppSDK=function(){e('./init').init()};PingppSDK.prototype={version:r,createPayment:function(e,n,t,r){'function'==typeof n&&(i.userCallback=n);var u;if('string'==typeof e)try{u=JSON.parse(e)}catch(d){return void i.innerCallback('fail',i.error('json_decode_fail',d))}else u=e;if('undefined'==typeof u)return void i.innerCallback('fail',i.error('json_decode_fail'));if(!s.call(u,'id'))return void i.innerCallback('fail',i.error('invalid_charge','no_charge_id'));if(!s.call(u,'channel'))return void i.innerCallback('fail',i.error('invalid_charge','no_channel'));s.call(u,'app')&&('string'==typeof u.app?c.app_id=u.app:'object'==typeof u.app&&'string'==typeof u.app.id&&(c.app_id=u.app.id)),l.report({type:'pure_sdk_click',channel:u.channel,ch_id:u.id});var p=u.channel;if(!s.call(u,'credential'))return void i.innerCallback('fail',i.error('invalid_charge','no_credential'));if(!u.credential)return void i.innerCallback('fail',i.error('invalid_credential','credential_is_undefined'));if(!s.call(u.credential,p))return void i.innerCallback('fail',i.error('invalid_credential','credential_is_incorrect'));if(!s.call(u,'livemode'))return void i.innerCallback('fail',i.error('invalid_charge','no_livemode_field'));var f=o.getChannelModule(p);return'undefined'==typeof f?(console.error('channel module "'+p+'" is undefined'),void i.innerCallback('fail',i.error('invalid_channel','channel module "'+p+'" is undefined'))):u.livemode===!1?void(s.call(f,'runTestMode')?f.runTestMode(u):a.runTestMode(u)):('undefined'!=typeof t&&(c.signature=t),'boolean'==typeof r&&(c.debug=r),void f.handleCharge(u))},setAPURL:function(e){c.APURL=e}},n.exports=new PingppSDK},{"./callbacks":1,"./collection":16,"./init":17,"./mods":20,"./stash":21,"./testmode":22,"./version":24}],20:[function(e,n,t){var r={}.hasOwnProperty,a={};n.exports=a,a.channels={alipay_pc_direct:e('./channels/alipay_pc_direct'),alipay_wap:e('./channels/alipay_wap'),bfb_wap:e('./channels/bfb_wap'),cp_b2b:e('./channels/cp_b2b'),fqlpay_qr:e('./channels/fqlpay_qr'),fqlpay_wap:e('./channels/fqlpay_wap'),jdpay_wap:e('./channels/jdpay_wap'),upacp_pc:e('./channels/upacp_pc'),upacp_wap:e('./channels/upacp_wap'),wx_pub:e('./channels/wx_pub'),wx_wap:e('./channels/wx_wap'),yeepay_wap:e('./channels/yeepay_wap')},a.extras={ap:e('./channels/extras/ap')},a.getChannelModule=function(e){return r.call(a.channels,e)?a.channels[e]:void 0},a.getExtraModule=function(e){return r.call(a.extras,e)?a.extras[e]:void 0}},{"./channels/alipay_pc_direct":2,"./channels/alipay_wap":3,"./channels/bfb_wap":4,"./channels/cp_b2b":6,"./channels/extras/ap":7,"./channels/fqlpay_qr":8,"./channels/fqlpay_wap":9,"./channels/jdpay_wap":10,"./channels/upacp_pc":11,"./channels/upacp_wap":12,"./channels/wx_pub":13,"./channels/wx_wap":14,"./channels/yeepay_wap":15}],21:[function(e,n,t){n.exports={}},{}],22:[function(e,n,t){var r=e('./utils'),a={}.hasOwnProperty;n.exports={PINGPP_MOCK_URL:'http://sissi.pingxx.com/mock.php',runTestMode:function(e){var n={ch_id:e.id,scheme:'http',channel:e.channel};a.call(e,'order_no')?n.order_no=e.order_no:a.call(e,'orderNo')&&(n.order_no=e.orderNo),a.call(e,'time_expire')?n.time_expire=e.time_expire:a.call(e,'timeExpire')&&(n.time_expire=e.timeExpire),a.call(e,'extra')&&(n.extra=encodeURIComponent(JSON.stringify(e.extra))),r.redirectTo(this.PINGPP_MOCK_URL+'?'+r.stringifyData(n))}}},{"./utils":23}],23:[function(e,n,t){var r={}.hasOwnProperty,a=n.exports={stringifyData:function(e,n,t){'undefined'==typeof t&&(t=!1);var a=[];for(var i in e)r.call(e,i)&&'function'!=typeof e[i]&&('bfb_wap'==n&&'url'==i||'yeepay_wap'==n&&'mode'==i||'channel_url'!=i&&a.push(i+'='+(t?encodeURIComponent(e[i]):e[i])));return a.join('&')},request:function(e,n,t,i,o,c){if('undefined'==typeof XMLHttpRequest)return void console.log('Function XMLHttpRequest is undefined.');var l=new XMLHttpRequest;if('undefined'!=typeof l.timeout&&(l.timeout=6e3),n=n.toUpperCase(),'GET'===n&&'object'==typeof t&&t&&(e+='?'+a.stringifyData(t,'',!0)),l.open(n,e,!0),'undefined'!=typeof c)for(var s in c)r.call(c,s)&&l.setRequestHeader(s,c[s]);'POST'===n?(l.setRequestHeader('Content-type','application/json; charset=utf-8'),l.send(JSON.stringify(t))):l.send(),'undefined'==typeof i&&(i=function(){}),'undefined'==typeof o&&(o=function(){}),l.onreadystatechange=function(){4==l.readyState&&i(l.responseText,l.status,l)},l.onerror=function(e){o(l,0,e)}},formSubmit:function(e,n,t){if('undefined'==typeof window)return void console.log('Not a browser, form submit url: '+e);var a=document.createElement('form');a.setAttribute('method',n),a.setAttribute('action',e);for(var i in t)if(r.call(t,i)){var o=document.createElement('input');o.setAttribute('type','hidden'),o.setAttribute('name',i),o.setAttribute('value',t[i]),a.appendChild(o)}document.body.appendChild(a),a.submit()},randomString:function(e){'undefined'==typeof e&&(e=32);for(var n='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',t=n.length,r='',a=0;e>a;a++)r+=n.charAt(Math.floor(Math.random()*t));return r},redirectTo:function(e){return'undefined'==typeof window?void console.log('Not a browser, redirect url: '+e):void(window.location.href=e)},inWeixin:function(){if('undefined'==typeof navigator)return!1;var e=navigator.userAgent.toLowerCase();return-1!==e.indexOf('micromessenger')},documentReady:function(e){return'undefined'==typeof document?void e():void('loading'!=document.readyState?e():document.addEventListener('DOMContentLoaded',e))}}},{}],24:[function(e,n,t){n.exports={v:'2.1.5'}},{}]},{},[19])(19)}); //# sourceMappingURL=pingpp.js.map