|
|
|
!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 i(a,l){if(!t[a]){if(!n[a]){var c="function"==typeof require&&require;if(!l&&c)return c(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var d=t[a]={exports:{}};n[a][0].call(d.exports,function(e){var t=n[a][1][e];return i(t?t:e)},d,d.exports,e,n,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,n,t){var r=e('./payment_elements.js');n.exports={userCallback:void 0,innerCallback:function(e,n){'function'==typeof this.userCallback&&('undefined'==typeof n&&(n=this.error()),this.userCallback(e,n),this.userCallback=void 0,r.clear())},error:function(e,n){return e='undefined'==typeof e?'':e,n='undefined'==typeof n?'':n,{msg:e,extra:n}}}},{"./payment_elements.js":8}],2:[function(e,n,t){var r=e('../stash'),i=e('../callbacks'),o={}.hasOwnProperty;n.exports={handleCharge:function(e){for(var n=e.credential[e.channel],t=['appId','timeStamp','nonceStr','package','signType','paySign'],a=0;a<t.length;a++)if(!o.call(n,t[a]))return void i.innerCallback('fail',i.error('invalid_credential','missing_field_'+t[a]));r.jsApiParameters=n,this.callpay()},wxLiteEnabled:function(){return'undefined'!=typeof wx&&wx.requestPayment},callpay:function(){if(!this.wxLiteEnabled())return void console.log('请在微信小程序中打开');var e=r.jsApiParameters;delete e.appId,e.complete=function(e){'requestPayment:ok'===e.errMsg&&i.innerCallback('success'),'requestPayment:cancel'===e.errMsg&&i.innerCallback('cancel',i.error('用户取消支付')),'undefined'!==e.err_code&&'undefined'!==e.err_desc&&i.innerCallback('fail',i.error(e.err_desc,e))},wx.requestPayment(e)},runTestMode:function(e){wx.showModal({title:'提示',content:'因 "微信小程序" 限制 域名的原因 暂不支持 模拟付款 请使用 livekey 获取 charge 进行支付'})}}},{"../callbacks":1,"../stash":9}],3:[function(e,n,t){var r=e('./utils'),i=e('./stash'),o=e('./libs/md5'),a={seperator:'###',limit:1,report_url:'https://statistics.pingxx.com/one_stats',timeout:100},l=function(e,n){var t=new RegExp('(^|&)'+n+'=([^&]*)(&|$)','i'),r=e.substr(0).match(t);return null!==r?unescape(r[2]):null},c=function(){return navigator.userAgent},u=function(){return window.location.host};a.store=function(e){if('undefined'!=typeof localStorage&&null!==localStorage){var n=this,t={};t.app_id=e.app_id||i.app_id||'app_not_defined',t.ch_id=e.ch_id||'',t.channel=e.channel||'',t.type=e.type||'',t.user_agent=c(),t.host=u(),t.time=(new Date).getTime(),t.puid=i.puid;var r='app_id='+t.app_id+'&channel='+t.channel+'&ch_id='+t.ch_id+'&host='+t.host+'&time='+t.time+'&type='+t.type+'&user_agent='+t.user_agent+'&puid='+t.puid,o=r;null!==localStorage.getItem('PPP_ONE_STATS')&&0!==localStorage.getItem('PPP_ONE_STATS').length&&(o=localStorage.getItem('PPP_ONE_STATS')+n.seperator+r);try{localStorage.setItem('PPP_ONE_STATS',o)}catch(a){}}},a.send=function(){if('undefined'!=typeof localStorage&&null!==localStorage){var e=this,n=localStorage.getItem('PPP_ONE_STATS');if(!(null===n||n.split(e.seperator).length<e.limit))try{for(var t=[],i=n.split(e.seperator),a=o(i.join('&')),c=0;c<i.length;c++)t.push({app_id:l(i[c],'app_id'),channel:l(i[c],'channel'),ch_id:l(i[c],'ch_id'),host:l(i[c],'host'),time:l(i[c],'time'),type:l(i[c],'type'),user_agent:l(i[c],'user_agent'),puid:l(i[c],'puid')});r.request(e.report_url,'POST',t,function(e,n){200==n&&localStorage.removeItem('PPP_ONE_STATS')},void 0,{'X-Pingpp-Report-Token':a})}catch(u){}}},a.report=function(e){var n=this;n.store(e),setTimeout(function(){n.send()},n.timeout)},n.exports=a},{"./libs/md5":5,"./stash":9,"./utils":11}],4:[function(e,n,t){var r=e('./stash'),i=e('./utils'),o=e('./collection');n.exports={SRC_URL:'https://cookie.pingxx.com',init:function(){var e=this;i.documentReady(function(){e.initPuid()})},initPuid:function(){if('undefined'!=typeof window&&'undefined'!=typeof localStorage){var e=localStorage.getItem('pingpp_uid');if(null===e){e=i.randomString();try{localStorage.setItem('pingpp_uid',e)}catch(n){}}if(r.puid=e,!document.getElementById('p_analyse_iframe')){var t=document.createElement('iframe');t.id='p_analyse_iframe',t.src=this.SRC_URL+'/?puid='+e,t.style.display='none',document.body.appendChild(t)}setTimeout(function(){o.send()},0)}}}},{"./collection":3,"./stash":9,"./utils":11}],5:[function(e,n,t){!function(){function e(e,n){var t=(65535&e)+(65535&n),r=(e>>16)+(n>>16)+(t>>16);return r<<16|65535&t}function t(e,n){return e<<n|e>>>32-n}function r(n,r,i,o,a,l){return e(t(e(e(r,n),e(o,l)),a),i)}function i(e,n,t,i,o,a,l){return r(n&t|~n&i,e,n,o,a,l)}function o(e,n,t,i,o,a,l){return r(n&i|t&~i,e,n,o,a,l)}function a(e,n,t,i,o,a,l){return r(n^t^i,e,n,o,a,l)}function l(e,n,t,i,o,a,l){return r(t^(n|~i),e,n,o,a,l)}function c(n,t){n[t>>5]|=128<<t%32,n[(t+64>>>9<<4)+14]=t;var r,c,u,d,s,f=1732584193,p=-271733879,h=-1732584194,m=271733878;for(r=0;r<n.length;r+=16)c=f,u=p,d=h,s=m,f=i(f,p,h,m,n[r],7,-680876936),m=i(m,f,p,h,n[r+1],12,-389564586),h=i(h,m,f,p,n[r+2],17,606105819),p=i(p,h,m,f,n[r+3],22,-1044525330),f=i(f,p,h,m,n[r+4],7,-176418897),m=i(m,f,p,h,n[r+5],12,1200080426),h=i(h,m,f,p,n[r+6],17,-1473231341),p=i(p,h,m,f,n[r+7],22,-45705983),f=i(f,p,h,m,n[r+8],7,1770035416),m=i(m,f,p,h,n[r+9],12,-1958414417),h=i(h,m,f,p,n[r+10],17,-42063),p=i(p,h,m,f,n[r+11],22,-1990404162),f=i(f,p,h,m,n[r+12],7,1804603682),m=i(m,f,p,h,n[r+13],12,-40341101),h=i(h,m,f,p,n[r+14],17,-1502002290),p=i(p,h,m,f,n[r+15],22,1236535329),f=o(f,p,h,m,n[r+1],5,-165796510),m=o(m,f,p,h,n[r+6],9,-1069501632),h=o(h,m,f,p,n[r+11],14,643717713),p=o(p,h,m,f,n[r],20,-373897302),f=o(f,p,h,m,n[r+5],5,-701558691),m=o(m,f,p,h,n[r+10],9,38016083),h=o(h,m,f,p,n[r+15],14,-660478335),p=o(p,h,m,f,n[r+4],20,-405537848),f=o(f,p,h,m,n[r+9],5,568446438),m=o(m,f,p,h,n[r+14],9,-1019803690),h=o(h,m,f,p,n[r+3],14,-187363961),p=o(p,h,m,f,n[r+8],20,1163531501),f=o(f,p,h,m,n[r+13],5,-1444681467),m=o(m,f,p,h,n[r+2],9,-51403784),h=o(h,m,f,p,n[r+7],14,1735328473),p=o(p,h,m,f,n[r+12],20,-1926607734),f=a(f,p,h,m,n[r+5],4,-378558),m=a(m,f,p,h,n[r+8],11,-2022574463),h=a(h,m,f,p,n[r+11],16,1839030562),p=a(p,h,m,f,n[r+14],23,-35309556),f=a(f,p,h,m,n[r+1],4,-1530992060),m=a(m,f,p,h,n[r+4],11,1272893353),h=a(h,m,f,p,n[r+7],16,-155497632),p=a(p,h,m,f,n[r+10],23,-1094730640),f=a(f,p,h,m,n[r+13],4,681279174),m=a(m,f,p,h,n[r],11,-358537222),h=a(h,m,f,p,n[r+3],16,-722521979),p=a(p,h,m,f,n[r+6],23,76029189),f=a(f,p,h,m,n[r+9],4,-640364487),m=a(m,f,p,h,n[r+12],11,-421815835),h=a(h,m,f,p,n[r+15],16,530742520),p=a(p,h,m,f,n[r+2],23,-995338651),f=l(f,p,h,m,n[r],6,-198630844),m=l(m,f,p,h,n[r+7],10,1126891415),h=l(h,m,f,p,n[r+14],15,-1416354905),p=l(p,h,m,f,n[r+5],21,-57434055),f=l(f,p,h,m,n[r+12],6,1700485571),m=l(m,f,p,h,n[r+3],10,-1894986606),h=l(h,m,f,p,n[r+10],15,-1051523),p=l(p,h,m,f,n[r+1],21,-2054922799),f=l(f,p,h,m,n[r+8],6,1873313359),m=l(m,f,p,h,n[r+15],10,-30611744),h=l(h,m,f,p,n[r+6],15,-1560198380),p=l(p,h,m,f,n[r+13],21,1309151649),f=l(f,p,h,m,n[r+4],6,-145523070),m=l(m,f,p,h,n[r+11],10,-1120210379),h=l(h,m,f,p,n[r+2],15,718787259),p=l(p,h,m,f,n[r+9],21,-343485551),f=e(f,c),p=e(p,u),h=e(h,d),m=e(m,s);return[f,p,h,m]}function u(e){var n,t='';for(n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}function d(e){var n,t=[];for(t[(e.length>>2)-1]=void 0,n=0;n<t.length;n+=1)t[n]=0;for(n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<n%32;return t}function s(e){return u(c(d(e),8*e.length))}function f(e,n){var t,r,i=d(e),o=[],a=[];for(o[15]=a[15]=void 0,i.length>16&&(i=c(i,8*e.length)),t=0;t<16;t+=1)o[t]=909522486^i[t],a[t]=1549556828^i[t];return r=c(o.concat(d(n)),512+8*n.length),u(c(a.concat(r),640))}function p(e){var n,t,r='0123456789abcdef',i='';for(t=0;t<e.length;t+=1)n=e.charCodeAt(t),i+=r.charAt(n>>>4&15)+r.charAt(15&n);return i}function h(e){return unescape(encodeURIComponent(e))}function m(e){return s(h(e))}function _(e){return p(m(e))}function y(e,n){return f(h(e),h(n))}function g(e,n){return p(y(e,n))}function v(e,n,t){return n?t?y(n,e):g(n,e):t?m(e):_(e)}n.exports=v}()},{}],6:[function(e,n,t){var r=e('./version').v,i=e('./testmode'),o=e('./callbacks'),a=e('./mods'),l=e('./stash'),c=e('./collection'),u=e('./payment_elements'),d={}.hasOwnProperty,PingppSDK=function(){e('./init').init()};PingppSDK.prototype={version:r,createPayment:function(e,n,t,r){if('function'==typeof n&&(o.userCallback=n),u.init(e),!d.call(u,'id'))return void o.innerCallback('fail',o.error('invalid_charge','no_charge_id'));if(!d.call(u,'channel'))return void o.innerCallback('fail',o.error('invalid_charge','no_channel'));d.call(u,'app')&&('string'==typeof u.app?l.app_id=u.app:'object'==typeof u.app&&'string'==typeof u.app.id&&(l.app_id=u.app.id)),c.report({type:'pure_sdk_click',channel:u.channel,ch_id:u.id});var s=u.channel;if(!d.call(u,'credential'))return void o.innerCallback('fail',o.error('invalid_charge','no_credential'));if(!u.credential)return void o.innerCallback('fail',o.error('invalid_credential','credential_is_undefined'));if(!d.call(u.credential,s))return void o.innerCallback('fail',o.error('invalid_credential','credential_is_incorrect'));if(!d.call(u,'livemode'))return void o.innerCallback('fail',o.error('invalid_charge','no_livemode_field'));var f=a.getChannelModule(s);return'undefined'==typeof f?(console.error('channel module "'+s+'" is undefined'),void o.innerCallback('fail',o.error('invalid_channel','channel module "'+s+'" is undefined'))):u.livemode===!1?void(d.call(f,'runTestMode')?f.runTestMode(u):i.runTestMode(u)):('undefined'!=typeof t&&(l.signature=t),'boolean'==typeof r&&(l.debug=r),void f.handleCharge(u))},setAPURL:function(e){l.APURL=e}},n.exports=new PingppSDK},{"./callbacks":1,"./collection":3,"./init":4,"./mods":7,"./payment_elements":8,"./stash":9,"./testmode":10,"./version":12}],7:[function(e,n,t){var r={}.hasOwnProperty,i={};n.exports=i,i.channels={wx_lite:e('./channels/wx_lite')},i.extras={},i.getChannelModule=function(e){if(r.call(i.channels,e))return i.channels[e]},i.getExtraModule=function(e){if(r.call(i.extras,e))return i.extras[e]}},{"./channels/wx_lite":2}],8:[function(e,n,t){var r=e('./callbacks'),i={}.hasOwnProperty;n.exports={id:null,or_id:null,channel:null,app:null,credential:{},extra:null,livemode:null,order_no:null,time_expire:null,init:function(e){var n;if('string'==typeof e)try{n=JSON.parse(e)}catch(t){return void r.innerCallback('fail',r.error('json_decode_fail',t))}else n=e;if('undefined'==typeof n)return void r.innerCallback('fail',r.error('json_decode_fail'));if(i.call(n,'object')&&'order'==n.object){n.or_id=n.id,n.id=n.charge,n.order_no=n.merchant_order_no;var o=n.charge_essentials;n.channel=o.channel,n.credential=o.credential,n.extra=o.extra}for(var a in this)i.call(n,a)&&(this[a]=n[a]);return this},clear:function(){for(var e in this)'function'!=typeof this[e]&&(this[e]=null)}}},{"./callbacks":1}],9:[function(e,n,t){n.exports={}},{}],10:[function(e,n,t){var r=e('./utils'),i={}.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};i.call(e,'or_id')&&null!==e.or_id&&(n.or_id=e.or_id),i.call(e,'order_no')?n.order_no=e.order_no:i.call(e,'orderNo')&&(n.order_no=e.orderNo),i.call(e,'time_expire')?n.time_expire=e.time_expire:i.call(e,'timeExpire')&&(n.time_expire=e.timeExpire),i.call(e,'extra')&&(n.extra=encodeURIComponent(JSON.stringify(e.extra))),r.redirectTo(this.PINGPP_MOCK_URL+'?'+r.stringifyData(n))}}},{"./utils":11}],11:[function(e,n,t){var r={}.hasOwnProperty,i=n.exports={stringifyData:function(e,n,t){'undefined'==typeof t&&(t=!1);var i=[];for(var o in e)r.call(e,o)&&'function'!=typeof e[o]&&('bfb_wap'==n&&'url'==o||'yeepay_wap'==n&&'mode'==o||'channel_url'!=o&&i.push(o+'='+(t?encodeURIComponent(e[o]):e[o])));return i.join('&')},request:function(e,n,t,o,a,l){if('undefined'==typeof XMLHttpRequest)return void console.log('Function XMLHttpRequest is undefined.');var c=new XMLHttpRequest;if('undefined'!=typeof c.timeout&&(c.timeout=6e3),n=n.toUpperCase(),'GET'===n&&'object'==typeof t&&t&&(e+='?'+i.stringifyData(t,'',!0)),c.open(n,e,!0),'undefined'!=typeof l)for(var u in l)r.call(l,u)&&c.setRequestHeader(u,l[u]);'POST'===n?(c.setRequestHeader('Content-type','application/json; charset=utf-8'),c.send(JSON.stringify(t))):c.send(),'undefined'==typeof o&&(o=function(){}),'undefined'==typeof a&&(a=function(){}),c.onreadystatechange=function(){4==c.readyState&&o(c.responseText,c.status,c)},c.onerror=function(e){a(c,0,e)}},formSubmit:function(e,n,t){if('undefined'==typeof window)return void console.log('Not a browser, form submit url: '+e);var i=document.createElement('form');i.setAttribute('method',n),i.setAttribute('action',e);for(var o in t)if(r.call(t,o)){var a=document.createElement('input');a.setAttribute('type','hidden'),a.setAttribute('name',o),a.setAttribute('value',t[o]),i.appendChild(a)}document.body.appendChild(i),i.submit()},randomString:function(e){'undefined'==typeof e&&(e=32);for(var n='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',t=n.length,r='',i=0;i<e;i++)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 e.indexOf('micromessenger')!==-1},documentReady:function(e){return'undefined'==typeof document?void e():void('loading'!=document.readyState?e():document.addEventListener('DOMContentLoaded',e))},loadUrlJs:function(e,n,t){var r=document.getElementsByTagName('head')[0],i=null;null==document.getElementById(e)?(i=document.createElement('script'),i.setAttribute('type','text/javascript'),i.setAttribute('src',n),i.setAttribute('id',e),i.async=!0,null!=t&&(i.onload=i.onreadystatechange=function(){return!i.ready&&void(i.readyState&&'loaded'!=i.readyState&&'complete'!=i.readyState||(i.ready=!0,t()))}),r.appendChild(i)):null!=t&&t()}}},{}],12:[function(e,n,t){n.exports={v:'2.1.7'}},{}]},{},[6])(6)});
|