From 8909bb68cce0df83b7d514a1b7d5257c70e6a41a Mon Sep 17 00:00:00 2001 From: devil_gong Date: Wed, 29 May 2019 16:57:10 +0800 Subject: [PATCH] debug --- application/index/controller/Order.php | 7 +- .../index/view/default/order/index.html | 16 +- .../default/orderaftersale/aftersale.html | 28 +- application/service/OrderService.php | 11 +- extend/payment/Weixin.php | 40 +- public/php_sdk_v3.0.10/doc/README | 55 - public/php_sdk_v3.0.10/doc/README.doc | Bin 30720 -> 0 bytes .../php_sdk_v3.0.10/example/WxPay.Config.php | 116 - .../example/WxPay.JsApiPay.php | 230 -- .../example/WxPay.MicroPay.php | 166 - .../example/WxPay.NativePay.php | 76 - public/php_sdk_v3.0.10/example/download.php | 60 - public/php_sdk_v3.0.10/example/index.php | 68 - public/php_sdk_v3.0.10/example/jsapi.php | 138 - public/php_sdk_v3.0.10/example/log.php | 125 - public/php_sdk_v3.0.10/example/micropay.php | 73 - public/php_sdk_v3.0.10/example/native.php | 73 - .../php_sdk_v3.0.10/example/native_notify.php | 124 - public/php_sdk_v3.0.10/example/notify.php | 105 - public/php_sdk_v3.0.10/example/orderquery.php | 77 - .../example/phpqrcode/phpqrcode.php | 3312 ----------------- public/php_sdk_v3.0.10/example/qrcode.php | 15 - public/php_sdk_v3.0.10/example/refund.php | 101 - .../php_sdk_v3.0.10/example/refundquery.php | 112 - public/php_sdk_v3.0.10/lib/WxPay.Api.php | 620 --- .../lib/WxPay.Config.Interface.php | 76 - public/php_sdk_v3.0.10/lib/WxPay.Data.php | 3094 --------------- .../php_sdk_v3.0.10/lib/WxPay.Exception.php | 13 - public/php_sdk_v3.0.10/lib/WxPay.Notify.php | 105 - 29 files changed, 54 insertions(+), 8982 deletions(-) delete mode 100755 public/php_sdk_v3.0.10/doc/README delete mode 100755 public/php_sdk_v3.0.10/doc/README.doc delete mode 100755 public/php_sdk_v3.0.10/example/WxPay.Config.php delete mode 100755 public/php_sdk_v3.0.10/example/WxPay.JsApiPay.php delete mode 100755 public/php_sdk_v3.0.10/example/WxPay.MicroPay.php delete mode 100755 public/php_sdk_v3.0.10/example/WxPay.NativePay.php delete mode 100755 public/php_sdk_v3.0.10/example/download.php delete mode 100755 public/php_sdk_v3.0.10/example/index.php delete mode 100755 public/php_sdk_v3.0.10/example/jsapi.php delete mode 100755 public/php_sdk_v3.0.10/example/log.php delete mode 100755 public/php_sdk_v3.0.10/example/micropay.php delete mode 100755 public/php_sdk_v3.0.10/example/native.php delete mode 100755 public/php_sdk_v3.0.10/example/native_notify.php delete mode 100755 public/php_sdk_v3.0.10/example/notify.php delete mode 100755 public/php_sdk_v3.0.10/example/orderquery.php delete mode 100755 public/php_sdk_v3.0.10/example/phpqrcode/phpqrcode.php delete mode 100755 public/php_sdk_v3.0.10/example/qrcode.php delete mode 100755 public/php_sdk_v3.0.10/example/refund.php delete mode 100755 public/php_sdk_v3.0.10/example/refundquery.php delete mode 100755 public/php_sdk_v3.0.10/lib/WxPay.Api.php delete mode 100755 public/php_sdk_v3.0.10/lib/WxPay.Config.Interface.php delete mode 100755 public/php_sdk_v3.0.10/lib/WxPay.Data.php delete mode 100755 public/php_sdk_v3.0.10/lib/WxPay.Exception.php delete mode 100755 public/php_sdk_v3.0.10/lib/WxPay.Notify.php diff --git a/application/index/controller/Order.php b/application/index/controller/Order.php index 7a448b7ce..080e9b3d1 100755 --- a/application/index/controller/Order.php +++ b/application/index/controller/Order.php @@ -76,9 +76,10 @@ class Order extends Common // 获取列表 $data_params = array( - 'm' => $page->GetPageStarNumber(), - 'n' => $number, - 'where' => $where, + 'm' => $page->GetPageStarNumber(), + 'n' => $number, + 'where' => $where, + 'is_orderaftersale' => 1, ); $data = OrderService::OrderList($data_params); $this->assign('data_list', $data['data']); diff --git a/application/index/view/default/order/index.html b/application/index/view/default/order/index.html index 713c99b12..9bd7fa6fd 100755 --- a/application/index/view/default/order/index.html +++ b/application/index/view/default/order/index.html @@ -189,13 +189,25 @@ {{switch $order.status}} {{case 2|3}} - 退款/退货 + {{if empty($goods['orderaftersale'])}} + 退款/退货 + {{else /}} + 查看进度 + {{/if}} {{/case}} {{case 4}} 申请售后 {{/case}} {{case 6}} - 查看退款 + {{if empty($goods['orderaftersale']) or $goods['orderaftersale'] eq 5}} + 申请售后 + {{else /}} + {{if $goods['orderaftersale']['status'] eq 3}} + 查看退款 + {{else /}} + 查看进度 + {{/if}} + {{/if}} {{/case}} {{/switch}} diff --git a/application/index/view/default/orderaftersale/aftersale.html b/application/index/view/default/orderaftersale/aftersale.html index 5f2b5afff..a5f7abed1 100644 --- a/application/index/view/default/orderaftersale/aftersale.html +++ b/application/index/view/default/orderaftersale/aftersale.html @@ -100,22 +100,12 @@ - {{if empty($new_aftersale_data) or (isset($new_aftersale_data['status']) and in_array($new_aftersale_data['status'], [4,5]))}} + {{if empty($new_aftersale_data) or (isset($new_aftersale_data['status']) and $new_aftersale_data['status'] eq 5)}} - {{if isset($new_aftersale_data['status']) and in_array($new_aftersale_data['status'], [3,4])}} - {{switch $new_aftersale_data.status}} - {{case 4}} -
- 当前订单商品售后申请已被拒绝!详情查看 -
- {{/case}} - - {{case 5}} -
- 当前订单商品售后申请已关闭!详情查看 -
- {{/case}} - {{/switch}} + {{if isset($new_aftersale_data['status']) and $new_aftersale_data['status'] eq 5}} +
+ 当前订单商品售后申请已关闭!详情查看 +
{{/if}} @@ -179,11 +169,17 @@ 当前订单商品售后已处理结束!详情查看 {{/case}} + + {{case 4}} +
+ 当前订单商品售后申请已被拒绝!详情查看 +
+ {{/case}} {{/switch}} {{/if}} - {{if !empty($new_aftersale_data)}} + {{if !empty($new_aftersale_data) and $new_aftersale_data['status'] neq 5}}
diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 801af014f..ac31021c9 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -623,6 +623,7 @@ class OrderService $order_by = empty($params['order_by']) ? 'id desc' : $params['order_by']; $is_items = isset($params['is_items']) ? intval($params['is_items']) : 1; $is_excel_export = isset($params['is_excel_export']) ? intval($params['is_excel_export']) : 0; + $is_orderaftersale = isset($params['is_orderaftersale']) ? intval($params['is_orderaftersale']) : 0; // 获取订单 $data = Db::name('Order')->where($where)->limit($m, $n)->order($order_by)->select(); @@ -753,11 +754,11 @@ class OrderService $excel_export_items .= "\n"; } - // 是否获取售后信息 - // if($is_orderaftersale == 1) - // { - // $items['orderaftersale'] = Db::name('OrderAftersale')->where(['order_detail_id'=>$vs['id']])->find(); - // } + // 是否获取最新一条售后信息 + if($is_orderaftersale == 1) + { + $vs['orderaftersale'] = Db::name('OrderAftersale')->where(['order_detail_id'=>$vs['id']])->order('id desc')->find(); + } } } else { $buy_number_count = Db::name('OrderDetail')->where(['order_id'=>$v['id']])->sum('buy_number'); diff --git a/extend/payment/Weixin.php b/extend/payment/Weixin.php index 82d0b301b..c3d54b5fa 100755 --- a/extend/payment/Weixin.php +++ b/extend/payment/Weixin.php @@ -173,9 +173,8 @@ class Weixin return $ret; } - // xml - $xml = $this->ArrayToXml($ret['data']); - $result = $this->XmlToArray($this->HttpRequest('https://api.mch.weixin.qq.com/pay/unifiedorder', $xml)); + // 请求接口处理 + $result = $this->XmlToArray($this->HttpRequest('https://api.mch.weixin.qq.com/pay/unifiedorder', $this->ArrayToXml($ret['data']))); if(!empty($result['return_code']) && $result['return_code'] == 'SUCCESS' && !empty($result['prepay_id'])) { return $this->PayHandleReturn($ret['data'], $result, $params); @@ -505,11 +504,8 @@ class Weixin ]; $data['sign'] = $this->GetSign($data); - // xml - $xml = $this->ArrayToXml($data); - // echo $xml;die; - $result = $this->XmlToArray($this->HttpRequest('https://api.mch.weixin.qq.com/secapi/pay/refund', $xml, true)); - print_r($result);die; + // 请求接口处理 + $result = $this->XmlToArray($this->HttpRequest('https://api.mch.weixin.qq.com/secapi/pay/refund', $this->ArrayToXml($data), true)); if(!empty($result['return_code']) && $result['return_code'] == 'SUCCESS' && !empty($result['prepay_id'])) { // 统一返回格式 @@ -640,25 +636,25 @@ class Weixin if($use_cert == true) { - // $apiclient_cert = "-----BEGIN CERTIFICATE-----\n"; - // $apiclient_cert .= wordwrap($this->config['apiclient_cert'], 64, "\n", true); - // $apiclient_cert .= "\n-----END CERTIFICATE-----"; + $apiclient_cert = "-----BEGIN CERTIFICATE-----\n"; + $apiclient_cert .= wordwrap($this->config['apiclient_cert'], 64, "\n", true); + $apiclient_cert .= "\n-----END CERTIFICATE-----"; - // $apiclient_key = "-----BEGIN PRIVATE KEY-----\n"; - // $apiclient_key .= wordwrap($this->config['apiclient_key'], 64, "\n", true); - // $apiclient_key .= "\n-----END PRIVATE KEY-----"; + $apiclient_key = "-----BEGIN PRIVATE KEY-----\n"; + $apiclient_key .= wordwrap($this->config['apiclient_key'], 64, "\n", true); + $apiclient_key .= "\n-----END PRIVATE KEY-----"; - // $options[CURLOPT_SSLCERTTYPE] = 'PEM'; - // $options[CURLOPT_SSLCERT] = $apiclient_cert; - // $options[CURLOPT_SSLKEYTYPE] = 'PEM'; - // $options[CURLOPT_SSLKEY] = $apiclient_key; + $options[CURLOPT_SSLCERTTYPE] = 'PEM'; + $options[CURLOPT_SSLCERT] = $apiclient_cert; + $options[CURLOPT_SSLKEYTYPE] = 'PEM'; + $options[CURLOPT_SSLKEY] = $apiclient_key; //设置证书 //使用证书:cert 与 key 分别属于两个.pem文件 - $options[CURLOPT_SSLCERTTYPE] = 'PEM'; - $options[CURLOPT_SSLCERT] = ROOT.'cert/apiclient_cert.pem'; - $options[CURLOPT_SSLKEYTYPE] = 'PEM'; - $options[CURLOPT_SSLKEY] = ROOT.'cert/apiclient_key.pem'; + // $options[CURLOPT_SSLCERTTYPE] = 'PEM'; + // $options[CURLOPT_SSLCERT] = ROOT.'cert/apiclient_cert.pem'; + // $options[CURLOPT_SSLKEYTYPE] = 'PEM'; + // $options[CURLOPT_SSLKEY] = ROOT.'cert/apiclient_key.pem'; } $ch = curl_init($url); diff --git a/public/php_sdk_v3.0.10/doc/README b/public/php_sdk_v3.0.10/doc/README deleted file mode 100755 index 8f4a132f9..000000000 --- a/public/php_sdk_v3.0.10/doc/README +++ /dev/null @@ -1,55 +0,0 @@ -SDK -ַ -http://paysdk.weixin.qq.com/ - -ٴָ -١װnginx+phpfpm+php -ڡSDKѹվĿ¼ -ۡ޸lib/WxPay.Config.phpΪԼ̻ŵϢ˵ -ݡ֤滻certµļ -ޡ - -SDKĿ¼ṹ -|-- lib -|-- logs -`-- example - - -Ŀ¼ܼ -lib -APIӿڷװ -WxPay.Api.php ΢֧APIӿڵķװ -WxPay.Config.Interface.php ̻ , ҵҪ̳УעⱣԼԿ/֤ȣ -WxPay.Data.php װ -WxPay.Exception.php 쳣 -WxPay.Notify.php ص֪ͨ - -cert -֤·֤Ե¼̻ƽ̨https://pay.weixin.qq.com/index.php/account/api_cert -ע: -1.֤ļܷwebĿ¼ӦзȨ޿ƵĿ¼Уֹأ -2.齫֤ļΪҲײ²ļ -3.̻ҪòľǷȡ֤ļ - -example -· - -example/phpqrcode -Դάphp - -logs -־ļ - -ָ -MCHID = '1225312702'; -ʼе̻ - -APPID = 'wx426b3015555a46be'; -ʼеģ˺APPIDӦAPPID - -KEY = 'e10adc3949ba59abbe56e057f20f883e' -ʹ̻ƽ̨¼˻¼http://pay.weixin.qq.com ƽ̨õġAPIԿΪ˰ȫΪ32ַ - -APPSECRET = '01c6d59a3f9024db6336662ac95c8e74' -IJJSAPI֧openƽ̨˻ܽJSAPI֧ʱҪȡûopenidʹAPPIDӦĹƽ̨¼http://mp.weixin.qq.com ĿĻȡAppSecret - diff --git a/public/php_sdk_v3.0.10/doc/README.doc b/public/php_sdk_v3.0.10/doc/README.doc deleted file mode 100755 index ea33f69ce2f8c8de2f32f661a27ecf13f6ef3c76..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30720 zcmeHQ2V9iLwx8XlEJ_m*6)Yw;^NQU?;zKa=Dzm9RXO?=HEyHmHEe5=p7vm#;W{} zP$M#imW2^A7TAz6eI^|#9eMr1^#=;yj~*IA6K3CpvHjB=h7ocF%3!^ZVtsJPNNZ*PW)H0kLxO{5`GtR#* zN_(6U+i22kN&cK*gZc|HyFh97PHz8;|s< zuySrLTp9YWKRLb}C$7CHpFntWa^@(PKj-Esm%c8_#j8!Z{>ag~(sTZgQ7+|B#rb@m z*3O4>b8_a~by1Eh*N(O6KMSuN|G&%4wO3u`uFIb*@1Lc0@uRW19|qEm=)_Lw^_t8G zPaO@7nz8%O=A(}PcS<0D^C_s;mu;7Vj1)t0skQbjG&!Sii zi)Z6l2aI3QKqL_N-lfOF5c_qAl2iGt>;SR9UwY|;ZqbiY2Zrh~DMBClbd$w`i#nbntMrp}bTl;|-TVoP|q3l8|CVO$-@I9fn$uMqC;E=|g;0`M=G`n0N+xaXj2m zyM8P`ygYz6>||ECgf~v_qdL2RN6h=$ikN0VrL?D1Cu)0WnUAgPn&dZ)Vpoi7<_ENHvz3|tMH3J z__+7=wN*%%!c!DdCpWcZ==-uzU({nHQ74qk4k@WLik>KWo6%in6+}5onO@Wy|L8$O zXWW)j57Lz{2%#{Ys3X~r7J5YaF4`FG=%1NNVb&5|x&0#Ps4ZDnB!v>MP{05k917aW+m;~q= zVb%-qvEI-CS^(yN70?mr3^)Q^0Vkk4&=cqd^Z~qp{(wI~YnI=txz7uQt*Vkf?>!ZP zWtZr4_QX-;=WLzw`5z9@GKscilNmD*jHH~Du7N_HL8Isq6W79h-z9}5Sn--PiZ*C* z5N>+9x7UK#=xD|IrctdBr8oFqHy8^&tfYu809Uw(D_jUCTW4D5QTv+!y#Oh25V!@X z_6dFT1rg8{Z~|2ONF?0rffnc|5+DPhezOmtzT=O+GZgq5pngPs=(Va`)sDYUAS8FJ z_M;-G`C0Q$7)xlJRE|kgW)1b7Jmh3b$*7z_tEkvz_KVg_D~1pA(Ut2-wq%7Yz8t&T zN9L!QF>S(?0B-Ezi)lQrtslEYXZzHjFgJwsAC1hP#-VYTW)owevuRYN(H7%WXl{It z(|)Fa&~pVhu9`k&5Q*hRw*BRNSo?mrq!DbQRFPD$+iIj5*((27cx^gGU3<*h(BuX)yB%Pp3 zf`Tn4+DnwJs4Q;)O6kG;@eF)l)^0M=@>W4!m_sSK(p*I-Pe2RGpbsfmD!Cps-SxTs zvp$ZeBhO5IDQoIW^AD>OS=8QXR|2e3x=6XyF=%~V`QreR#Rr+a3SJPBnM%?n?w?A7 zW@9$2ZY?finW-%FVt{6bwWKJN@}#-fXw*Q49+!w`GNXDcTO}v()7q0Jt&Tetrz;mR z~g#E?0xyHWx-S%QNbyP)k590ks6w5>QJ(EdjLz)DlojKrI2a1k@5x zOW@x|0(>oFX2f_biD$sHQEKH8P7V56Pyu}vO7_}-*Z-)Y{Qgcu_5L&F&&DU-oNWJ0 zKL6k2+T);k6IAjPI^Y%H9`F*-!p@}$U?8OT%zf$e`6Y0I$zOZyn2FIr9~4yVdTwM)L6tuiJr@kp}siI zT4Mz4j;yhNbQZ;-djpKMX9H25C!o3*fkp-$fS-U(pZ#t@emLDN=-!^^-kv`idCHlD zwIrGFB#7I9DZYgRpOhs!IHS`R2de}YJiSvw#_wjBDB|%gBeZyo*Vlsi!Vk%{ASIl# zgy!(@GGbwXJ$q;SRNjDRk9-Vk_-QNnp^b2^A`IVeQyC~ewHKvvL4A14oacfvG*l^r z=@dHAZ-g>1l``iQl)7{D^%iIt;|>v3q7{2^%istdS!#wc0bet+ zV2_0OWLbQ2XyEwKvZUcQi!Vc^uN zG;4}!6PK`jgC)-k4c7)pRR^b8g7-z*kKRehQH}Ty)rUOZ2pUj!{v8?yS)7qC`!t?;UYoIji#el_9YQ zZ_e2{XOd&cS;;ZE@rV~aerovr+4SIaNJK6du#e@He`VwSqmYv$Px&5(Cdy)yY;EY7 zIrqDfMPl8VkEb7+c5$*_Nl}wFskZsK9=7WyvofpnXmhjcW)H9XoYty$K$yAyarHl3 z-)+x+Rkq;1$Yj}Ot)d@2dYp+aOLaYxKDBuI`i*Ub!Q)2HSU2(d?$Cq27uUI*vop*0 z+#_CSWRO+rbI^agd&I?J!xFFF*E>rs(l_Rf3BB5K$;zg89Q%L&!o>e-ml50NZYq}V zDiWVv>2oZ7N5_iZ8u48g^pCkKU9-uyJm667CfVjoEiUZd_v*@9ROQo(jvBwnWEv{^ z1wdDElA~pDGFz4BfUx+mC|M%)5Z$u_>J^C$dzMXJGd8!hOZWk+-qM|CwjX%OJXV;x zonBqC>iX4+@@ZYp-!{Iy+*@x*#}(RoU&zkcWbLh*)N!NPrXM_;o$MG}cDm8M2jiL) ze?7b5?S9`R`Au$pId}TD-8V&7c6Yek>T$=LA^R;xx@Pwc`sw@Xc0cxh*uk+g=a z(js_%^O&5-gJuo+ZN_&r_WFL_Of9d_*SyP=m%5$MY1=V=-^nD+tH+*X==F1n-*@%R&0*(K_Vs*X z=x0(s!@20jp@O$%+V?Lm5{}7iUNHBS$;f?c4Cil~w9;TilP5{BQ^WT;O8aGMtgtNq zP3+e9PM5W>{MYyv_su%7z2Q3HjgY3ZzhTbbrN8~9VywZ<)MkXrEp$LrX9?=G)%Y5BC1NZBLKW zBUeAa@Z*8uaf`FHLY{?&l;3z>@!io5zCYg%E*g7)*XtteUsPYMS{Y=mxpGR-YU9u$ zMM3q??Fn+Is%PwP)N<>Z`f2&iIu2Uy)+guD;Ifq44+nWC-S;*Q^cXZe@rwr8CpQeu zzF@s5nJ1cJtYhRXbv)L(bB4XXVVgHPV^WK|W*%R@ddZk3HVf+AbZ`3Z%&LuZ0()IB z>9cJ2UCsW#{*ZgOyvohpa&1|fZpd)Gr>{%r?pWnIX3k?**TdCkp1gf?x;jnLyy+lk zs}>Ij?Kmv|@p0c(PU)_%US6KIqjKE#a`~?hcHKXc9;1ESYjLY_PhOPwSk*o4N!7E( zJzNToF4y_tYT0C?ut&pA^*!%ka_o4Zu>ZYrJ;pm{r)6cuU(7k(?4;*;>66bKA0e#!A0t4@W#xmz4~ zdbr0=7aYfCNLwHI@`1+J3$G2+YULOml5b@aofF=%+4$MbN5l@fIlw(<-=jRY<6X^k z?pux-nl;#?r0ttN4%V|%JvGKJEfu;So_($I=IEh0KMcBgYNn;pqk6rp@4i`L8g?*i z1HZT9;>pH-u6GW2W;)J0G{pYGnC3R3@5B2q{l2O6e4JyD(cm46o_mXIUw-}g;*bdQ zhHm!i@Vt^c|%xZt^6-1M4v28x?z#&F}`h) zhF1Ivk*wUJ|0MTb*Xm!?cv;;$$f@bG{SWQNTILk(3Dpap?CtVppNX+cx^FkhetNNU zBZE075)a;qDzDnq%0D^3aFWKE8y)t9zu0t8B#OH|BhztdzqPTg{D$j(EBc3al5pAd z%%P>uVSalHHubB{4&3$?8#!dqh=+HN&e&4+y2X-=1}=WBzL;t66SKK->A>Pii{9JQpMrYl>+^+BK%v0Cz6&~*Y z4>z9~?&q}gcdz%`_SP)>`+KI9gLY3jRp@`=TDOt=7Vb1?)2ZkD8O~Err*+M-^mQH< zKfXcpqBFauc$S#G>-?>KzkSiITWsJ3t)0Kwt(S(Rnb+DG9Tu<3pK{8}!+5V$N2BcQ zye-qVu5d`qP3}}YuJduhnvKKF^714;Ze;=63PJ|n+o;z1*V@&-VXj(Tlw$OYZI5a>OUlVZof%PC6G4uKP*4^7z69QOTEv zml-c4Xl>EH{L_XZS3SGMRu;B3EB+>C?f%N8Gd6#-JtoL5d`54x z!LuqJEIW8=WCQ7i&WDONmKyDiFq)^xU z+{(Gj4uyYpwBe>h{pMc?JhF520i(TJ`wreX?N~rcT0!u(p-oJ!UoLE4@^jJ5cQI3c zxy^qPUF3bIU87<7M%`U3gpR#jcem{)6U66Tm!^$6n%8N7XVIa6s^uZRPp1uAb8l>7 zNNI<=Bhz-R81*`B|FtLC(^I!3H#W@{u3Nh*E&0LmEmls;(mmwdasgWK+# zaoTCyZXJ5)G_zi%!g=7? z%QyGe_%^t(@Wk!+Rp;@oac8rxc`c%;n9s~|eZ45^dVtW z%qUeRP|C@aiuh}Dsy&PO!0F28I4R~dwRzO;1Rr=@$L#>s()>=B@b%VI{N{irR$jwV z`zyFWfa?Z5FozPQ$`X@e65?IW?QF#6B3XQRLPSh_l&kr`z&_Sp%|%JcVet`Ru?g`q zSM%|*B=a8K_3F8VIfch24hS190)zM@r!ZIZ=;Y+lPPVp5;h1HHCD|m5mc=71G9fW8 zEE&$kDBFm{u(4nq7i()T7CYL;g~i01i=G-h+01Rblk`?%VT%P9?E@%&pn)j76hH1j!ba;TmbA32tqY2)`&h@(1sg>J!A^&V z=>RGD(dIEV6>S(GZdFfE#HHAwFpVlJg})A6F8ajqSv^HMN~2iF6T^9kW~joDhsFD! zW{5PzkP6@qYE+XE@uEHQ09L=M1*}IZ^tOV8rTY;UxF5oC|3@8T90vCZ2pb~fl zJO$|Zunr1Q56}k;faZV*umsuybhXz7=mGQue1Sk( zU7!JA3^V~mKpUVF&<$_}+yQSO92f;811Z3GU;;1=m=4SWz5sH8Re(0yp3v;QO&fNl z9~Y*iAIJE77#D}5pX0;%DdT)TFD}mKscITkyRu9W8Vv29`2+dDCg3DM{bm^2Z3IA@ zzAb_F0JU3pfZ8n>2n9aKrxPUedq89u>hCmOqyyAMi;1PbF;qj4#nml-OLkO+*0r$Nl=N&KyXanQ;@-9uTdug z8G8RYJ4gAn`9bD6($Jv2L^0YasA71N(-?wc55#Lf3P`~1mv{`Dv@`g@C}SyyQ$9DS zVrb>;nuyxBMJ`zJ`C0-^4Nbm4L*AaI>7GIOJ02$T6IDY|e>YpbD& z+G+`qAD`WkTVRX0#;hW-!gwGrDy1@45gPz^GImoLYOTTSgjrCb>k&6v5x+#*X=drD z6q@g%(?AEZEPw_dK1xF!OJGQ<@?&3x@`P`zn(iUM4fBQ=>f7O#wheA5JF^}b+$ZA& z+{;e$i}{U2CZeXI<|0dxqd8B^7YoFiVjXdPv7XpK+(6t&+*r($^X1xd9l5StUv4Tl zled(+%6rO($%o5B$M1Zk*996$3`9op_HrRgV)d^EUIIE`zRG8dp1ZUsPnbQ3@w@+d$Gfu@~8 z;0{3g>kRCw>1+qwEM!%9q}<7NFdF zQQJ;w#>Pa9k4~{Fe0`rf;w3MWc(BubitsM@F{pq7AI0%{4UC7_moS^{bbs3oA5fLa1-38*FT-z|aP zTmSPfpS!%m#>{a3Vyyo=zS=HE<^=$)*|7vy{5mzQ&qn~X-X9In?k4R_(WY4j&={cg zE$vL@0*1g6fY$M=0ouK#{Q_DGbL)B9D+uf@@#rlHRIG=IC#{PqPolKDN0fF4xE-&$ zs3MyBp_YJJ0%{4UC7_moS^{bbs3oA5fLa1-38*EYmcW0w1ZYjoeGg6FqtiN`*4y;G zJ*~s(`+Dw3Dt%W@|Mf=S&C|M{*7CH@r|X@vo{W|b^(N)n50E|zN6lmP zI^{oOIl-M#8U3q;~kD#uWLJ#Ob~LqxlnW`rke>nmCzBxhhY8 zjmOb)`ad2j6Zvre+@g&8xu?}%kiR7{s*%6uCpG_b<>`w2Y22c^llfd3Yx~)dM@{}b zocW~FtfO)GS*kctUpw~iyNxh)K;C>FW_CreateOauthUrlForCode($baseUrl); - Header("Location: $url"); - exit(); - } else { - //获取code码,以获取openid - $code = $_GET['code']; - $openid = $this->getOpenidFromMp($code); - return $openid; - } - } - - /** - * - * 获取jsapi支付的参数 - * @param array $UnifiedOrderResult 统一支付接口返回的数据 - * @throws WxPayException - * - * @return json数据,可直接填入js函数作为参数 - */ - public function GetJsApiParameters($UnifiedOrderResult) - { - if(!array_key_exists("appid", $UnifiedOrderResult) - || !array_key_exists("prepay_id", $UnifiedOrderResult) - || $UnifiedOrderResult['prepay_id'] == "") - { - throw new WxPayException("参数错误"); - } - - $jsapi = new WxPayJsApiPay(); - $jsapi->SetAppid($UnifiedOrderResult["appid"]); - $timeStamp = time(); - $jsapi->SetTimeStamp("$timeStamp"); - $jsapi->SetNonceStr(WxPayApi::getNonceStr()); - $jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']); - - $config = new WxPayConfig(); - $jsapi->SetPaySign($jsapi->MakeSign($config)); - $parameters = json_encode($jsapi->GetValues()); - return $parameters; - } - - /** - * - * 通过code从工作平台获取openid机器access_token - * @param string $code 微信跳转回来带上的code - * - * @return openid - */ - public function GetOpenidFromMp($code) - { - $url = $this->__CreateOauthUrlForOpenid($code); - - //初始化curl - $ch = curl_init(); - $curlVersion = curl_version(); - $config = new WxPayConfig(); - $ua = "WXPaySDK/3.0.9 (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." " - .$config->GetMerchantId(); - - //设置超时 - curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE); - curl_setopt($ch, CURLOPT_USERAGENT, $ua); - curl_setopt($ch, CURLOPT_HEADER, FALSE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - - $proxyHost = "0.0.0.0"; - $proxyPort = 0; - $config->GetProxy($proxyHost, $proxyPort); - if($proxyHost != "0.0.0.0" && $proxyPort != 0){ - curl_setopt($ch,CURLOPT_PROXY, $proxyHost); - curl_setopt($ch,CURLOPT_PROXYPORT, $proxyPort); - } - //运行curl,结果以jason形式返回 - $res = curl_exec($ch); - curl_close($ch); - //取出openid - $data = json_decode($res,true); - $this->data = $data; - $openid = $data['openid']; - return $openid; - } - - /** - * - * 拼接签名字符串 - * @param array $urlObj - * - * @return 返回已经拼接好的字符串 - */ - private function ToUrlParams($urlObj) - { - $buff = ""; - foreach ($urlObj as $k => $v) - { - if($k != "sign"){ - $buff .= $k . "=" . $v . "&"; - } - } - - $buff = trim($buff, "&"); - return $buff; - } - - /** - * - * 获取地址js参数 - * - * @return 获取共享收货地址js函数需要的参数,json格式可以直接做参数使用 - */ - public function GetEditAddressParameters() - { - $config = new WxPayConfig(); - $getData = $this->data; - $data = array(); - $data["appid"] = $config->GetAppId(); - $data["url"] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; - $time = time(); - $data["timestamp"] = "$time"; - $data["noncestr"] = WxPayApi::getNonceStr(); - $data["accesstoken"] = $getData["access_token"]; - ksort($data); - $params = $this->ToUrlParams($data); - $addrSign = sha1($params); - - $afterData = array( - "addrSign" => $addrSign, - "signType" => "sha1", - "scope" => "jsapi_address", - "appId" => $config->GetAppId(), - "timeStamp" => $data["timestamp"], - "nonceStr" => $data["noncestr"] - ); - $parameters = json_encode($afterData); - return $parameters; - } - - /** - * - * 构造获取code的url连接 - * @param string $redirectUrl 微信服务器回跳的url,需要url编码 - * - * @return 返回构造好的url - */ - private function _CreateOauthUrlForCode($redirectUrl) - { - $config = new WxPayConfig(); - $urlObj["appid"] = $config->GetAppId(); - $urlObj["redirect_uri"] = "$redirectUrl"; - $urlObj["response_type"] = "code"; - $urlObj["scope"] = "snsapi_base"; - $urlObj["state"] = "STATE"."#wechat_redirect"; - $bizString = $this->ToUrlParams($urlObj); - return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString; - } - - /** - * - * 构造获取open和access_toke的url地址 - * @param string $code,微信跳转带回的code - * - * @return 请求的url - */ - private function __CreateOauthUrlForOpenid($code) - { - $config = new WxPayConfig(); - $urlObj["appid"] = $config->GetAppId(); - $urlObj["secret"] = $config->GetAppSecret(); - $urlObj["code"] = $code; - $urlObj["grant_type"] = "authorization_code"; - $bizString = $this->ToUrlParams($urlObj); - return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString; - } -} diff --git a/public/php_sdk_v3.0.10/example/WxPay.MicroPay.php b/public/php_sdk_v3.0.10/example/WxPay.MicroPay.php deleted file mode 100755 index c359a7bb5..000000000 --- a/public/php_sdk_v3.0.10/example/WxPay.MicroPay.php +++ /dev/null @@ -1,166 +0,0 @@ -GetOut_trade_no(); - - //②、接口调用成功,明确返回调用失败 - if($result["return_code"] == "SUCCESS" && - $result["result_code"] == "FAIL" && - $result["err_code"] != "USERPAYING" && - $result["err_code"] != "SYSTEMERROR") - { - return false; - } - - //③、确认支付是否成功 - $queryTimes = 10; - while($queryTimes > 0) - { - $succResult = 0; - $queryResult = $this->query($out_trade_no, $succResult); - //如果需要等待1s后继续 - if($succResult == 2){ - sleep(2); - continue; - } else if($succResult == 1){//查询成功 - return $queryResult; - } else {//订单交易失败 - break; - } - } - - //④、次确认失败,则撤销订单 - if(!$this->cancel($out_trade_no)) - { - throw new WxpayException("撤销单失败!"); - } - - return false; - } - - /** - * - * 查询订单情况 - * @param string $out_trade_no 商户订单号 - * @param int $succCode 查询订单结果 - * @return 0 订单不成功,1表示订单成功,2表示继续等待 - */ - public function query($out_trade_no, &$succCode) - { - $queryOrderInput = new WxPayOrderQuery(); - $queryOrderInput->SetOut_trade_no($out_trade_no); - $config = new WxPayConfig(); - try{ - $result = WxPayApi::orderQuery($config, $queryOrderInput); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - if($result["return_code"] == "SUCCESS" - && $result["result_code"] == "SUCCESS") - { - //支付成功 - if($result["trade_state"] == "SUCCESS"){ - $succCode = 1; - return $result; - } - //用户支付中 - else if($result["trade_state"] == "USERPAYING"){ - $succCode = 2; - return false; - } - } - - //如果返回错误码为“此交易订单号不存在”则直接认定失败 - if($result["err_code"] == "ORDERNOTEXIST") - { - $succCode = 0; - } else{ - //如果是系统错误,则后续继续 - $succCode = 2; - } - return false; - } - - /** - * - * 撤销订单,如果失败会重复调用10次 - * @param string $out_trade_no - * @param 调用深度 $depth - */ - public function cancel($out_trade_no, $depth = 0) - { - try { - if($depth > 10){ - return false; - } - - $clostOrder = new WxPayReverse(); - $clostOrder->SetOut_trade_no($out_trade_no); - - $config = new WxPayConfig(); - $result = WxPayApi::reverse($config, $clostOrder); - - - //接口调用失败 - if($result["return_code"] != "SUCCESS"){ - return false; - } - - //如果结果为success且不需要重新调用撤销,则表示撤销成功 - if($result["result_code"] != "SUCCESS" - && $result["recall"] == "N"){ - return true; - } else if($result["recall"] == "Y") { - return $this->cancel($out_trade_no, ++$depth); - } - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - return false; - } -} \ No newline at end of file diff --git a/public/php_sdk_v3.0.10/example/WxPay.NativePay.php b/public/php_sdk_v3.0.10/example/WxPay.NativePay.php deleted file mode 100755 index f043bec75..000000000 --- a/public/php_sdk_v3.0.10/example/WxPay.NativePay.php +++ /dev/null @@ -1,76 +0,0 @@ -SetProduct_id($productId); - try{ - $config = new WxPayConfig(); - $values = WxpayApi::bizpayurl($config, $biz); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - $url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values); - return $url; - } - - /** - * - * 参数数组转换为url参数 - * @param array $urlObj - */ - private function ToUrlParams($urlObj) - { - $buff = ""; - foreach ($urlObj as $k => $v) - { - $buff .= $k . "=" . $v . "&"; - } - - $buff = trim($buff, "&"); - return $buff; - } - - /** - * - * 生成直接支付url,支付url有效期为2小时,模式二 - * @param UnifiedOrderInput $input - */ - public function GetPayUrl($input) - { - if($input->GetTrade_type() == "NATIVE") - { - try{ - $config = new WxPayConfig(); - $result = WxPayApi::unifiedOrder($config, $input); - return $result; - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - } - return false; - } -} \ No newline at end of file diff --git a/public/php_sdk_v3.0.10/example/download.php b/public/php_sdk_v3.0.10/example/download.php deleted file mode 100755 index 7928fca38..000000000 --- a/public/php_sdk_v3.0.10/example/download.php +++ /dev/null @@ -1,60 +0,0 @@ -SetBill_date($bill_date); - $input->SetBill_type($bill_type); - $config = new WxPayConfig(); - $file = WxPayApi::downloadBill($config, $input); - echo htmlspecialchars($file, ENT_QUOTES); - //TODO 对账单文件处理 - exit(0); -} -?> - - - - - 微信支付样例-查退款单 - - -
-
对账日期:

-

-
账单类型:

-

-
- -
-
- - diff --git a/public/php_sdk_v3.0.10/example/index.php b/public/php_sdk_v3.0.10/example/index.php deleted file mode 100755 index ed4c04d38..000000000 --- a/public/php_sdk_v3.0.10/example/index.php +++ /dev/null @@ -1,68 +0,0 @@ - - - - - 微信支付样例 - - - - - - \ No newline at end of file diff --git a/public/php_sdk_v3.0.10/example/jsapi.php b/public/php_sdk_v3.0.10/example/jsapi.php deleted file mode 100755 index 3ceba92fc..000000000 --- a/public/php_sdk_v3.0.10/example/jsapi.php +++ /dev/null @@ -1,138 +0,0 @@ -$value){ - echo "$key : ".htmlspecialchars($value, ENT_QUOTES)."
"; - } -} - -//①、获取用户openid -try{ - - $tools = new JsApiPay(); - $openId = $tools->GetOpenid(); - - //②、统一下单 - $input = new WxPayUnifiedOrder(); - $input->SetBody("test"); - $input->SetAttach("test"); - $input->SetOut_trade_no("sdkphp".date("YmdHis")); - $input->SetTotal_fee("1"); - $input->SetTime_start(date("YmdHis")); - $input->SetTime_expire(date("YmdHis", time() + 600)); - $input->SetGoods_tag("test"); - $input->SetNotify_url("http://paysdk.weixin.qq.com/notify.php"); - $input->SetTrade_type("JSAPI"); - $input->SetOpenid($openId); - $config = new WxPayConfig(); - $order = WxPayApi::unifiedOrder($config, $input); - echo '统一下单支付单信息
'; - printf_info($order); - $jsApiParameters = $tools->GetJsApiParameters($order); - - //获取共享收货地址js函数参数 - $editAddress = $tools->GetEditAddressParameters(); -} catch(Exception $e) { - Log::ERROR(json_encode($e)); -} -//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php -/** - * 注意: - * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功 - * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”, - * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html) - */ -?> - - - - - - 微信支付样例-支付 - - - - -
- 该笔订单支付金额为1分

-
- -
- - \ No newline at end of file diff --git a/public/php_sdk_v3.0.10/example/log.php b/public/php_sdk_v3.0.10/example/log.php deleted file mode 100755 index 379b62934..000000000 --- a/public/php_sdk_v3.0.10/example/log.php +++ /dev/null @@ -1,125 +0,0 @@ -handle = fopen($file,'a'); - } - - public function write($msg) - { - fwrite($this->handle, $msg, 4096); - } - - public function __destruct() - { - fclose($this->handle); - } -} - -class Log -{ - private $handler = null; - private $level = 15; - - private static $instance = null; - - private function __construct(){} - - private function __clone(){} - - public static function Init($handler = null,$level = 15) - { - if(!self::$instance instanceof self) - { - self::$instance = new self(); - self::$instance->__setHandle($handler); - self::$instance->__setLevel($level); - } - return self::$instance; - } - - - private function __setHandle($handler){ - $this->handler = $handler; - } - - private function __setLevel($level) - { - $this->level = $level; - } - - public static function DEBUG($msg) - { - self::$instance->write(1, $msg); - } - - public static function WARN($msg) - { - self::$instance->write(4, $msg); - } - - public static function ERROR($msg) - { - $debugInfo = debug_backtrace(); - $stack = "["; - foreach($debugInfo as $key => $val){ - if(array_key_exists("file", $val)){ - $stack .= ",file:" . $val["file"]; - } - if(array_key_exists("line", $val)){ - $stack .= ",line:" . $val["line"]; - } - if(array_key_exists("function", $val)){ - $stack .= ",function:" . $val["function"]; - } - } - $stack .= "]"; - self::$instance->write(8, $stack . $msg); - } - - public static function INFO($msg) - { - self::$instance->write(2, $msg); - } - - private function getLevelStr($level) - { - switch ($level) - { - case 1: - return 'debug'; - break; - case 2: - return 'info'; - break; - case 4: - return 'warn'; - break; - case 8: - return 'error'; - break; - default: - - } - } - - protected function write($level,$msg) - { - if(($level & $this->level) == $level ) - { - $msg = '['.date('Y-m-d H:i:s').']['.$this->getLevelStr($level).'] '.$msg."\n"; - $this->handler->write($msg); - } - } -} diff --git a/public/php_sdk_v3.0.10/example/micropay.php b/public/php_sdk_v3.0.10/example/micropay.php deleted file mode 100755 index 6be7de54c..000000000 --- a/public/php_sdk_v3.0.10/example/micropay.php +++ /dev/null @@ -1,73 +0,0 @@ - - - - - 微信支付样例-查退款单 - -$value){ - echo "$key : ".htmlspecialchars($value, ENT_QUOTES)."
"; - } -} - -if(isset($_REQUEST["auth_code"]) && $_REQUEST["auth_code"] != ""){ - try { - $auth_code = $_REQUEST["auth_code"]; - $input = new WxPayMicroPay(); - $input->SetAuth_code($auth_code); - $input->SetBody("刷卡测试样例-支付"); - $input->SetTotal_fee("1"); - $input->SetOut_trade_no("sdkphp".date("YmdHis")); - - $microPay = new MicroPay(); - printf_info($microPay->pay($input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } -} - -/** - * 注意: - * 1、提交被扫之后,返回系统繁忙、用户输入密码等错误信息时需要循环查单以确定是否支付成功 - * 2、多次(一半10次)确认都未明确成功时需要调用撤单接口撤单,防止用户重复支付 - */ - -?> - -
-
商品描述:

-

-
支付金额:

-

-
授权码:

-

-
- -
-
- - diff --git a/public/php_sdk_v3.0.10/example/native.php b/public/php_sdk_v3.0.10/example/native.php deleted file mode 100755 index d50f73efe..000000000 --- a/public/php_sdk_v3.0.10/example/native.php +++ /dev/null @@ -1,73 +0,0 @@ -GetPrePayUrl("123456789"); - -//模式二 -/** - * 流程: - * 1、调用统一下单,取得code_url,生成二维码 - * 2、用户扫描二维码,进行支付 - * 3、支付完成之后,微信服务器会通知支付成功 - * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php) - */ -$input = new WxPayUnifiedOrder(); -$input->SetBody("test"); -$input->SetAttach("test"); -$input->SetOut_trade_no("sdkphp123456789".date("YmdHis")); -$input->SetTotal_fee("1"); -$input->SetTime_start(date("YmdHis")); -$input->SetTime_expire(date("YmdHis", time() + 600)); -$input->SetGoods_tag("test"); -$input->SetNotify_url("http://paysdk.weixin.qq.com/notify.php"); -$input->SetTrade_type("NATIVE"); -$input->SetProduct_id("123456789"); - -$result = $notify->GetPayUrl($input); -$url2 = $result["code_url"]; -?> - - - - - - 微信支付样例-退款 - - -
扫描支付模式一

- 模式一扫码支付 -


-
扫描支付模式二

- 模式二扫码支付 -
微信支付样例程序,仅做参考
- - - \ No newline at end of file diff --git a/public/php_sdk_v3.0.10/example/native_notify.php b/public/php_sdk_v3.0.10/example/native_notify.php deleted file mode 100755 index 08a19b80e..000000000 --- a/public/php_sdk_v3.0.10/example/native_notify.php +++ /dev/null @@ -1,124 +0,0 @@ -SetBody("test"); - $input->SetAttach("test"); - $input->SetOut_trade_no($config->GetMerchantId().date("YmdHis")); - $input->SetTotal_fee("1"); - $input->SetTime_start(date("YmdHis")); - $input->SetTime_expire(date("YmdHis", time() + 600)); - $input->SetGoods_tag("test"); - $input->SetNotify_url("http://paysdk.weixin.qq.com/notify.php"); - $input->SetTrade_type("NATIVE"); - $input->SetOpenid($openId); - $input->SetProduct_id($product_id); - try { - $result = WxPayApi::unifiedOrder($config, $input); - Log::DEBUG("unifiedorder:" . json_encode($result)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - return $result; - } - - /** - * - * 回包前的回调方法 - * 业务可以继承该方法,打印日志方便定位 - * @param string $xmlData 返回的xml参数 - * - **/ - public function LogAfterProcess($xmlData) - { - Log::DEBUG("call back, return xml:" . $xmlData); - return; - } - - /** - * @param WxPayNotifyResults $objData 回调解释出的参数 - * @param WxPayConfigInterface $config - * @param string $msg 如果回调处理失败,可以将错误信息输出到该方法 - * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 - */ - public function NotifyProcess($objData, $config, &$msg) - { - $data = $objData->GetValues(); - //echo "处理回调"; - Log::DEBUG("call back:" . json_encode($data)); - //TODO 1、进行参数校验 - if(!array_key_exists("openid", $data) || - !array_key_exists("product_id", $data)) - { - $msg = "回调数据异常"; - Log::DEBUG($msg . json_encode($data)); - return false; - } - - //TODO 2、进行签名验证 - try { - $checkResult = $objData->CheckSign($config); - if($checkResult == false){ - //签名错误 - Log::ERROR("签名错误..."); - return false; - } - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - - $openid = $data["openid"]; - $product_id = $data["product_id"]; - - //TODO 3、处理业务逻辑 - //统一下单 - $result = $this->unifiedorder($openid, $product_id); - if(!array_key_exists("appid", $result) || - !array_key_exists("mch_id", $result) || - !array_key_exists("prepay_id", $result)) - { - $msg = "统一下单失败"; - Log::DEBUG($msg . json_encode($data)); - return false; - } - - $this->SetData("appid", $result["appid"]); - $this->SetData("mch_id", $result["mch_id"]); - $this->SetData("nonce_str", WxPayApi::getNonceStr()); - $this->SetData("prepay_id", $result["prepay_id"]); - $this->SetData("result_code", "SUCCESS"); - $this->SetData("err_code_des", "OK"); - return true; - } -} - -$config = new WxPayConfig(); -Log::DEBUG("begin notify!"); -$notify = new NativeNotifyCallBack(); -$notify->Handle($config, true); - - - - - diff --git a/public/php_sdk_v3.0.10/example/notify.php b/public/php_sdk_v3.0.10/example/notify.php deleted file mode 100755 index 9130603ca..000000000 --- a/public/php_sdk_v3.0.10/example/notify.php +++ /dev/null @@ -1,105 +0,0 @@ -SetTransaction_id($transaction_id); - - $config = new WxPayConfig(); - $result = WxPayApi::orderQuery($config, $input); - Log::DEBUG("query:" . json_encode($result)); - if(array_key_exists("return_code", $result) - && array_key_exists("result_code", $result) - && $result["return_code"] == "SUCCESS" - && $result["result_code"] == "SUCCESS") - { - return true; - } - return false; - } - - /** - * - * 回包前的回调方法 - * 业务可以继承该方法,打印日志方便定位 - * @param string $xmlData 返回的xml参数 - * - **/ - public function LogAfterProcess($xmlData) - { - Log::DEBUG("call back, return xml:" . $xmlData); - return; - } - - //重写回调处理函数 - /** - * @param WxPayNotifyResults $data 回调解释出的参数 - * @param WxPayConfigInterface $config - * @param string $msg 如果回调处理失败,可以将错误信息输出到该方法 - * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 - */ - public function NotifyProcess($objData, $config, &$msg) - { - $data = $objData->GetValues(); - //TODO 1、进行参数校验 - if(!array_key_exists("return_code", $data) - ||(array_key_exists("return_code", $data) && $data['return_code'] != "SUCCESS")) { - //TODO失败,不是支付成功的通知 - //如果有需要可以做失败时候的一些清理处理,并且做一些监控 - $msg = "异常异常"; - return false; - } - if(!array_key_exists("transaction_id", $data)){ - $msg = "输入参数不正确"; - return false; - } - - //TODO 2、进行签名验证 - try { - $checkResult = $objData->CheckSign($config); - if($checkResult == false){ - //签名错误 - Log::ERROR("签名错误..."); - return false; - } - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - - //TODO 3、处理业务逻辑 - Log::DEBUG("call back:" . json_encode($data)); - $notfiyOutput = array(); - - - //查询订单,判断订单真实性 - if(!$this->Queryorder($data["transaction_id"])){ - $msg = "订单查询失败"; - return false; - } - return true; - } -} - -$config = new WxPayConfig(); -Log::DEBUG("begin notify"); -$notify = new PayNotifyCallBack(); -$notify->Handle($config, false); diff --git a/public/php_sdk_v3.0.10/example/orderquery.php b/public/php_sdk_v3.0.10/example/orderquery.php deleted file mode 100755 index cf6522b21..000000000 --- a/public/php_sdk_v3.0.10/example/orderquery.php +++ /dev/null @@ -1,77 +0,0 @@ - - - - - 微信支付样例-订单查询 - -$value){ - echo "$key : ".htmlspecialchars($value, ENT_QUOTES)."
"; - } -} - - -if(isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != ""){ - try { - $transaction_id = $_REQUEST["transaction_id"]; - $input = new WxPayOrderQuery(); - $input->SetTransaction_id($transaction_id); - $config = new WxPayConfig(); - printf_info(WxPayApi::orderQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} - -if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){ - try{ - $out_trade_no = $_REQUEST["out_trade_no"]; - $input = new WxPayOrderQuery(); - $input->SetOut_trade_no($out_trade_no); - $config = new WxPayConfig(); - printf_info(WxPayApi::orderQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} -?> - -
-
微信订单号和商户订单号选少填一个,微信订单号优先:

-
微信订单号:

-

-
商户订单号:

-

-
- -
-
- - diff --git a/public/php_sdk_v3.0.10/example/phpqrcode/phpqrcode.php b/public/php_sdk_v3.0.10/example/phpqrcode/phpqrcode.php deleted file mode 100755 index 80adb9df2..000000000 --- a/public/php_sdk_v3.0.10/example/phpqrcode/phpqrcode.php +++ /dev/null @@ -1,3312 +0,0 @@ - - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - - -/* - * Version: 1.1.4 - * Build: 2010100721 - */ - - - -//---- qrconst.php ----------------------------- - - - - - -/* - * PHP QR Code encoder - * - * Common constants - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - // Encoding modes - - define('QR_MODE_NUL', -1); - define('QR_MODE_NUM', 0); - define('QR_MODE_AN', 1); - define('QR_MODE_8', 2); - define('QR_MODE_KANJI', 3); - define('QR_MODE_STRUCTURE', 4); - - // Levels of error correction. - - define('QR_ECLEVEL_L', 0); - define('QR_ECLEVEL_M', 1); - define('QR_ECLEVEL_Q', 2); - define('QR_ECLEVEL_H', 3); - - // Supported output formats - - define('QR_FORMAT_TEXT', 0); - define('QR_FORMAT_PNG', 1); - - class qrstr { - public static function set(&$srctab, $x, $y, $repl, $replLen = false) { - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); - } - } - - - -//---- merged_config.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Config file, tuned-up for merged verion - */ - - define('QR_CACHEABLE', false); // use cache - more disk reads but less CPU power, masks and format templates are stored there - define('QR_CACHE_DIR', false); // used when QR_CACHEABLE === true - define('QR_LOG_DIR', false); // default error logs dir - - define('QR_FIND_BEST_MASK', true); // if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code - define('QR_FIND_FROM_RANDOM', 2); // if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly - define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false - - define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images - - - - -//---- qrtools.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Toolset, handy and debug utilites. - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - class QRtools { - - //---------------------------------------------------------------------- - public static function binarize($frame) - { - $len = count($frame); - foreach ($frame as &$frameLine) { - - for($i=0; $i<$len; $i++) { - $frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0'; - } - } - - return $frame; - } - - //---------------------------------------------------------------------- - public static function tcpdfBarcodeArray($code, $mode = 'QR,L', $tcPdfVersion = '4.5.037') - { - $barcode_array = array(); - - if (!is_array($mode)) - $mode = explode(',', $mode); - - $eccLevel = 'L'; - - if (count($mode) > 1) { - $eccLevel = $mode[1]; - } - - $qrTab = QRcode::text($code, false, $eccLevel); - $size = count($qrTab); - - $barcode_array['num_rows'] = $size; - $barcode_array['num_cols'] = $size; - $barcode_array['bcode'] = array(); - - foreach ($qrTab as $line) { - $arrAdd = array(); - foreach(str_split($line) as $char) - $arrAdd[] = ($char=='1')?1:0; - $barcode_array['bcode'][] = $arrAdd; - } - - return $barcode_array; - } - - //---------------------------------------------------------------------- - public static function clearCache() - { - self::$frames = array(); - } - - //---------------------------------------------------------------------- - public static function buildCache() - { - QRtools::markTime('before_build_cache'); - - $mask = new QRmask(); - for ($a=1; $a <= QRSPEC_VERSION_MAX; $a++) { - $frame = QRspec::newFrame($a); - if (QR_IMAGE) { - $fileName = QR_CACHE_DIR.'frame_'.$a.'.png'; - QRimage::png(self::binarize($frame), $fileName, 1, 0); - } - - $width = count($frame); - $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); - for ($maskNo=0; $maskNo<8; $maskNo++) - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); - } - - QRtools::markTime('after_build_cache'); - } - - //---------------------------------------------------------------------- - public static function log($outfile, $err) - { - if (QR_LOG_DIR !== false) { - if ($err != '') { - if ($outfile !== false) { - file_put_contents(QR_LOG_DIR.basename($outfile).'-errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND); - } else { - file_put_contents(QR_LOG_DIR.'errors.txt', date('Y-m-d H:i:s').': '.$err, FILE_APPEND); - } - } - } - } - - //---------------------------------------------------------------------- - public static function dumpMask($frame) - { - $width = count($frame); - for($y=0;$y<$width;$y++) { - for($x=0;$x<$width;$x++) { - echo ord($frame[$y][$x]).','; - } - } - } - - //---------------------------------------------------------------------- - public static function markTime($markerId) - { - list($usec, $sec) = explode(" ", microtime()); - $time = ((float)$usec + (float)$sec); - - if (!isset($GLOBALS['qr_time_bench'])) - $GLOBALS['qr_time_bench'] = array(); - - $GLOBALS['qr_time_bench'][$markerId] = $time; - } - - //---------------------------------------------------------------------- - public static function timeBenchmark() - { - self::markTime('finish'); - - $lastTime = 0; - $startTime = 0; - $p = 0; - - echo ' - - '; - - foreach($GLOBALS['qr_time_bench'] as $markerId=>$thisTime) { - if ($p > 0) { - echo ''; - } else { - $startTime = $thisTime; - } - - $p++; - $lastTime = $thisTime; - } - - echo ' - - -
BENCHMARK
till '.$markerId.': '.number_format($thisTime-$lastTime, 6).'s
TOTAL: '.number_format($lastTime-$startTime, 6).'s
'; - } - - } - - //########################################################################## - - QRtools::markTime('start'); - - - - -//---- qrspec.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * QR Code specifications - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * The following data / specifications are taken from - * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) - * or - * "Automatic identification and data capture techniques -- - * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - define('QRSPEC_VERSION_MAX', 40); - define('QRSPEC_WIDTH_MAX', 177); - - define('QRCAP_WIDTH', 0); - define('QRCAP_WORDS', 1); - define('QRCAP_REMINDER', 2); - define('QRCAP_EC', 3); - - class QRspec { - - public static $capacity = array( - array( 0, 0, 0, array( 0, 0, 0, 0)), - array( 21, 26, 0, array( 7, 10, 13, 17)), // 1 - array( 25, 44, 7, array( 10, 16, 22, 28)), - array( 29, 70, 7, array( 15, 26, 36, 44)), - array( 33, 100, 7, array( 20, 36, 52, 64)), - array( 37, 134, 7, array( 26, 48, 72, 88)), // 5 - array( 41, 172, 7, array( 36, 64, 96, 112)), - array( 45, 196, 0, array( 40, 72, 108, 130)), - array( 49, 242, 0, array( 48, 88, 132, 156)), - array( 53, 292, 0, array( 60, 110, 160, 192)), - array( 57, 346, 0, array( 72, 130, 192, 224)), //10 - array( 61, 404, 0, array( 80, 150, 224, 264)), - array( 65, 466, 0, array( 96, 176, 260, 308)), - array( 69, 532, 0, array( 104, 198, 288, 352)), - array( 73, 581, 3, array( 120, 216, 320, 384)), - array( 77, 655, 3, array( 132, 240, 360, 432)), //15 - array( 81, 733, 3, array( 144, 280, 408, 480)), - array( 85, 815, 3, array( 168, 308, 448, 532)), - array( 89, 901, 3, array( 180, 338, 504, 588)), - array( 93, 991, 3, array( 196, 364, 546, 650)), - array( 97, 1085, 3, array( 224, 416, 600, 700)), //20 - array(101, 1156, 4, array( 224, 442, 644, 750)), - array(105, 1258, 4, array( 252, 476, 690, 816)), - array(109, 1364, 4, array( 270, 504, 750, 900)), - array(113, 1474, 4, array( 300, 560, 810, 960)), - array(117, 1588, 4, array( 312, 588, 870, 1050)), //25 - array(121, 1706, 4, array( 336, 644, 952, 1110)), - array(125, 1828, 4, array( 360, 700, 1020, 1200)), - array(129, 1921, 3, array( 390, 728, 1050, 1260)), - array(133, 2051, 3, array( 420, 784, 1140, 1350)), - array(137, 2185, 3, array( 450, 812, 1200, 1440)), //30 - array(141, 2323, 3, array( 480, 868, 1290, 1530)), - array(145, 2465, 3, array( 510, 924, 1350, 1620)), - array(149, 2611, 3, array( 540, 980, 1440, 1710)), - array(153, 2761, 3, array( 570, 1036, 1530, 1800)), - array(157, 2876, 0, array( 570, 1064, 1590, 1890)), //35 - array(161, 3034, 0, array( 600, 1120, 1680, 1980)), - array(165, 3196, 0, array( 630, 1204, 1770, 2100)), - array(169, 3362, 0, array( 660, 1260, 1860, 2220)), - array(173, 3532, 0, array( 720, 1316, 1950, 2310)), - array(177, 3706, 0, array( 750, 1372, 2040, 2430)) //40 - ); - - //---------------------------------------------------------------------- - public static function getDataLength($version, $level) - { - return self::$capacity[$version][QRCAP_WORDS] - self::$capacity[$version][QRCAP_EC][$level]; - } - - //---------------------------------------------------------------------- - public static function getECCLength($version, $level) - { - return self::$capacity[$version][QRCAP_EC][$level]; - } - - //---------------------------------------------------------------------- - public static function getWidth($version) - { - return self::$capacity[$version][QRCAP_WIDTH]; - } - - //---------------------------------------------------------------------- - public static function getRemainder($version) - { - return self::$capacity[$version][QRCAP_REMINDER]; - } - - //---------------------------------------------------------------------- - public static function getMinimumVersion($size, $level) - { - - for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) { - $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; - if($words >= $size) - return $i; - } - - return -1; - } - - //###################################################################### - - public static $lengthTableBits = array( - array(10, 12, 14), - array( 9, 11, 13), - array( 8, 16, 16), - array( 8, 10, 12) - ); - - //---------------------------------------------------------------------- - public static function lengthIndicator($mode, $version) - { - if ($mode == QR_MODE_STRUCTURE) - return 0; - - if ($version <= 9) { - $l = 0; - } else if ($version <= 26) { - $l = 1; - } else { - $l = 2; - } - - return self::$lengthTableBits[$mode][$l]; - } - - //---------------------------------------------------------------------- - public static function maximumWords($mode, $version) - { - if($mode == QR_MODE_STRUCTURE) - return 3; - - if($version <= 9) { - $l = 0; - } else if($version <= 26) { - $l = 1; - } else { - $l = 2; - } - - $bits = self::$lengthTableBits[$mode][$l]; - $words = (1 << $bits) - 1; - - if($mode == QR_MODE_KANJI) { - $words *= 2; // the number of bytes is required - } - - return $words; - } - - // Error correction code ----------------------------------------------- - // Table of the error correction code (Reed-Solomon block) - // See Table 12-16 (pp.30-36), JIS X0510:2004. - - public static $eccTable = array( - array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1 - array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), - array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), - array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), - array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5 - array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), - array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), - array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), - array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), - array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), //10 - array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), - array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), - array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), - array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), - array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), //15 - array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), - array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), - array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), - array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), - array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), //20 - array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), - array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), - array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), - array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), - array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), //25 - array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), - array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), - array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), - array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), - array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), //30 - array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), - array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), - array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), - array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), - array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), //35 - array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), - array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), - array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), - array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), - array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)),//40 - ); - - //---------------------------------------------------------------------- - // CACHEABLE!!! - - public static function getEccSpec($version, $level, array &$spec) - { - if (count($spec) < 5) { - $spec = array(0,0,0,0,0); - } - - $b1 = self::$eccTable[$version][$level][0]; - $b2 = self::$eccTable[$version][$level][1]; - $data = self::getDataLength($version, $level); - $ecc = self::getECCLength($version, $level); - - if($b2 == 0) { - $spec[0] = $b1; - $spec[1] = (int)($data / $b1); - $spec[2] = (int)($ecc / $b1); - $spec[3] = 0; - $spec[4] = 0; - } else { - $spec[0] = $b1; - $spec[1] = (int)($data / ($b1 + $b2)); - $spec[2] = (int)($ecc / ($b1 + $b2)); - $spec[3] = $b2; - $spec[4] = $spec[1] + 1; - } - } - - // Alignment pattern --------------------------------------------------- - - // Positions of alignment patterns. - // This array includes only the second and the third position of the - // alignment patterns. Rest of them can be calculated from the distance - // between them. - - // See Table 1 in Appendix E (pp.71) of JIS X0510:2004. - - public static $alignmentPattern = array( - array( 0, 0), - array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5 - array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10 - array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), //11-15 - array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), //16-20 - array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), //21-25 - array(30, 58), array(34, 62), array(26, 50), array(30, 54), array(26, 52), //26-30 - array(30, 56), array(34, 60), array(30, 58), array(34, 62), array(30, 54), //31-35 - array(24, 50), array(28, 54), array(32, 58), array(26, 54), array(30, 58), //35-40 - ); - - - /** -------------------------------------------------------------------- - * Put an alignment marker. - * @param frame - * @param width - * @param ox,oy center coordinate of the pattern - */ - public static function putAlignmentMarker(array &$frame, $ox, $oy) - { - $finder = array( - "\xa1\xa1\xa1\xa1\xa1", - "\xa1\xa0\xa0\xa0\xa1", - "\xa1\xa0\xa1\xa0\xa1", - "\xa1\xa0\xa0\xa0\xa1", - "\xa1\xa1\xa1\xa1\xa1" - ); - - $yStart = $oy-2; - $xStart = $ox-2; - - for($y=0; $y<5; $y++) { - QRstr::set($frame, $xStart, $yStart+$y, $finder[$y]); - } - } - - //---------------------------------------------------------------------- - public static function putAlignmentPattern($version, &$frame, $width) - { - if($version < 2) - return; - - $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; - if($d < 0) { - $w = 2; - } else { - $w = (int)(($width - self::$alignmentPattern[$version][0]) / $d + 2); - } - - if($w * $w - 3 == 1) { - $x = self::$alignmentPattern[$version][0]; - $y = self::$alignmentPattern[$version][0]; - self::putAlignmentMarker($frame, $x, $y); - return; - } - - $cx = self::$alignmentPattern[$version][0]; - for($x=1; $x<$w - 1; $x++) { - self::putAlignmentMarker($frame, 6, $cx); - self::putAlignmentMarker($frame, $cx, 6); - $cx += $d; - } - - $cy = self::$alignmentPattern[$version][0]; - for($y=0; $y<$w-1; $y++) { - $cx = self::$alignmentPattern[$version][0]; - for($x=0; $x<$w-1; $x++) { - self::putAlignmentMarker($frame, $cx, $cy); - $cx += $d; - } - $cy += $d; - } - } - - // Version information pattern ----------------------------------------- - - // Version information pattern (BCH coded). - // See Table 1 in Appendix D (pp.68) of JIS X0510:2004. - - // size: [QRSPEC_VERSION_MAX - 6] - - public static $versionPattern = array( - 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, - 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, - 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, - 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, - 0x27541, 0x28c69 - ); - - //---------------------------------------------------------------------- - public static function getVersionPattern($version) - { - if($version < 7 || $version > QRSPEC_VERSION_MAX) - return 0; - - return self::$versionPattern[$version -7]; - } - - // Format information -------------------------------------------------- - // See calcFormatInfo in tests/test_qrspec.c (orginal qrencode c lib) - - public static $formatInfo = array( - array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976), - array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0), - array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed), - array(0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b) - ); - - public static function getFormatInfo($mask, $level) - { - if($mask < 0 || $mask > 7) - return 0; - - if($level < 0 || $level > 3) - return 0; - - return self::$formatInfo[$level][$mask]; - } - - // Frame --------------------------------------------------------------- - // Cache of initial frames. - - public static $frames = array(); - - /** -------------------------------------------------------------------- - * Put a finder pattern. - * @param frame - * @param width - * @param ox,oy upper-left coordinate of the pattern - */ - public static function putFinderPattern(&$frame, $ox, $oy) - { - $finder = array( - "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", - "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", - "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", - "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" - ); - - for($y=0; $y<7; $y++) { - QRstr::set($frame, $ox, $oy+$y, $finder[$y]); - } - } - - //---------------------------------------------------------------------- - public static function createFrame($version) - { - $width = self::$capacity[$version][QRCAP_WIDTH]; - $frameLine = str_repeat ("\0", $width); - $frame = array_fill(0, $width, $frameLine); - - // Finder pattern - self::putFinderPattern($frame, 0, 0); - self::putFinderPattern($frame, $width - 7, 0); - self::putFinderPattern($frame, 0, $width - 7); - - // Separator - $yOffset = $width - 7; - - for($y=0; $y<7; $y++) { - $frame[$y][7] = "\xc0"; - $frame[$y][$width - 8] = "\xc0"; - $frame[$yOffset][7] = "\xc0"; - $yOffset++; - } - - $setPattern = str_repeat("\xc0", 8); - - QRstr::set($frame, 0, 7, $setPattern); - QRstr::set($frame, $width-8, 7, $setPattern); - QRstr::set($frame, 0, $width - 8, $setPattern); - - // Format info - $setPattern = str_repeat("\x84", 9); - QRstr::set($frame, 0, 8, $setPattern); - QRstr::set($frame, $width - 8, 8, $setPattern, 8); - - $yOffset = $width - 8; - - for($y=0; $y<8; $y++,$yOffset++) { - $frame[$y][8] = "\x84"; - $frame[$yOffset][8] = "\x84"; - } - - // Timing pattern - - for($i=1; $i<$width-15; $i++) { - $frame[6][7+$i] = chr(0x90 | ($i & 1)); - $frame[7+$i][6] = chr(0x90 | ($i & 1)); - } - - // Alignment pattern - self::putAlignmentPattern($version, $frame, $width); - - // Version information - if($version >= 7) { - $vinf = self::getVersionPattern($version); - - $v = $vinf; - - for($x=0; $x<6; $x++) { - for($y=0; $y<3; $y++) { - $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1)); - $v = $v >> 1; - } - } - - $v = $vinf; - for($y=0; $y<6; $y++) { - for($x=0; $x<3; $x++) { - $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1)); - $v = $v >> 1; - } - } - } - - // and a little bit... - $frame[$width - 8][8] = "\x81"; - - return $frame; - } - - //---------------------------------------------------------------------- - public static function debug($frame, $binary_mode = false) - { - if ($binary_mode) { - - foreach ($frame as &$frameLine) { - $frameLine = join('  ', explode('0', $frameLine)); - $frameLine = join('██', explode('1', $frameLine)); - } - - ?> - -


        '; - echo join("
        ", $frame); - echo '






'; - - } else { - - foreach ($frame as &$frameLine) { - $frameLine = join(' ', explode("\xc0", $frameLine)); - $frameLine = join('', explode("\xc1", $frameLine)); - $frameLine = join(' ', explode("\xa0", $frameLine)); - $frameLine = join('', explode("\xa1", $frameLine)); - $frameLine = join('', explode("\x84", $frameLine)); //format 0 - $frameLine = join('', explode("\x85", $frameLine)); //format 1 - $frameLine = join('', explode("\x81", $frameLine)); //special bit - $frameLine = join(' ', explode("\x90", $frameLine)); //clock 0 - $frameLine = join('', explode("\x91", $frameLine)); //clock 1 - $frameLine = join(' ', explode("\x88", $frameLine)); //version - $frameLine = join('', explode("\x89", $frameLine)); //version - $frameLine = join('♦', explode("\x01", $frameLine)); - $frameLine = join('⋅', explode("\0", $frameLine)); - } - - ?> - - "; - echo join("
", $frame); - echo "
"; - - } - } - - //---------------------------------------------------------------------- - public static function serial($frame) - { - return gzcompress(join("\n", $frame), 9); - } - - //---------------------------------------------------------------------- - public static function unserial($code) - { - return explode("\n", gzuncompress($code)); - } - - //---------------------------------------------------------------------- - public static function newFrame($version) - { - if($version < 1 || $version > QRSPEC_VERSION_MAX) - return null; - - if(!isset(self::$frames[$version])) { - - $fileName = QR_CACHE_DIR.'frame_'.$version.'.dat'; - - if (QR_CACHEABLE) { - if (file_exists($fileName)) { - self::$frames[$version] = self::unserial(file_get_contents($fileName)); - } else { - self::$frames[$version] = self::createFrame($version); - file_put_contents($fileName, self::serial(self::$frames[$version])); - } - } else { - self::$frames[$version] = self::createFrame($version); - } - } - - if(is_null(self::$frames[$version])) - return null; - - return self::$frames[$version]; - } - - //---------------------------------------------------------------------- - public static function rsBlockNum($spec) { return $spec[0] + $spec[3]; } - public static function rsBlockNum1($spec) { return $spec[0]; } - public static function rsDataCodes1($spec) { return $spec[1]; } - public static function rsEccCodes1($spec) { return $spec[2]; } - public static function rsBlockNum2($spec) { return $spec[3]; } - public static function rsDataCodes2($spec) { return $spec[4]; } - public static function rsEccCodes2($spec) { return $spec[2]; } - public static function rsDataLength($spec) { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); } - public static function rsEccLength($spec) { return ($spec[0] + $spec[3]) * $spec[2]; } - - } - - - -//---- qrimage.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Image output of code using GD2 - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - define('QR_IMAGE', true); - - class QRimage { - - //---------------------------------------------------------------------- - public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE) - { - $image = self::image($frame, $pixelPerPoint, $outerFrame); - - if ($filename === false) { - Header("Content-type: image/png"); - ImagePng($image); - } else { - if($saveandprint===TRUE){ - ImagePng($image, $filename); - header("Content-type: image/png"); - ImagePng($image); - }else{ - ImagePng($image, $filename); - } - } - - ImageDestroy($image); - } - - //---------------------------------------------------------------------- - public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85) - { - $image = self::image($frame, $pixelPerPoint, $outerFrame); - - if ($filename === false) { - Header("Content-type: image/jpeg"); - ImageJpeg($image, null, $q); - } else { - ImageJpeg($image, $filename, $q); - } - - ImageDestroy($image); - } - - //---------------------------------------------------------------------- - private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4) - { - $h = count($frame); - $w = strlen($frame[0]); - - $imgW = $w + 2*$outerFrame; - $imgH = $h + 2*$outerFrame; - - $base_image =ImageCreate($imgW, $imgH); - - $col[0] = ImageColorAllocate($base_image,255,255,255); - $col[1] = ImageColorAllocate($base_image,0,0,0); - - imagefill($base_image, 0, 0, $col[0]); - - for($y=0; $y<$h; $y++) { - for($x=0; $x<$w; $x++) { - if ($frame[$y][$x] == '1') { - ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]); - } - } - } - - $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); - ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); - ImageDestroy($base_image); - - return $target_image; - } - } - - - -//---- qrinput.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Input encoding class - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - define('STRUCTURE_HEADER_BITS', 20); - define('MAX_STRUCTURED_SYMBOLS', 16); - - class QRinputItem { - - public $mode; - public $size; - public $data; - public $bstream; - - public function __construct($mode, $size, $data, $bstream = null) - { - $setData = array_slice($data, 0, $size); - - if (count($setData) < $size) { - $setData = array_merge($setData, array_fill(0,$size-count($setData),0)); - } - - if(!QRinput::check($mode, $size, $setData)) { - throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData)); - return null; - } - - $this->mode = $mode; - $this->size = $size; - $this->data = $setData; - $this->bstream = $bstream; - } - - //---------------------------------------------------------------------- - public function encodeModeNum($version) - { - try { - - $words = (int)($this->size / 3); - $bs = new QRbitstream(); - - $val = 0x1; - $bs->appendNum(4, $val); - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size); - - for($i=0; $i<$words; $i++) { - $val = (ord($this->data[$i*3 ]) - ord('0')) * 100; - $val += (ord($this->data[$i*3+1]) - ord('0')) * 10; - $val += (ord($this->data[$i*3+2]) - ord('0')); - $bs->appendNum(10, $val); - } - - if($this->size - $words * 3 == 1) { - $val = ord($this->data[$words*3]) - ord('0'); - $bs->appendNum(4, $val); - } else if($this->size - $words * 3 == 2) { - $val = (ord($this->data[$words*3 ]) - ord('0')) * 10; - $val += (ord($this->data[$words*3+1]) - ord('0')); - $bs->appendNum(7, $val); - } - - $this->bstream = $bs; - return 0; - - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function encodeModeAn($version) - { - try { - $words = (int)($this->size / 2); - $bs = new QRbitstream(); - - $bs->appendNum(4, 0x02); - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size); - - for($i=0; $i<$words; $i++) { - $val = (int)QRinput::lookAnTable(ord($this->data[$i*2 ])) * 45; - $val += (int)QRinput::lookAnTable(ord($this->data[$i*2+1])); - - $bs->appendNum(11, $val); - } - - if($this->size & 1) { - $val = QRinput::lookAnTable(ord($this->data[$words * 2])); - $bs->appendNum(6, $val); - } - - $this->bstream = $bs; - return 0; - - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function encodeMode8($version) - { - try { - $bs = new QRbitstream(); - - $bs->appendNum(4, 0x4); - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size); - - for($i=0; $i<$this->size; $i++) { - $bs->appendNum(8, ord($this->data[$i])); - } - - $this->bstream = $bs; - return 0; - - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function encodeModeKanji($version) - { - try { - - $bs = new QRbitrtream(); - - $bs->appendNum(4, 0x8); - $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2)); - - for($i=0; $i<$this->size; $i+=2) { - $val = (ord($this->data[$i]) << 8) | ord($this->data[$i+1]); - if($val <= 0x9ffc) { - $val -= 0x8140; - } else { - $val -= 0xc140; - } - - $h = ($val >> 8) * 0xc0; - $val = ($val & 0xff) + $h; - - $bs->appendNum(13, $val); - } - - $this->bstream = $bs; - return 0; - - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function encodeModeStructure() - { - try { - $bs = new QRbitstream(); - - $bs->appendNum(4, 0x03); - $bs->appendNum(4, ord($this->data[1]) - 1); - $bs->appendNum(4, ord($this->data[0]) - 1); - $bs->appendNum(8, ord($this->data[2])); - - $this->bstream = $bs; - return 0; - - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function estimateBitStreamSizeOfEntry($version) - { - $bits = 0; - - if($version == 0) - $version = 1; - - switch($this->mode) { - case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; - case QR_MODE_AN: $bits = QRinput::estimateBitsModeAn($this->size); break; - case QR_MODE_8: $bits = QRinput::estimateBitsMode8($this->size); break; - case QR_MODE_KANJI: $bits = QRinput::estimateBitsModeKanji($this->size);break; - case QR_MODE_STRUCTURE: return STRUCTURE_HEADER_BITS; - default: - return 0; - } - - $l = QRspec::lengthIndicator($this->mode, $version); - $m = 1 << $l; - $num = (int)(($this->size + $m - 1) / $m); - - $bits += $num * (4 + $l); - - return $bits; - } - - //---------------------------------------------------------------------- - public function encodeBitStream($version) - { - try { - - unset($this->bstream); - $words = QRspec::maximumWords($this->mode, $version); - - if($this->size > $words) { - - $st1 = new QRinputItem($this->mode, $words, $this->data); - $st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words)); - - $st1->encodeBitStream($version); - $st2->encodeBitStream($version); - - $this->bstream = new QRbitstream(); - $this->bstream->append($st1->bstream); - $this->bstream->append($st2->bstream); - - unset($st1); - unset($st2); - - } else { - - $ret = 0; - - switch($this->mode) { - case QR_MODE_NUM: $ret = $this->encodeModeNum($version); break; - case QR_MODE_AN: $ret = $this->encodeModeAn($version); break; - case QR_MODE_8: $ret = $this->encodeMode8($version); break; - case QR_MODE_KANJI: $ret = $this->encodeModeKanji($version);break; - case QR_MODE_STRUCTURE: $ret = $this->encodeModeStructure(); break; - - default: - break; - } - - if($ret < 0) - return -1; - } - - return $this->bstream->size(); - - } catch (Exception $e) { - return -1; - } - } - }; - - //########################################################################## - - class QRinput { - - public $items; - - private $version; - private $level; - - //---------------------------------------------------------------------- - public function __construct($version = 0, $level = QR_ECLEVEL_L) - { - if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) { - throw new Exception('Invalid version no'); - return NULL; - } - - $this->version = $version; - $this->level = $level; - } - - //---------------------------------------------------------------------- - public function getVersion() - { - return $this->version; - } - - //---------------------------------------------------------------------- - public function setVersion($version) - { - if($version < 0 || $version > QRSPEC_VERSION_MAX) { - throw new Exception('Invalid version no'); - return -1; - } - - $this->version = $version; - - return 0; - } - - //---------------------------------------------------------------------- - public function getErrorCorrectionLevel() - { - return $this->level; - } - - //---------------------------------------------------------------------- - public function setErrorCorrectionLevel($level) - { - if($level > QR_ECLEVEL_H) { - throw new Exception('Invalid ECLEVEL'); - return -1; - } - - $this->level = $level; - - return 0; - } - - //---------------------------------------------------------------------- - public function appendEntry(QRinputItem $entry) - { - $this->items[] = $entry; - } - - //---------------------------------------------------------------------- - public function append($mode, $size, $data) - { - try { - $entry = new QRinputItem($mode, $size, $data); - $this->items[] = $entry; - return 0; - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - - public function insertStructuredAppendHeader($size, $index, $parity) - { - if( $size > MAX_STRUCTURED_SYMBOLS ) { - throw new Exception('insertStructuredAppendHeader wrong size'); - } - - if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) { - throw new Exception('insertStructuredAppendHeader wrong index'); - } - - $buf = array($size, $index, $parity); - - try { - $entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf); - array_unshift($this->items, $entry); - return 0; - } catch (Exception $e) { - return -1; - } - } - - //---------------------------------------------------------------------- - public function calcParity() - { - $parity = 0; - - foreach($this->items as $item) { - if($item->mode != QR_MODE_STRUCTURE) { - for($i=$item->size-1; $i>=0; $i--) { - $parity ^= $item->data[$i]; - } - } - } - - return $parity; - } - - //---------------------------------------------------------------------- - public static function checkModeNum($size, $data) - { - for($i=0; $i<$size; $i++) { - if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){ - return false; - } - } - - return true; - } - - //---------------------------------------------------------------------- - public static function estimateBitsModeNum($size) - { - $w = (int)$size / 3; - $bits = $w * 10; - - switch($size - $w * 3) { - case 1: - $bits += 4; - break; - case 2: - $bits += 7; - break; - default: - break; - } - - return $bits; - } - - //---------------------------------------------------------------------- - public static $anTable = array( - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 - ); - - //---------------------------------------------------------------------- - public static function lookAnTable($c) - { - return (($c > 127)?-1:self::$anTable[$c]); - } - - //---------------------------------------------------------------------- - public static function checkModeAn($size, $data) - { - for($i=0; $i<$size; $i++) { - if (self::lookAnTable(ord($data[$i])) == -1) { - return false; - } - } - - return true; - } - - //---------------------------------------------------------------------- - public static function estimateBitsModeAn($size) - { - $w = (int)($size / 2); - $bits = $w * 11; - - if($size & 1) { - $bits += 6; - } - - return $bits; - } - - //---------------------------------------------------------------------- - public static function estimateBitsMode8($size) - { - return $size * 8; - } - - //---------------------------------------------------------------------- - public function estimateBitsModeKanji($size) - { - return (int)(($size / 2) * 13); - } - - //---------------------------------------------------------------------- - public static function checkModeKanji($size, $data) - { - if($size & 1) - return false; - - for($i=0; $i<$size; $i+=2) { - $val = (ord($data[$i]) << 8) | ord($data[$i+1]); - if( $val < 0x8140 - || ($val > 0x9ffc && $val < 0xe040) - || $val > 0xebbf) { - return false; - } - } - - return true; - } - - /*********************************************************************** - * Validation - **********************************************************************/ - - public static function check($mode, $size, $data) - { - if($size <= 0) - return false; - - switch($mode) { - case QR_MODE_NUM: return self::checkModeNum($size, $data); break; - case QR_MODE_AN: return self::checkModeAn($size, $data); break; - case QR_MODE_KANJI: return self::checkModeKanji($size, $data); break; - case QR_MODE_8: return true; break; - case QR_MODE_STRUCTURE: return true; break; - - default: - break; - } - - return false; - } - - - //---------------------------------------------------------------------- - public function estimateBitStreamSize($version) - { - $bits = 0; - - foreach($this->items as $item) { - $bits += $item->estimateBitStreamSizeOfEntry($version); - } - - return $bits; - } - - //---------------------------------------------------------------------- - public function estimateVersion() - { - $version = 0; - $prev = 0; - do { - $prev = $version; - $bits = $this->estimateBitStreamSize($prev); - $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); - if ($version < 0) { - return -1; - } - } while ($version > $prev); - - return $version; - } - - //---------------------------------------------------------------------- - public static function lengthOfCode($mode, $version, $bits) - { - $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version); - switch($mode) { - case QR_MODE_NUM: - $chunks = (int)($payload / 10); - $remain = $payload - $chunks * 10; - $size = $chunks * 3; - if($remain >= 7) { - $size += 2; - } else if($remain >= 4) { - $size += 1; - } - break; - case QR_MODE_AN: - $chunks = (int)($payload / 11); - $remain = $payload - $chunks * 11; - $size = $chunks * 2; - if($remain >= 6) - $size++; - break; - case QR_MODE_8: - $size = (int)($payload / 8); - break; - case QR_MODE_KANJI: - $size = (int)(($payload / 13) * 2); - break; - case QR_MODE_STRUCTURE: - $size = (int)($payload / 8); - break; - default: - $size = 0; - break; - } - - $maxsize = QRspec::maximumWords($mode, $version); - if($size < 0) $size = 0; - if($size > $maxsize) $size = $maxsize; - - return $size; - } - - //---------------------------------------------------------------------- - public function createBitStream() - { - $total = 0; - - foreach($this->items as $item) { - $bits = $item->encodeBitStream($this->version); - - if($bits < 0) - return -1; - - $total += $bits; - } - - return $total; - } - - //---------------------------------------------------------------------- - public function convertData() - { - $ver = $this->estimateVersion(); - if($ver > $this->getVersion()) { - $this->setVersion($ver); - } - - for(;;) { - $bits = $this->createBitStream(); - - if($bits < 0) - return -1; - - $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); - if($ver < 0) { - throw new Exception('WRONG VERSION'); - return -1; - } else if($ver > $this->getVersion()) { - $this->setVersion($ver); - } else { - break; - } - } - - return 0; - } - - //---------------------------------------------------------------------- - public function appendPaddingBit(&$bstream) - { - $bits = $bstream->size(); - $maxwords = QRspec::getDataLength($this->version, $this->level); - $maxbits = $maxwords * 8; - - if ($maxbits == $bits) { - return 0; - } - - if ($maxbits - $bits < 5) { - return $bstream->appendNum($maxbits - $bits, 0); - } - - $bits += 4; - $words = (int)(($bits + 7) / 8); - - $padding = new QRbitstream(); - $ret = $padding->appendNum($words * 8 - $bits + 4, 0); - - if($ret < 0) - return $ret; - - $padlen = $maxwords - $words; - - if($padlen > 0) { - - $padbuf = array(); - for($i=0; $i<$padlen; $i++) { - $padbuf[$i] = ($i&1)?0x11:0xec; - } - - $ret = $padding->appendBytes($padlen, $padbuf); - - if($ret < 0) - return $ret; - - } - - $ret = $bstream->append($padding); - - return $ret; - } - - //---------------------------------------------------------------------- - public function mergeBitStream() - { - if($this->convertData() < 0) { - return null; - } - - $bstream = new QRbitstream(); - - foreach($this->items as $item) { - $ret = $bstream->append($item->bstream); - if($ret < 0) { - return null; - } - } - - return $bstream; - } - - //---------------------------------------------------------------------- - public function getBitStream() - { - - $bstream = $this->mergeBitStream(); - - if($bstream == null) { - return null; - } - - $ret = $this->appendPaddingBit($bstream); - if($ret < 0) { - return null; - } - - return $bstream; - } - - //---------------------------------------------------------------------- - public function getByteStream() - { - $bstream = $this->getBitStream(); - if($bstream == null) { - return null; - } - - return $bstream->toByte(); - } - } - - - - - - -//---- qrbitstream.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Bitstream class - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - class QRbitstream { - - public $data = array(); - - //---------------------------------------------------------------------- - public function size() - { - return count($this->data); - } - - //---------------------------------------------------------------------- - public function allocate($setLength) - { - $this->data = array_fill(0, $setLength, 0); - return 0; - } - - //---------------------------------------------------------------------- - public static function newFromNum($bits, $num) - { - $bstream = new QRbitstream(); - $bstream->allocate($bits); - - $mask = 1 << ($bits - 1); - for($i=0; $i<$bits; $i++) { - if($num & $mask) { - $bstream->data[$i] = 1; - } else { - $bstream->data[$i] = 0; - } - $mask = $mask >> 1; - } - - return $bstream; - } - - //---------------------------------------------------------------------- - public static function newFromBytes($size, $data) - { - $bstream = new QRbitstream(); - $bstream->allocate($size * 8); - $p=0; - - for($i=0; $i<$size; $i++) { - $mask = 0x80; - for($j=0; $j<8; $j++) { - if($data[$i] & $mask) { - $bstream->data[$p] = 1; - } else { - $bstream->data[$p] = 0; - } - $p++; - $mask = $mask >> 1; - } - } - - return $bstream; - } - - //---------------------------------------------------------------------- - public function append(QRbitstream $arg) - { - if (is_null($arg)) { - return -1; - } - - if($arg->size() == 0) { - return 0; - } - - if($this->size() == 0) { - $this->data = $arg->data; - return 0; - } - - $this->data = array_values(array_merge($this->data, $arg->data)); - - return 0; - } - - //---------------------------------------------------------------------- - public function appendNum($bits, $num) - { - if ($bits == 0) - return 0; - - $b = QRbitstream::newFromNum($bits, $num); - - if(is_null($b)) - return -1; - - $ret = $this->append($b); - unset($b); - - return $ret; - } - - //---------------------------------------------------------------------- - public function appendBytes($size, $data) - { - if ($size == 0) - return 0; - - $b = QRbitstream::newFromBytes($size, $data); - - if(is_null($b)) - return -1; - - $ret = $this->append($b); - unset($b); - - return $ret; - } - - //---------------------------------------------------------------------- - public function toByte() - { - - $size = $this->size(); - - if($size == 0) { - return array(); - } - - $data = array_fill(0, (int)(($size + 7) / 8), 0); - $bytes = (int)($size / 8); - - $p = 0; - - for($i=0; $i<$bytes; $i++) { - $v = 0; - for($j=0; $j<8; $j++) { - $v = $v << 1; - $v |= $this->data[$p]; - $p++; - } - $data[$i] = $v; - } - - if($size & 7) { - $v = 0; - for($j=0; $j<($size & 7); $j++) { - $v = $v << 1; - $v |= $this->data[$p]; - $p++; - } - $data[$bytes] = $v; - } - - return $data; - } - - } - - - - -//---- qrsplit.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Input splitting classes - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * The following data / specifications are taken from - * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) - * or - * "Automatic identification and data capture techniques -- - * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - class QRsplit { - - public $dataStr = ''; - public $input; - public $modeHint; - - //---------------------------------------------------------------------- - public function __construct($dataStr, $input, $modeHint) - { - $this->dataStr = $dataStr; - $this->input = $input; - $this->modeHint = $modeHint; - } - - //---------------------------------------------------------------------- - public static function isdigitat($str, $pos) - { - if ($pos >= strlen($str)) - return false; - - return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); - } - - //---------------------------------------------------------------------- - public static function isalnumat($str, $pos) - { - if ($pos >= strlen($str)) - return false; - - return (QRinput::lookAnTable(ord($str[$pos])) >= 0); - } - - //---------------------------------------------------------------------- - public function identifyMode($pos) - { - if ($pos >= strlen($this->dataStr)) - return QR_MODE_NUL; - - $c = $this->dataStr[$pos]; - - if(self::isdigitat($this->dataStr, $pos)) { - return QR_MODE_NUM; - } else if(self::isalnumat($this->dataStr, $pos)) { - return QR_MODE_AN; - } else if($this->modeHint == QR_MODE_KANJI) { - - if ($pos+1 < strlen($this->dataStr)) - { - $d = $this->dataStr[$pos+1]; - $word = (ord($c) << 8) | ord($d); - if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) { - return QR_MODE_KANJI; - } - } - } - - return QR_MODE_8; - } - - //---------------------------------------------------------------------- - public function eatNum() - { - $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); - - $p = 0; - while(self::isdigitat($this->dataStr, $p)) { - $p++; - } - - $run = $p; - $mode = $this->identifyMode($p); - - if($mode == QR_MODE_8) { - $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln - + QRinput::estimateBitsMode8(1) // + 4 + l8 - - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 - if($dif > 0) { - return $this->eat8(); - } - } - if($mode == QR_MODE_AN) { - $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln - + QRinput::estimateBitsModeAn(1) // + 4 + la - - QRinput::estimateBitsModeAn($run + 1);// - 4 - la - if($dif > 0) { - return $this->eatAn(); - } - } - - $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); - if($ret < 0) - return -1; - - return $run; - } - - //---------------------------------------------------------------------- - public function eatAn() - { - $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion()); - $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); - - $p = 0; - - while(self::isalnumat($this->dataStr, $p)) { - if(self::isdigitat($this->dataStr, $p)) { - $q = $p; - while(self::isdigitat($this->dataStr, $q)) { - $q++; - } - - $dif = QRinput::estimateBitsModeAn($p) // + 4 + la - + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - - QRinput::estimateBitsModeAn($q); // - 4 - la - - if($dif < 0) { - break; - } else { - $p = $q; - } - } else { - $p++; - } - } - - $run = $p; - - if(!self::isalnumat($this->dataStr, $p)) { - $dif = QRinput::estimateBitsModeAn($run) + 4 + $la - + QRinput::estimateBitsMode8(1) // + 4 + l8 - - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 - if($dif > 0) { - return $this->eat8(); - } - } - - $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); - if($ret < 0) - return -1; - - return $run; - } - - //---------------------------------------------------------------------- - public function eatKanji() - { - $p = 0; - - while($this->identifyMode($p) == QR_MODE_KANJI) { - $p += 2; - } - - $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); - if($ret < 0) - return -1; - - return $run; - } - - //---------------------------------------------------------------------- - public function eat8() - { - $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion()); - $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); - - $p = 1; - $dataStrLen = strlen($this->dataStr); - - while($p < $dataStrLen) { - - $mode = $this->identifyMode($p); - if($mode == QR_MODE_KANJI) { - break; - } - if($mode == QR_MODE_NUM) { - $q = $p; - while(self::isdigitat($this->dataStr, $q)) { - $q++; - } - $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 - + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - - QRinput::estimateBitsMode8($q); // - 4 - l8 - if($dif < 0) { - break; - } else { - $p = $q; - } - } else if($mode == QR_MODE_AN) { - $q = $p; - while(self::isalnumat($this->dataStr, $q)) { - $q++; - } - $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 - + QRinput::estimateBitsModeAn($q - $p) + 4 + $la - - QRinput::estimateBitsMode8($q); // - 4 - l8 - if($dif < 0) { - break; - } else { - $p = $q; - } - } else { - $p++; - } - } - - $run = $p; - $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); - - if($ret < 0) - return -1; - - return $run; - } - - //---------------------------------------------------------------------- - public function splitString() - { - while (strlen($this->dataStr) > 0) - { - if($this->dataStr == '') - return 0; - - $mode = $this->identifyMode(0); - - switch ($mode) { - case QR_MODE_NUM: $length = $this->eatNum(); break; - case QR_MODE_AN: $length = $this->eatAn(); break; - case QR_MODE_KANJI: - if ($hint == QR_MODE_KANJI) - $length = $this->eatKanji(); - else $length = $this->eat8(); - break; - default: $length = $this->eat8(); break; - - } - - if($length == 0) return 0; - if($length < 0) return -1; - - $this->dataStr = substr($this->dataStr, $length); - } - } - - //---------------------------------------------------------------------- - public function toUpper() - { - $stringLen = strlen($this->dataStr); - $p = 0; - - while ($p<$stringLen) { - $mode = self::identifyMode(substr($this->dataStr, $p), $this->modeHint); - if($mode == QR_MODE_KANJI) { - $p += 2; - } else { - if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) { - $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32); - } - $p++; - } - } - - return $this->dataStr; - } - - //---------------------------------------------------------------------- - public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true) - { - if(is_null($string) || $string == '\0' || $string == '') { - throw new Exception('empty string!!!'); - } - - $split = new QRsplit($string, $input, $modeHint); - - if(!$casesensitive) - $split->toUpper(); - - return $split->splitString(); - } - } - - - -//---- qrrscode.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Reed-Solomon error correction support - * - * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q - * (libfec is released under the GNU Lesser General Public License.) - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - class QRrsItem { - - public $mm; // Bits per symbol - public $nn; // Symbols per block (= (1<= $this->nn) { - $x -= $this->nn; - $x = ($x >> $this->mm) + ($x & $this->nn); - } - - return $x; - } - - //---------------------------------------------------------------------- - public static function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) - { - // Common code for intializing a Reed-Solomon control block (char or int symbols) - // Copyright 2004 Phil Karn, KA9Q - // May be used under the terms of the GNU Lesser General Public License (LGPL) - - $rs = null; - - // Check parameter ranges - if($symsize < 0 || $symsize > 8) return $rs; - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding - - $rs = new QRrsItem(); - $rs->mm = $symsize; - $rs->nn = (1<<$symsize)-1; - $rs->pad = $pad; - - $rs->alpha_to = array_fill(0, $rs->nn+1, 0); - $rs->index_of = array_fill(0, $rs->nn+1, 0); - - // PHP style macro replacement ;) - $NN =& $rs->nn; - $A0 =& $NN; - - // Generate Galois field lookup tables - $rs->index_of[0] = $A0; // log(zero) = -inf - $rs->alpha_to[$A0] = 0; // alpha**-inf = 0 - $sr = 1; - - for($i=0; $i<$rs->nn; $i++) { - $rs->index_of[$sr] = $i; - $rs->alpha_to[$i] = $sr; - $sr <<= 1; - if($sr & (1<<$symsize)) { - $sr ^= $gfpoly; - } - $sr &= $rs->nn; - } - - if($sr != 1){ - // field generator polynomial is not primitive! - $rs = NULL; - return $rs; - } - - /* Form RS code generator polynomial from its roots */ - $rs->genpoly = array_fill(0, $nroots+1, 0); - - $rs->fcr = $fcr; - $rs->prim = $prim; - $rs->nroots = $nroots; - $rs->gfpoly = $gfpoly; - - /* Find prim-th root of 1, used in decoding */ - for($iprim=1;($iprim % $prim) != 0;$iprim += $rs->nn) - ; // intentional empty-body loop! - - $rs->iprim = (int)($iprim / $prim); - $rs->genpoly[0] = 1; - - for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) { - $rs->genpoly[$i+1] = 1; - - // Multiply rs->genpoly[] by @**(root + x) - for ($j = $i; $j > 0; $j--) { - if ($rs->genpoly[$j] != 0) { - $rs->genpoly[$j] = $rs->genpoly[$j-1] ^ $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[$j]] + $root)]; - } else { - $rs->genpoly[$j] = $rs->genpoly[$j-1]; - } - } - // rs->genpoly[0] can never be zero - $rs->genpoly[0] = $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[0]] + $root)]; - } - - // convert rs->genpoly[] to index form for quicker encoding - for ($i = 0; $i <= $nroots; $i++) - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; - - return $rs; - } - - //---------------------------------------------------------------------- - public function encode_rs_char($data, &$parity) - { - $MM =& $this->mm; - $NN =& $this->nn; - $ALPHA_TO =& $this->alpha_to; - $INDEX_OF =& $this->index_of; - $GENPOLY =& $this->genpoly; - $NROOTS =& $this->nroots; - $FCR =& $this->fcr; - $PRIM =& $this->prim; - $IPRIM =& $this->iprim; - $PAD =& $this->pad; - $A0 =& $NN; - - $parity = array_fill(0, $NROOTS, 0); - - for($i=0; $i< ($NN-$NROOTS-$PAD); $i++) { - - $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; - if($feedback != $A0) { - // feedback term is non-zero - - // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must - // always be for the polynomials constructed by init_rs() - $feedback = $this->modnn($NN - $GENPOLY[$NROOTS] + $feedback); - - for($j=1;$j<$NROOTS;$j++) { - $parity[$j] ^= $ALPHA_TO[$this->modnn($feedback + $GENPOLY[$NROOTS-$j])]; - } - } - - // Shift - array_shift($parity); - if($feedback != $A0) { - array_push($parity, $ALPHA_TO[$this->modnn($feedback + $GENPOLY[0])]); - } else { - array_push($parity, 0); - } - } - } - } - - //########################################################################## - - class QRrs { - - public static $items = array(); - - //---------------------------------------------------------------------- - public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) - { - foreach(self::$items as $rs) { - if($rs->pad != $pad) continue; - if($rs->nroots != $nroots) continue; - if($rs->mm != $symsize) continue; - if($rs->gfpoly != $gfpoly) continue; - if($rs->fcr != $fcr) continue; - if($rs->prim != $prim) continue; - - return $rs; - } - - $rs = QRrsItem::init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad); - array_unshift(self::$items, $rs); - - return $rs; - } - } - - - -//---- qrmask.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Masking - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - define('N1', 3); - define('N2', 3); - define('N3', 40); - define('N4', 10); - - class QRmask { - - public $runLength = array(); - - //---------------------------------------------------------------------- - public function __construct() - { - $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); - } - - //---------------------------------------------------------------------- - public function writeFormatInformation($width, &$frame, $mask, $level) - { - $blacks = 0; - $format = QRspec::getFormatInfo($mask, $level); - - for($i=0; $i<8; $i++) { - if($format & 1) { - $blacks += 2; - $v = 0x85; - } else { - $v = 0x84; - } - - $frame[8][$width - 1 - $i] = chr($v); - if($i < 6) { - $frame[$i][8] = chr($v); - } else { - $frame[$i + 1][8] = chr($v); - } - $format = $format >> 1; - } - - for($i=0; $i<7; $i++) { - if($format & 1) { - $blacks += 2; - $v = 0x85; - } else { - $v = 0x84; - } - - $frame[$width - 7 + $i][8] = chr($v); - if($i == 0) { - $frame[8][7] = chr($v); - } else { - $frame[8][6 - $i] = chr($v); - } - - $format = $format >> 1; - } - - return $blacks; - } - - //---------------------------------------------------------------------- - public function mask0($x, $y) { return ($x+$y)&1; } - public function mask1($x, $y) { return ($y&1); } - public function mask2($x, $y) { return ($x%3); } - public function mask3($x, $y) { return ($x+$y)%3; } - public function mask4($x, $y) { return (((int)($y/2))+((int)($x/3)))&1; } - public function mask5($x, $y) { return (($x*$y)&1)+($x*$y)%3; } - public function mask6($x, $y) { return ((($x*$y)&1)+($x*$y)%3)&1; } - public function mask7($x, $y) { return ((($x*$y)%3)+(($x+$y)&1))&1; } - - //---------------------------------------------------------------------- - private function generateMaskNo($maskNo, $width, $frame) - { - $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); - - for($y=0; $y<$width; $y++) { - for($x=0; $x<$width; $x++) { - if(ord($frame[$y][$x]) & 0x80) { - $bitMask[$y][$x] = 0; - } else { - $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y); - $bitMask[$y][$x] = ($maskFunc == 0)?1:0; - } - - } - } - - return $bitMask; - } - - //---------------------------------------------------------------------- - public static function serial($bitFrame) - { - $codeArr = array(); - - foreach ($bitFrame as $line) - $codeArr[] = join('', $line); - - return gzcompress(join("\n", $codeArr), 9); - } - - //---------------------------------------------------------------------- - public static function unserial($code) - { - $codeArr = array(); - - $codeLines = explode("\n", gzuncompress($code)); - foreach ($codeLines as $line) - $codeArr[] = str_split($line); - - return $codeArr; - } - - //---------------------------------------------------------------------- - public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) - { - $b = 0; - $bitMask = array(); - - $fileName = QR_CACHE_DIR.'mask_'.$maskNo.DIRECTORY_SEPARATOR.'mask_'.$width.'_'.$maskNo.'.dat'; - - if (QR_CACHEABLE) { - if (file_exists($fileName)) { - $bitMask = self::unserial(file_get_contents($fileName)); - } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); - file_put_contents($fileName, self::serial($bitMask)); - } - } else { - $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); - } - - if ($maskGenOnly) - return; - - $d = $s; - - for($y=0; $y<$width; $y++) { - for($x=0; $x<$width; $x++) { - if($bitMask[$y][$x] == 1) { - $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); - } - $b += (int)(ord($d[$y][$x]) & 1); - } - } - - return $b; - } - - //---------------------------------------------------------------------- - public function makeMask($width, $frame, $maskNo, $level) - { - $masked = array_fill(0, $width, str_repeat("\0", $width)); - $this->makeMaskNo($maskNo, $width, $frame, $masked); - $this->writeFormatInformation($width, $masked, $maskNo, $level); - - return $masked; - } - - //---------------------------------------------------------------------- - public function calcN1N3($length) - { - $demerit = 0; - - for($i=0; $i<$length; $i++) { - - if($this->runLength[$i] >= 5) { - $demerit += (N1 + ($this->runLength[$i] - 5)); - } - if($i & 1) { - if(($i >= 3) && ($i < ($length-2)) && ($this->runLength[$i] % 3 == 0)) { - $fact = (int)($this->runLength[$i] / 3); - if(($this->runLength[$i-2] == $fact) && - ($this->runLength[$i-1] == $fact) && - ($this->runLength[$i+1] == $fact) && - ($this->runLength[$i+2] == $fact)) { - if(($this->runLength[$i-3] < 0) || ($this->runLength[$i-3] >= (4 * $fact))) { - $demerit += N3; - } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) { - $demerit += N3; - } - } - } - } - } - return $demerit; - } - - //---------------------------------------------------------------------- - public function evaluateSymbol($width, $frame) - { - $head = 0; - $demerit = 0; - - for($y=0; $y<$width; $y++) { - $head = 0; - $this->runLength[0] = 1; - - $frameY = $frame[$y]; - - if ($y>0) - $frameYM = $frame[$y-1]; - - for($x=0; $x<$width; $x++) { - if(($x > 0) && ($y > 0)) { - $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]); - $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]); - - if(($b22 | ($w22 ^ 1))&1) { - $demerit += N2; - } - } - if(($x == 0) && (ord($frameY[$x]) & 1)) { - $this->runLength[0] = -1; - $head = 1; - $this->runLength[$head] = 1; - } else if($x > 0) { - if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) { - $head++; - $this->runLength[$head] = 1; - } else { - $this->runLength[$head]++; - } - } - } - - $demerit += $this->calcN1N3($head+1); - } - - for($x=0; $x<$width; $x++) { - $head = 0; - $this->runLength[0] = 1; - - for($y=0; $y<$width; $y++) { - if($y == 0 && (ord($frame[$y][$x]) & 1)) { - $this->runLength[0] = -1; - $head = 1; - $this->runLength[$head] = 1; - } else if($y > 0) { - if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) { - $head++; - $this->runLength[$head] = 1; - } else { - $this->runLength[$head]++; - } - } - } - - $demerit += $this->calcN1N3($head+1); - } - - return $demerit; - } - - - //---------------------------------------------------------------------- - public function mask($width, $frame, $level) - { - $minDemerit = PHP_INT_MAX; - $bestMaskNum = 0; - $bestMask = array(); - - $checked_masks = array(0,1,2,3,4,5,6,7); - - if (QR_FIND_FROM_RANDOM !== false) { - - $howManuOut = 8-(QR_FIND_FROM_RANDOM % 9); - for ($i = 0; $i < $howManuOut; $i++) { - $remPos = rand (0, count($checked_masks)-1); - unset($checked_masks[$remPos]); - $checked_masks = array_values($checked_masks); - } - - } - - $bestMask = $frame; - - foreach($checked_masks as $i) { - $mask = array_fill(0, $width, str_repeat("\0", $width)); - - $demerit = 0; - $blacks = 0; - $blacks = $this->makeMaskNo($i, $width, $frame, $mask); - $blacks += $this->writeFormatInformation($width, $mask, $i, $level); - $blacks = (int)(100 * $blacks / ($width * $width)); - $demerit = (int)((int)(abs($blacks - 50) / 5) * N4); - $demerit += $this->evaluateSymbol($width, $mask); - - if($demerit < $minDemerit) { - $minDemerit = $demerit; - $bestMask = $mask; - $bestMaskNum = $i; - } - } - - return $bestMask; - } - - //---------------------------------------------------------------------- - } - - - - -//---- qrencode.php ----------------------------- - - - - -/* - * PHP QR Code encoder - * - * Main encoder classes. - * - * Based on libqrencode C library distributed under LGPL 2.1 - * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi - * - * PHP QR Code is distributed under LGPL 3 - * Copyright (C) 2010 Dominik Dzienia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - class QRrsblock { - public $dataLength; - public $data = array(); - public $eccLength; - public $ecc = array(); - - public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs) - { - $rs->encode_rs_char($data, $ecc); - - $this->dataLength = $dl; - $this->data = $data; - $this->eccLength = $el; - $this->ecc = $ecc; - } - }; - - //########################################################################## - - class QRrawcode { - public $version; - public $datacode = array(); - public $ecccode = array(); - public $blocks; - public $rsblocks = array(); //of RSblock - public $count; - public $dataLength; - public $eccLength; - public $b1; - - //---------------------------------------------------------------------- - public function __construct(QRinput $input) - { - $spec = array(0,0,0,0,0); - - $this->datacode = $input->getByteStream(); - if(is_null($this->datacode)) { - throw new Exception('null imput string'); - } - - QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec); - - $this->version = $input->getVersion(); - $this->b1 = QRspec::rsBlockNum1($spec); - $this->dataLength = QRspec::rsDataLength($spec); - $this->eccLength = QRspec::rsEccLength($spec); - $this->ecccode = array_fill(0, $this->eccLength, 0); - $this->blocks = QRspec::rsBlockNum($spec); - - $ret = $this->init($spec); - if($ret < 0) { - throw new Exception('block alloc error'); - return null; - } - - $this->count = 0; - } - - //---------------------------------------------------------------------- - public function init(array $spec) - { - $dl = QRspec::rsDataCodes1($spec); - $el = QRspec::rsEccCodes1($spec); - $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); - - - $blockNo = 0; - $dataPos = 0; - $eccPos = 0; - for($i=0; $iecccode,$eccPos); - $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); - $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); - - $dataPos += $dl; - $eccPos += $el; - $blockNo++; - } - - if(QRspec::rsBlockNum2($spec) == 0) - return 0; - - $dl = QRspec::rsDataCodes2($spec); - $el = QRspec::rsEccCodes2($spec); - $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); - - if($rs == NULL) return -1; - - for($i=0; $iecccode,$eccPos); - $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); - $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); - - $dataPos += $dl; - $eccPos += $el; - $blockNo++; - } - - return 0; - } - - //---------------------------------------------------------------------- - public function getCode() - { - $ret; - - if($this->count < $this->dataLength) { - $row = $this->count % $this->blocks; - $col = $this->count / $this->blocks; - if($col >= $this->rsblocks[0]->dataLength) { - $row += $this->b1; - } - $ret = $this->rsblocks[$row]->data[$col]; - } else if($this->count < $this->dataLength + $this->eccLength) { - $row = ($this->count - $this->dataLength) % $this->blocks; - $col = ($this->count - $this->dataLength) / $this->blocks; - $ret = $this->rsblocks[$row]->ecc[$col]; - } else { - return 0; - } - $this->count++; - - return $ret; - } - } - - //########################################################################## - - class QRcode { - - public $version; - public $width; - public $data; - - //---------------------------------------------------------------------- - public function encodeMask(QRinput $input, $mask) - { - if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { - throw new Exception('wrong version'); - } - if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) { - throw new Exception('wrong level'); - } - - $raw = new QRrawcode($input); - - QRtools::markTime('after_raw'); - - $version = $raw->version; - $width = QRspec::getWidth($version); - $frame = QRspec::newFrame($version); - - $filler = new FrameFiller($width, $frame); - if(is_null($filler)) { - return NULL; - } - - // inteleaved data and ecc codes - for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) { - $code = $raw->getCode(); - $bit = 0x80; - for($j=0; $j<8; $j++) { - $addr = $filler->next(); - $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); - $bit = $bit >> 1; - } - } - - QRtools::markTime('after_filler'); - - unset($raw); - - // remainder bits - $j = QRspec::getRemainder($version); - for($i=0; $i<$j; $i++) { - $addr = $filler->next(); - $filler->setFrameAt($addr, 0x02); - } - - $frame = $filler->frame; - unset($filler); - - - // masking - $maskObj = new QRmask(); - if($mask < 0) { - - if (QR_FIND_BEST_MASK) { - $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel()); - } else { - $masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel()); - } - } else { - $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel()); - } - - if($masked == NULL) { - return NULL; - } - - QRtools::markTime('after_mask'); - - $this->version = $version; - $this->width = $width; - $this->data = $masked; - - return $this; - } - - //---------------------------------------------------------------------- - public function encodeInput(QRinput $input) - { - return $this->encodeMask($input, -1); - } - - //---------------------------------------------------------------------- - public function encodeString8bit($string, $version, $level) - { - if(string == NULL) { - throw new Exception('empty string!'); - return NULL; - } - - $input = new QRinput($version, $level); - if($input == NULL) return NULL; - - $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); - if($ret < 0) { - unset($input); - return NULL; - } - return $this->encodeInput($input); - } - - //---------------------------------------------------------------------- - public function encodeString($string, $version, $level, $hint, $casesensitive) - { - - if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) { - throw new Exception('bad hint'); - return NULL; - } - - $input = new QRinput($version, $level); - if($input == NULL) return NULL; - - $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); - if($ret < 0) { - return NULL; - } - - return $this->encodeInput($input); - } - - //---------------------------------------------------------------------- - public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false) - { - $enc = QRencode::factory($level, $size, $margin); - return $enc->encodePNG($text, $outfile, $saveandprint=false); - } - - //---------------------------------------------------------------------- - public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) - { - $enc = QRencode::factory($level, $size, $margin); - return $enc->encode($text, $outfile); - } - - //---------------------------------------------------------------------- - public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) - { - $enc = QRencode::factory($level, $size, $margin); - return $enc->encodeRAW($text, $outfile); - } - } - - //########################################################################## - - class FrameFiller { - - public $width; - public $frame; - public $x; - public $y; - public $dir; - public $bit; - - //---------------------------------------------------------------------- - public function __construct($width, &$frame) - { - $this->width = $width; - $this->frame = $frame; - $this->x = $width - 1; - $this->y = $width - 1; - $this->dir = -1; - $this->bit = -1; - } - - //---------------------------------------------------------------------- - public function setFrameAt($at, $val) - { - $this->frame[$at['y']][$at['x']] = chr($val); - } - - //---------------------------------------------------------------------- - public function getFrameAt($at) - { - return ord($this->frame[$at['y']][$at['x']]); - } - - //---------------------------------------------------------------------- - public function next() - { - do { - - if($this->bit == -1) { - $this->bit = 0; - return array('x'=>$this->x, 'y'=>$this->y); - } - - $x = $this->x; - $y = $this->y; - $w = $this->width; - - if($this->bit == 0) { - $x--; - $this->bit++; - } else { - $x++; - $y += $this->dir; - $this->bit--; - } - - if($this->dir < 0) { - if($y < 0) { - $y = 0; - $x -= 2; - $this->dir = 1; - if($x == 6) { - $x--; - $y = 9; - } - } - } else { - if($y == $w) { - $y = $w - 1; - $x -= 2; - $this->dir = -1; - if($x == 6) { - $x--; - $y -= 8; - } - } - } - if($x < 0 || $y < 0) return null; - - $this->x = $x; - $this->y = $y; - - } while(ord($this->frame[$y][$x]) & 0x80); - - return array('x'=>$x, 'y'=>$y); - } - - } ; - - //########################################################################## - - class QRencode { - - public $casesensitive = true; - public $eightbit = false; - - public $version = 0; - public $size = 3; - public $margin = 4; - - public $structured = 0; // not supported yet - - public $level = QR_ECLEVEL_L; - public $hint = QR_MODE_8; - - //---------------------------------------------------------------------- - public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4) - { - $enc = new QRencode(); - $enc->size = $size; - $enc->margin = $margin; - - switch ($level.'') { - case '0': - case '1': - case '2': - case '3': - $enc->level = $level; - break; - case 'l': - case 'L': - $enc->level = QR_ECLEVEL_L; - break; - case 'm': - case 'M': - $enc->level = QR_ECLEVEL_M; - break; - case 'q': - case 'Q': - $enc->level = QR_ECLEVEL_Q; - break; - case 'h': - case 'H': - $enc->level = QR_ECLEVEL_H; - break; - } - - return $enc; - } - - //---------------------------------------------------------------------- - public function encodeRAW($intext, $outfile = false) - { - $code = new QRcode(); - - if($this->eightbit) { - $code->encodeString8bit($intext, $this->version, $this->level); - } else { - $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive); - } - - return $code->data; - } - - //---------------------------------------------------------------------- - public function encode($intext, $outfile = false) - { - $code = new QRcode(); - - if($this->eightbit) { - $code->encodeString8bit($intext, $this->version, $this->level); - } else { - $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive); - } - - QRtools::markTime('after_encode'); - - if ($outfile!== false) { - file_put_contents($outfile, join("\n", QRtools::binarize($code->data))); - } else { - return QRtools::binarize($code->data); - } - } - - //---------------------------------------------------------------------- - public function encodePNG($intext, $outfile = false,$saveandprint=false) - { - try { - - ob_start(); - $tab = $this->encode($intext); - $err = ob_get_contents(); - ob_end_clean(); - - if ($err != '') - QRtools::log($outfile, $err); - - $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); - - QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint); - - } catch (Exception $e) { - - QRtools::log($outfile, $e->getMessage()); - - } - } - } - - diff --git a/public/php_sdk_v3.0.10/example/qrcode.php b/public/php_sdk_v3.0.10/example/qrcode.php deleted file mode 100755 index 226da398a..000000000 --- a/public/php_sdk_v3.0.10/example/qrcode.php +++ /dev/null @@ -1,15 +0,0 @@ - - - - - 微信支付样例-退款 - -$value){ - echo "$key : ".htmlspecialchars($value, ENT_QUOTES)."
"; - } -} - -if(isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != ""){ - try{ - $transaction_id = $_REQUEST["transaction_id"]; - $total_fee = $_REQUEST["total_fee"]; - $refund_fee = $_REQUEST["refund_fee"]; - $input = new WxPayRefund(); - $input->SetTransaction_id($transaction_id); - $input->SetTotal_fee($total_fee); - $input->SetRefund_fee($refund_fee); - - $config = new WxPayConfig(); - $input->SetOut_refund_no("sdkphp".date("YmdHis")); - $input->SetOp_user_id($config->GetMerchantId()); - printf_info(WxPayApi::refund($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} - -//$_REQUEST["out_trade_no"]= "122531270220150304194108"; -///$_REQUEST["total_fee"]= "1"; -//$_REQUEST["refund_fee"] = "1"; -if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){ - try{ - $out_trade_no = $_REQUEST["out_trade_no"]; - $total_fee = $_REQUEST["total_fee"]; - $refund_fee = $_REQUEST["refund_fee"]; - $input = new WxPayRefund(); - $input->SetOut_trade_no($out_trade_no); - $input->SetTotal_fee($total_fee); - $input->SetRefund_fee($refund_fee); - - $config = new WxPayConfig(); - $input->SetOut_refund_no("sdkphp".date("YmdHis")); - $input->SetOp_user_id($config->GetMerchantId()); - printf_info(WxPayApi::refund($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} -?> - -
-
微信订单号和商户订单号选少填一个,微信订单号优先:

-
微信订单号:

-

-
商户订单号:

-

-
订单总金额(分):

-

-
退款金额(分):

-

-
- -
-
- - diff --git a/public/php_sdk_v3.0.10/example/refundquery.php b/public/php_sdk_v3.0.10/example/refundquery.php deleted file mode 100755 index edea15468..000000000 --- a/public/php_sdk_v3.0.10/example/refundquery.php +++ /dev/null @@ -1,112 +0,0 @@ - - - - - 微信支付样例-查退款单 - -$value){ - echo "$key : ".htmlspecialchars($value, ENT_QUOTES)."
"; - } -} - -if(isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != ""){ - try{ - $transaction_id = $_REQUEST["transaction_id"]; - $input = new WxPayRefundQuery(); - $input->SetTransaction_id($transaction_id); - $config = new WxPayConfig(); - printf_info(WxPayApi::refundQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } -} - -if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){ - try{ - $out_trade_no = $_REQUEST["out_trade_no"]; - $input = new WxPayRefundQuery(); - $input->SetOut_trade_no($out_trade_no); - $config = new WxPayConfig(); - printf_info(WxPayApi::refundQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} - -if(isset($_REQUEST["out_refund_no"]) && $_REQUEST["out_refund_no"] != ""){ - try{ - $out_refund_no = $_REQUEST["out_refund_no"]; - $input = new WxPayRefundQuery(); - $input->SetOut_refund_no($out_refund_no); - $config = new WxPayConfig(); - printf_info(WxPayApi::refundQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} - -if(isset($_REQUEST["refund_id"]) && $_REQUEST["refund_id"] != ""){ - try{ - $refund_id = $_REQUEST["refund_id"]; - $input = new WxPayRefundQuery(); - $input->SetRefund_id($refund_id); - $config = new WxPayConfig(); - printf_info(WxPayApi::refundQuery($config, $input)); - } catch(Exception $e) { - Log::ERROR(json_encode($e)); - } - exit(); -} - -?> - -
-
微信订单号、商户订单号、微信订单号、微信退款单号选填至少一个,微信退款单号优先:

-
微信订单号:

-

-
商户订单号:

-

-
商户退款单号:

-

-
微信退款单号:

-

-
- -
-
- - diff --git a/public/php_sdk_v3.0.10/lib/WxPay.Api.php b/public/php_sdk_v3.0.10/lib/WxPay.Api.php deleted file mode 100755 index 1fa2382ac..000000000 --- a/public/php_sdk_v3.0.10/lib/WxPay.Api.php +++ /dev/null @@ -1,620 +0,0 @@ -IsOut_trade_noSet()) { - throw new WxPayException("缺少统一支付接口必填参数out_trade_no!"); - }else if(!$inputObj->IsBodySet()){ - throw new WxPayException("缺少统一支付接口必填参数body!"); - }else if(!$inputObj->IsTotal_feeSet()) { - throw new WxPayException("缺少统一支付接口必填参数total_fee!"); - }else if(!$inputObj->IsTrade_typeSet()) { - throw new WxPayException("缺少统一支付接口必填参数trade_type!"); - } - - //关联参数 - if($inputObj->GetTrade_type() == "JSAPI" && !$inputObj->IsOpenidSet()){ - throw new WxPayException("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"); - } - if($inputObj->GetTrade_type() == "NATIVE" && !$inputObj->IsProduct_idSet()){ - throw new WxPayException("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!"); - } - - //异步通知url未设置,则使用配置文件中的url - if(!$inputObj->IsNotify_urlSet() && $config->GetNotifyUrl() != ""){ - $inputObj->SetNotify_url($config->GetNotifyUrl());//异步通知url - } - - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);//终端ip - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - //签名 - $inputObj->SetSign($config); - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 查询订单,WxPayOrderQuery中out_trade_no、transaction_id至少填一个 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayOrderQuery $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function orderQuery($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/pay/orderquery"; - //检测必填参数 - if(!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) { - throw new WxPayException("订单查询接口中,out_trade_no、transaction_id至少填一个!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 关闭订单,WxPayCloseOrder中out_trade_no必填 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayCloseOrder $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function closeOrder($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/pay/closeorder"; - //检测必填参数 - if(!$inputObj->IsOut_trade_noSet()) { - throw new WxPayException("订单查询接口中,out_trade_no必填!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 申请退款,WxPayRefund中out_trade_no、transaction_id至少填一个且 - * out_refund_no、total_fee、refund_fee、op_user_id为必填参数 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayRefund $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function refund($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; - //检测必填参数 - if(!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) { - throw new WxPayException("退款申请接口中,out_trade_no、transaction_id至少填一个!"); - }else if(!$inputObj->IsOut_refund_noSet()){ - throw new WxPayException("退款申请接口中,缺少必填参数out_refund_no!"); - }else if(!$inputObj->IsTotal_feeSet()){ - throw new WxPayException("退款申请接口中,缺少必填参数total_fee!"); - }else if(!$inputObj->IsRefund_feeSet()){ - throw new WxPayException("退款申请接口中,缺少必填参数refund_fee!"); - }else if(!$inputObj->IsOp_user_idSet()){ - throw new WxPayException("退款申请接口中,缺少必填参数op_user_id!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, true, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 查询退款 - * 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时, - * 用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。 - * WxPayRefundQuery中out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayRefundQuery $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function refundQuery($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/pay/refundquery"; - //检测必填参数 - if(!$inputObj->IsOut_refund_noSet() && - !$inputObj->IsOut_trade_noSet() && - !$inputObj->IsTransaction_idSet() && - !$inputObj->IsRefund_idSet()) { - throw new WxPayException("退款查询接口中,out_refund_no、out_trade_no、transaction_id、refund_id四个参数必填一个!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * 下载对账单,WxPayDownloadBill中bill_date为必填参数 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayDownloadBill $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function downloadBill($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/pay/downloadbill"; - //检测必填参数 - if(!$inputObj->IsBill_dateSet()) { - throw new WxPayException("对账单接口中,缺少必填参数bill_date!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - if(substr($response, 0 , 5) == ""){ - return ""; - } - return $response; - } - - /** - * 提交被扫支付API - * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台, - * 由商户收银台或者商户后台调用该接口发起支付。 - * WxPayWxPayMicroPay中body、out_trade_no、total_fee、auth_code参数必填 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayWxPayMicroPay $inputObj - * @param int $timeOut - */ - public static function micropay($config, $inputObj, $timeOut = 10) - { - $url = "https://api.mch.weixin.qq.com/pay/micropay"; - //检测必填参数 - if(!$inputObj->IsBodySet()) { - throw new WxPayException("提交被扫支付API接口中,缺少必填参数body!"); - } else if(!$inputObj->IsOut_trade_noSet()) { - throw new WxPayException("提交被扫支付API接口中,缺少必填参数out_trade_no!"); - } else if(!$inputObj->IsTotal_feeSet()) { - throw new WxPayException("提交被扫支付API接口中,缺少必填参数total_fee!"); - } else if(!$inputObj->IsAuth_codeSet()) { - throw new WxPayException("提交被扫支付API接口中,缺少必填参数auth_code!"); - } - - $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);//终端ip - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 撤销订单API接口,WxPayReverse中参数out_trade_no和transaction_id必须填写一个 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayReverse $inputObj - * @param int $timeOut - * @throws WxPayException - */ - public static function reverse($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/secapi/pay/reverse"; - //检测必填参数 - if(!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) { - throw new WxPayException("撤销订单API接口中,参数out_trade_no和transaction_id必须填写一个!"); - } - - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, true, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 测速上报,该方法内部封装在report中,使用时请注意异常流程 - * WxPayReport中interface_url、return_code、result_code、user_ip、execute_time_必填 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayReport $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function report($config, $inputObj, $timeOut = 1) - { - $url = "https://api.mch.weixin.qq.com/payitil/report"; - //检测必填参数 - if(!$inputObj->IsInterface_urlSet()) { - throw new WxPayException("接口URL,缺少必填参数interface_url!"); - } if(!$inputObj->IsReturn_codeSet()) { - throw new WxPayException("返回状态码,缺少必填参数return_code!"); - } if(!$inputObj->IsResult_codeSet()) { - throw new WxPayException("业务结果,缺少必填参数result_code!"); - } if(!$inputObj->IsUser_ipSet()) { - throw new WxPayException("访问接口IP,缺少必填参数user_ip!"); - } if(!$inputObj->IsExecute_time_Set()) { - throw new WxPayException("接口耗时,缺少必填参数execute_time_!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetUser_ip($_SERVER['REMOTE_ADDR']);//终端ip - $inputObj->SetTime(date("YmdHis"));//商户上报时间 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - return $response; - } - - /** - * - * 生成二维码规则,模式一生成支付二维码 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayBizPayUrl $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function bizpayurl($config, $inputObj, $timeOut = 6) - { - if(!$inputObj->IsProduct_idSet()){ - throw new WxPayException("生成二维码,缺少必填参数product_id!"); - } - - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetTime_stamp(time());//时间戳 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - - return $inputObj->GetValues(); - } - - /** - * - * 转换短链接 - * 该接口主要用于扫码原生支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX), - * 减小二维码数据量,提升扫描速度和精确度。 - * appid、mchid、spbill_create_ip、nonce_str不需要填入 - * @param WxPayConfigInterface $config 配置对象 - * @param WxPayShortUrl $inputObj - * @param int $timeOut - * @throws WxPayException - * @return 成功时返回,其他抛异常 - */ - public static function shorturl($config, $inputObj, $timeOut = 6) - { - $url = "https://api.mch.weixin.qq.com/tools/shorturl"; - //检测必填参数 - if(!$inputObj->IsLong_urlSet()) { - throw new WxPayException("需要转换的URL,签名用原串,传输需URL encode!"); - } - $inputObj->SetAppid($config->GetAppId());//公众账号ID - $inputObj->SetMch_id($config->GetMerchantId());//商户号 - $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 - - $inputObj->SetSign($config);//签名 - $xml = $inputObj->ToXml(); - - $startTimeStamp = self::getMillisecond();//请求开始时间 - $response = self::postXmlCurl($config, $xml, $url, false, $timeOut); - $result = WxPayResults::Init($config, $response); - self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 - - return $result; - } - - /** - * - * 支付结果通用通知 - * @param function $callback - * 直接回调函数使用方法: notify(you_function); - * 回调类成员函数方法:notify(array($this, you_function)); - * $callback 原型为:function function_name($data){} - */ - public static function notify($config, $callback, &$msg) - { - //获取通知的数据 - $xml = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input"); - if (empty($xml)) { - # 如果没有数据,直接返回失败 - return false; - } - - //如果返回成功则验证签名 - try { - $result = WxPayNotifyResults::Init($config, $xml); - } catch (WxPayException $e){ - $msg = $e->errorMessage(); - return false; - } - - return call_user_func($callback, $result); - } - - /** - * - * 产生随机字符串,不长于32位 - * @param int $length - * @return 产生的随机字符串 - */ - public static function getNonceStr($length = 32) - { - $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; - $str =""; - for ( $i = 0; $i < $length; $i++ ) { - $str .= substr($chars, mt_rand(0, strlen($chars)-1), 1); - } - return $str; - } - - /** - * 直接输出xml - * @param string $xml - */ - public static function replyNotify($xml) - { - echo $xml; - } - - /** - * - * 上报数据, 上报的时候将屏蔽所有异常流程 - * @param WxPayConfigInterface $config 配置对象 - * @param string $usrl - * @param int $startTimeStamp - * @param array $data - */ - private static function reportCostTime($config, $url, $startTimeStamp, $data) - { - //如果不需要上报数据 - $reportLevenl = $config->GetReportLevenl(); - if($reportLevenl == 0){ - return; - } - //如果仅失败上报 - if($reportLevenl == 1 && - array_key_exists("return_code", $data) && - $data["return_code"] == "SUCCESS" && - array_key_exists("result_code", $data) && - $data["result_code"] == "SUCCESS") - { - return; - } - - //上报逻辑 - $endTimeStamp = self::getMillisecond(); - $objInput = new WxPayReport(); - $objInput->SetInterface_url($url); - $objInput->SetExecute_time_($endTimeStamp - $startTimeStamp); - //返回状态码 - if(array_key_exists("return_code", $data)){ - $objInput->SetReturn_code($data["return_code"]); - } - //返回信息 - if(array_key_exists("return_msg", $data)){ - $objInput->SetReturn_msg($data["return_msg"]); - } - //业务结果 - if(array_key_exists("result_code", $data)){ - $objInput->SetResult_code($data["result_code"]); - } - //错误代码 - if(array_key_exists("err_code", $data)){ - $objInput->SetErr_code($data["err_code"]); - } - //错误代码描述 - if(array_key_exists("err_code_des", $data)){ - $objInput->SetErr_code_des($data["err_code_des"]); - } - //商户订单号 - if(array_key_exists("out_trade_no", $data)){ - $objInput->SetOut_trade_no($data["out_trade_no"]); - } - //设备号 - if(array_key_exists("device_info", $data)){ - $objInput->SetDevice_info($data["device_info"]); - } - - try{ - self::report($config, $objInput); - } catch (WxPayException $e){ - //不做任何处理 - } - } - - /** - * 以post方式提交xml到对应的接口url - * - * @param WxPayConfigInterface $config 配置对象 - * @param string $xml 需要post的xml数据 - * @param string $url url - * @param bool $useCert 是否需要证书,默认不需要 - * @param int $second url执行超时时间,默认30s - * @throws WxPayException - */ - private static function postXmlCurl($config, $xml, $url, $useCert = false, $second = 30) - { - $ch = curl_init(); - $curlVersion = curl_version(); - $ua = "WXPaySDK/".self::$VERSION." (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." " - .$config->GetMerchantId(); - - //设置超时 - curl_setopt($ch, CURLOPT_TIMEOUT, $second); - - $proxyHost = "0.0.0.0"; - $proxyPort = 0; - $config->GetProxy($proxyHost, $proxyPort); - //如果有配置代理这里就设置代理 - if($proxyHost != "0.0.0.0" && $proxyPort != 0){ - curl_setopt($ch,CURLOPT_PROXY, $proxyHost); - curl_setopt($ch,CURLOPT_PROXYPORT, $proxyPort); - } - curl_setopt($ch,CURLOPT_URL, $url); - curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); - curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验 - curl_setopt($ch,CURLOPT_USERAGENT, $ua); - //设置header - curl_setopt($ch, CURLOPT_HEADER, FALSE); - //要求结果为字符串且输出到屏幕上 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - - if($useCert == true){ - //设置证书 - //使用证书:cert 与 key 分别属于两个.pem文件 - //证书文件请放入服务器的非web目录下 - $sslCertPath = ""; - $sslKeyPath = ""; - $config->GetSSLCertPath($sslCertPath, $sslKeyPath); - curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); - curl_setopt($ch,CURLOPT_SSLCERT, $sslCertPath); - curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); - curl_setopt($ch,CURLOPT_SSLKEY, $sslKeyPath); - - // echo file_get_contents($sslCertPath)."\n"; - // echo file_get_contents($sslKeyPath); - // die; - } - //post提交方式 - curl_setopt($ch, CURLOPT_POST, TRUE); - curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); - //运行curl - $data = curl_exec($ch); - //返回结果 - if($data){ - curl_close($ch); - return $data; - } else { - $error = curl_errno($ch); - curl_close($ch); - throw new WxPayException("curl出错,错误码:$error"); - } - } - - /** - * 获取毫秒级别的时间戳 - */ - private static function getMillisecond() - { - //获取毫秒的时间戳 - $time = explode ( " ", microtime () ); - $time = $time[1] . ($time[0] * 1000); - $time2 = explode( ".", $time ); - $time = $time2[0]; - return $time; - } -} - diff --git a/public/php_sdk_v3.0.10/lib/WxPay.Config.Interface.php b/public/php_sdk_v3.0.10/lib/WxPay.Config.Interface.php deleted file mode 100755 index 3129a04c5..000000000 --- a/public/php_sdk_v3.0.10/lib/WxPay.Config.Interface.php +++ /dev/null @@ -1,76 +0,0 @@ -values['sign_type'] = $sign_type; - return $sign_type; - } - - /** - * 设置签名,详见签名生成算法 - * @param string $value - **/ - public function SetSign($config) - { - $sign = $this->MakeSign($config); - $this->values['sign'] = $sign; - return $sign; - } - - /** - * 获取签名,详见签名生成算法的值 - * @return 值 - **/ - public function GetSign() - { - return $this->values['sign']; - } - - /** - * 判断签名,详见签名生成算法是否存在 - * @return true 或 false - **/ - public function IsSignSet() - { - return array_key_exists('sign', $this->values); - } - - /** - * 输出xml字符 - * @throws WxPayException - **/ - public function ToXml() - { - if(!is_array($this->values) || count($this->values) <= 0) - { - throw new WxPayException("数组数据异常!"); - } - - $xml = ""; - foreach ($this->values as $key=>$val) - { - if (is_numeric($val)){ - $xml.="<".$key.">".$val.""; - }else{ - $xml.="<".$key.">"; - } - } - $xml.=""; - return $xml; - } - - /** - * 将xml转为array - * @param string $xml - * @throws WxPayException - */ - public function FromXml($xml) - { - if(!$xml){ - throw new WxPayException("xml数据异常!"); - } - //将XML转为array - //禁止引用外部xml实体 - libxml_disable_entity_loader(true); - $this->values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); - return $this->values; - } - - /** - * 格式化参数格式化成url参数 - */ - public function ToUrlParams() - { - $buff = ""; - foreach ($this->values as $k => $v) - { - if($k != "sign" && $v != "" && !is_array($v)){ - $buff .= $k . "=" . $v . "&"; - } - } - - $buff = trim($buff, "&"); - return $buff; - } - - /** - * 生成签名 - * @param WxPayConfigInterface $config 配置对象 - * @param bool $needSignType 是否需要补signtype - * @return 签名,本函数不覆盖sign成员变量,如要设置签名需要调用SetSign方法赋值 - */ - public function MakeSign($config, $needSignType = true) - { - if($needSignType) { - $this->SetSignType($config->GetSignType()); - } - //签名步骤一:按字典序排序参数 - ksort($this->values); - $string = $this->ToUrlParams(); - //签名步骤二:在string后加入KEY - $string = $string . "&key=".$config->GetKey(); - //签名步骤三:MD5加密或者HMAC-SHA256 - if($config->GetSignType() == "MD5"){ - $string = md5($string); - } else if($config->GetSignType() == "HMAC-SHA256") { - $string = hash_hmac("sha256",$string ,$config->GetKey()); - } else { - throw new WxPayException("签名类型不支持!"); - } - - //签名步骤四:所有字符转为大写 - $result = strtoupper($string); - return $result; - } - - /** - * 获取设置的值 - */ - public function GetValues() - { - return $this->values; - } -} - -/** - * - * 只使用md5算法进行签名, 不管配置的是什么签名方式,都只支持md5签名方式 - * -**/ -class WxPayDataBaseSignMd5 extends WxPayDataBase -{ - /** - * 生成签名 - 重写该方法 - * @param WxPayConfigInterface $config 配置对象 - * @param bool $needSignType 是否需要补signtype - * @return 签名,本函数不覆盖sign成员变量,如要设置签名需要调用SetSign方法赋值 - */ - public function MakeSign($config, $needSignType = false) - { - if($needSignType) { - $this->SetSignType($config->GetSignType()); - } - //签名步骤一:按字典序排序参数 - ksort($this->values); - $string = $this->ToUrlParams(); - //签名步骤二:在string后加入KEY - $string = $string . "&key=".$config->GetKey(); - //签名步骤三:MD5加密 - $string = md5($string); - //签名步骤四:所有字符转为大写 - $result = strtoupper($string); - return $result; - } -} - -/** - * - * 接口调用结果类 - * @author widyhu - * - */ -class WxPayResults extends WxPayDataBase -{ - /** - * 生成签名 - 重写该方法 - * @param WxPayConfigInterface $config 配置对象 - * @param bool $needSignType 是否需要补signtype - * @return 签名,本函数不覆盖sign成员变量,如要设置签名需要调用SetSign方法赋值 - */ - public function MakeSign($config, $needSignType = false) - { - //签名步骤一:按字典序排序参数 - ksort($this->values); - $string = $this->ToUrlParams(); - //签名步骤二:在string后加入KEY - $string = $string . "&key=".$config->GetKey(); - //签名步骤三:MD5加密或者HMAC-SHA256 - if(strlen($this->GetSign()) <= 32){ - //如果签名小于等于32个,则使用md5验证 - $string = md5($string); - } else { - //是用sha256校验 - $string = hash_hmac("sha256",$string ,$config->GetKey()); - } - //签名步骤四:所有字符转为大写 - $result = strtoupper($string); - return $result; - } - - /** - * @param WxPayConfigInterface $config 配置对象 - * 检测签名 - */ - public function CheckSign($config) - { - if(!$this->IsSignSet()){ - throw new WxPayException("签名错误!"); - } - - $sign = $this->MakeSign($config, false); - if($this->GetSign() == $sign){ - //签名正确 - return true; - } - throw new WxPayException("签名错误!"); - } - - /** - * - * 使用数组初始化 - * @param array $array - */ - public function FromArray($array) - { - $this->values = $array; - } - - /** - * - * 使用数组初始化对象 - * @param array $array - * @param 是否检测签名 $noCheckSign - */ - public static function InitFromArray($config, $array, $noCheckSign = false) - { - $obj = new self(); - $obj->FromArray($array); - if($noCheckSign == false){ - $obj->CheckSign($config); - } - return $obj; - } - - /** - * - * 设置参数 - * @param string $key - * @param string $value - */ - public function SetData($key, $value) - { - $this->values[$key] = $value; - } - - /** - * 将xml转为array - * @param WxPayConfigInterface $config 配置对象 - * @param string $xml - * @throws WxPayException - */ - public static function Init($config, $xml) - { - $obj = new self(); - $obj->FromXml($xml); - //失败则直接返回失败 - if($obj->values['return_code'] != 'SUCCESS') { - foreach ($obj->values as $key => $value) { - #除了return_code和return_msg之外其他的参数存在,则报错 - if($key != "return_code" && $key != "return_msg"){ - throw new WxPayException("输入数据存在异常!"); - return false; - } - } - return $obj->GetValues(); - } - $obj->CheckSign($config); - return $obj->GetValues(); - } -} - -/** - * - * 回调回包数据基类 - * - **/ -class WxPayNotifyResults extends WxPayResults -{ - /** - * 将xml转为array - * @param WxPayConfigInterface $config - * @param string $xml - * @return WxPayNotifyResults - * @throws WxPayException - */ - public static function Init($config, $xml) - { - $obj = new self(); - $obj->FromXml($xml); - //失败则直接返回失败 - $obj->CheckSign($config); - return $obj; - } -} - -/** - * - * 回调基础类 - * @author widyhu - * - */ -class WxPayNotifyReply extends WxPayDataBaseSignMd5 -{ - /** - * - * 设置错误码 FAIL 或者 SUCCESS - * @param string - */ - public function SetReturn_code($return_code) - { - $this->values['return_code'] = $return_code; - } - - /** - * - * 获取错误码 FAIL 或者 SUCCESS - * @return string $return_code - */ - public function GetReturn_code() - { - return $this->values['return_code']; - } - - /** - * - * 设置错误信息 - * @param string $return_code - */ - public function SetReturn_msg($return_msg) - { - $this->values['return_msg'] = $return_msg; - } - - /** - * - * 获取错误信息 - * @return string - */ - public function GetReturn_msg() - { - return $this->values['return_msg']; - } - - /** - * - * 设置返回参数 - * @param string $key - * @param string $value - */ - public function SetData($key, $value) - { - $this->values[$key] = $value; - } -} - -/** - * - * 统一下单输入对象 - * @author widyhu - * - */ -class WxPayUnifiedOrder extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信支付分配的终端设备号,商户自定义 - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取微信支付分配的终端设备号,商户自定义的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断微信支付分配的终端设备号,商户自定义是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置商品或支付单简要描述 - * @param string $value - **/ - public function SetBody($value) - { - $this->values['body'] = $value; - } - /** - * 获取商品或支付单简要描述的值 - * @return 值 - **/ - public function GetBody() - { - return $this->values['body']; - } - /** - * 判断商品或支付单简要描述是否存在 - * @return true 或 false - **/ - public function IsBodySet() - { - return array_key_exists('body', $this->values); - } - - - /** - * 设置商品名称明细列表 - * @param string $value - **/ - public function SetDetail($value) - { - $this->values['detail'] = $value; - } - /** - * 获取商品名称明细列表的值 - * @return 值 - **/ - public function GetDetail() - { - return $this->values['detail']; - } - /** - * 判断商品名称明细列表是否存在 - * @return true 或 false - **/ - public function IsDetailSet() - { - return array_key_exists('detail', $this->values); - } - - - /** - * 设置附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 - * @param string $value - **/ - public function SetAttach($value) - { - $this->values['attach'] = $value; - } - /** - * 获取附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据的值 - * @return 值 - **/ - public function GetAttach() - { - return $this->values['attach']; - } - /** - * 判断附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据是否存在 - * @return true 或 false - **/ - public function IsAttachSet() - { - return array_key_exists('attach', $this->values); - } - - - /** - * 设置商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 - * @param string $value - **/ - public function SetFee_type($value) - { - $this->values['fee_type'] = $value; - } - /** - * 获取符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型的值 - * @return 值 - **/ - public function GetFee_type() - { - return $this->values['fee_type']; - } - /** - * 判断符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型是否存在 - * @return true 或 false - **/ - public function IsFee_typeSet() - { - return array_key_exists('fee_type', $this->values); - } - - - /** - * 设置订单总金额,只能为整数,详见支付金额 - * @param string $value - **/ - public function SetTotal_fee($value) - { - $this->values['total_fee'] = $value; - } - /** - * 获取订单总金额,只能为整数,详见支付金额的值 - * @return 值 - **/ - public function GetTotal_fee() - { - return $this->values['total_fee']; - } - /** - * 判断订单总金额,只能为整数,详见支付金额是否存在 - * @return true 或 false - **/ - public function IsTotal_feeSet() - { - return array_key_exists('total_fee', $this->values); - } - - - /** - * 设置APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。 - * @param string $value - **/ - public function SetSpbill_create_ip($value) - { - $this->values['spbill_create_ip'] = $value; - } - /** - * 获取APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。的值 - * @return 值 - **/ - public function GetSpbill_create_ip() - { - return $this->values['spbill_create_ip']; - } - /** - * 判断APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。是否存在 - * @return true 或 false - **/ - public function IsSpbill_create_ipSet() - { - return array_key_exists('spbill_create_ip', $this->values); - } - - - /** - * 设置订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则 - * @param string $value - **/ - public function SetTime_start($value) - { - $this->values['time_start'] = $value; - } - /** - * 获取订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则的值 - * @return 值 - **/ - public function GetTime_start() - { - return $this->values['time_start']; - } - /** - * 判断订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则是否存在 - * @return true 或 false - **/ - public function IsTime_startSet() - { - return array_key_exists('time_start', $this->values); - } - - - /** - * 设置订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则 - * @param string $value - **/ - public function SetTime_expire($value) - { - $this->values['time_expire'] = $value; - } - /** - * 获取订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则的值 - * @return 值 - **/ - public function GetTime_expire() - { - return $this->values['time_expire']; - } - /** - * 判断订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则是否存在 - * @return true 或 false - **/ - public function IsTime_expireSet() - { - return array_key_exists('time_expire', $this->values); - } - - - /** - * 设置商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠 - * @param string $value - **/ - public function SetGoods_tag($value) - { - $this->values['goods_tag'] = $value; - } - /** - * 获取商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠的值 - * @return 值 - **/ - public function GetGoods_tag() - { - return $this->values['goods_tag']; - } - /** - * 判断商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠是否存在 - * @return true 或 false - **/ - public function IsGoods_tagSet() - { - return array_key_exists('goods_tag', $this->values); - } - - - /** - * 设置接收微信支付异步通知回调地址 - * @param string $value - **/ - public function SetNotify_url($value) - { - $this->values['notify_url'] = $value; - } - /** - * 获取接收微信支付异步通知回调地址的值 - * @return 值 - **/ - public function GetNotify_url() - { - return $this->values['notify_url']; - } - /** - * 判断接收微信支付异步通知回调地址是否存在 - * @return true 或 false - **/ - public function IsNotify_urlSet() - { - return array_key_exists('notify_url', $this->values); - } - - - /** - * 设置取值如下:JSAPI,NATIVE,APP,详细说明见参数规定 - * @param string $value - **/ - public function SetTrade_type($value) - { - $this->values['trade_type'] = $value; - } - /** - * 获取取值如下:JSAPI,NATIVE,APP,详细说明见参数规定的值 - * @return 值 - **/ - public function GetTrade_type() - { - return $this->values['trade_type']; - } - /** - * 判断取值如下:JSAPI,NATIVE,APP,详细说明见参数规定是否存在 - * @return true 或 false - **/ - public function IsTrade_typeSet() - { - return array_key_exists('trade_type', $this->values); - } - - - /** - * 设置trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。 - * @param string $value - **/ - public function SetProduct_id($value) - { - $this->values['product_id'] = $value; - } - /** - * 获取trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。的值 - * @return 值 - **/ - public function GetProduct_id() - { - return $this->values['product_id']; - } - /** - * 判断trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。是否存在 - * @return true 或 false - **/ - public function IsProduct_idSet() - { - return array_key_exists('product_id', $this->values); - } - - - /** - * 设置trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。 - * @param string $value - **/ - public function SetOpenid($value) - { - $this->values['openid'] = $value; - } - /** - * 获取trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。 的值 - * @return 值 - **/ - public function GetOpenid() - { - return $this->values['openid']; - } - /** - * 判断trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。下单前需要调用【网页授权获取用户信息】接口获取到用户的Openid。 是否存在 - * @return true 或 false - **/ - public function IsOpenidSet() - { - return array_key_exists('openid', $this->values); - } -} - -/** - * - * 订单查询输入对象 - * @author widyhu - * - */ -class WxPayOrderQuery extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信的订单号,优先使用 - * @param string $value - **/ - public function SetTransaction_id($value) - { - $this->values['transaction_id'] = $value; - } - /** - * 获取微信的订单号,优先使用的值 - * @return 值 - **/ - public function GetTransaction_id() - { - return $this->values['transaction_id']; - } - /** - * 判断微信的订单号,优先使用是否存在 - * @return true 或 false - **/ - public function IsTransaction_idSet() - { - return array_key_exists('transaction_id', $this->values); - } - - - /** - * 设置商户系统内部的订单号,当没提供transaction_id时需要传这个。 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,当没提供transaction_id时需要传这个。的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,当没提供transaction_id时需要传这个。是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } -} - -/** - * - * 关闭订单输入对象 - * @author widyhu - * - */ -class WxPayCloseOrder extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置商户系统内部的订单号 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } -} - -/** - * - * 提交退款输入对象 - * @author widyhu - * - */ -class WxPayRefund extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信支付分配的终端设备号,与下单一致 - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取微信支付分配的终端设备号,与下单一致的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断微信支付分配的终端设备号,与下单一致是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置微信订单号 - * @param string $value - **/ - public function SetTransaction_id($value) - { - $this->values['transaction_id'] = $value; - } - /** - * 获取微信订单号的值 - * @return 值 - **/ - public function GetTransaction_id() - { - return $this->values['transaction_id']; - } - /** - * 判断微信订单号是否存在 - * @return true 或 false - **/ - public function IsTransaction_idSet() - { - return array_key_exists('transaction_id', $this->values); - } - - - /** - * 设置商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔 - * @param string $value - **/ - public function SetOut_refund_no($value) - { - $this->values['out_refund_no'] = $value; - } - /** - * 获取商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔的值 - * @return 值 - **/ - public function GetOut_refund_no() - { - return $this->values['out_refund_no']; - } - /** - * 判断商户系统内部的退款单号,商户系统内部唯一,同一退款单号多次请求只退一笔是否存在 - * @return true 或 false - **/ - public function IsOut_refund_noSet() - { - return array_key_exists('out_refund_no', $this->values); - } - - - /** - * 设置订单总金额,单位为分,只能为整数,详见支付金额 - * @param string $value - **/ - public function SetTotal_fee($value) - { - $this->values['total_fee'] = $value; - } - /** - * 获取订单总金额,单位为分,只能为整数,详见支付金额的值 - * @return 值 - **/ - public function GetTotal_fee() - { - return $this->values['total_fee']; - } - /** - * 判断订单总金额,单位为分,只能为整数,详见支付金额是否存在 - * @return true 或 false - **/ - public function IsTotal_feeSet() - { - return array_key_exists('total_fee', $this->values); - } - - - /** - * 设置退款总金额,订单总金额,单位为分,只能为整数,详见支付金额 - * @param string $value - **/ - public function SetRefund_fee($value) - { - $this->values['refund_fee'] = $value; - } - /** - * 获取退款总金额,订单总金额,单位为分,只能为整数,详见支付金额的值 - * @return 值 - **/ - public function GetRefund_fee() - { - return $this->values['refund_fee']; - } - /** - * 判断退款总金额,订单总金额,单位为分,只能为整数,详见支付金额是否存在 - * @return true 或 false - **/ - public function IsRefund_feeSet() - { - return array_key_exists('refund_fee', $this->values); - } - - - /** - * 设置货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 - * @param string $value - **/ - public function SetRefund_fee_type($value) - { - $this->values['refund_fee_type'] = $value; - } - /** - * 获取货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型的值 - * @return 值 - **/ - public function GetRefund_fee_type() - { - return $this->values['refund_fee_type']; - } - /** - * 判断货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型是否存在 - * @return true 或 false - **/ - public function IsRefund_fee_typeSet() - { - return array_key_exists('refund_fee_type', $this->values); - } - - - /** - * 设置操作员帐号, 默认为商户号 - * @param string $value - **/ - public function SetOp_user_id($value) - { - $this->values['op_user_id'] = $value; - } - /** - * 获取操作员帐号, 默认为商户号的值 - * @return 值 - **/ - public function GetOp_user_id() - { - return $this->values['op_user_id']; - } - /** - * 判断操作员帐号, 默认为商户号是否存在 - * @return true 或 false - **/ - public function IsOp_user_idSet() - { - return array_key_exists('op_user_id', $this->values); - } -} - -/** - * - * 退款查询输入对象 - * @author widyhu - * - */ -class WxPayRefundQuery extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信支付分配的终端设备号 - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取微信支付分配的终端设备号的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断微信支付分配的终端设备号是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置微信订单号 - * @param string $value - **/ - public function SetTransaction_id($value) - { - $this->values['transaction_id'] = $value; - } - /** - * 获取微信订单号的值 - * @return 值 - **/ - public function GetTransaction_id() - { - return $this->values['transaction_id']; - } - /** - * 判断微信订单号是否存在 - * @return true 或 false - **/ - public function IsTransaction_idSet() - { - return array_key_exists('transaction_id', $this->values); - } - - - /** - * 设置商户系统内部的订单号 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置商户退款单号 - * @param string $value - **/ - public function SetOut_refund_no($value) - { - $this->values['out_refund_no'] = $value; - } - /** - * 获取商户退款单号的值 - * @return 值 - **/ - public function GetOut_refund_no() - { - return $this->values['out_refund_no']; - } - /** - * 判断商户退款单号是否存在 - * @return true 或 false - **/ - public function IsOut_refund_noSet() - { - return array_key_exists('out_refund_no', $this->values); - } - - - /** - * 设置微信退款单号refund_id、out_refund_no、out_trade_no、transaction_id四个参数必填一个,如果同时存在优先级为:refund_id>out_refund_no>transaction_id>out_trade_no - * @param string $value - **/ - public function SetRefund_id($value) - { - $this->values['refund_id'] = $value; - } - /** - * 获取微信退款单号refund_id、out_refund_no、out_trade_no、transaction_id四个参数必填一个,如果同时存在优先级为:refund_id>out_refund_no>transaction_id>out_trade_no的值 - * @return 值 - **/ - public function GetRefund_id() - { - return $this->values['refund_id']; - } - /** - * 判断微信退款单号refund_id、out_refund_no、out_trade_no、transaction_id四个参数必填一个,如果同时存在优先级为:refund_id>out_refund_no>transaction_id>out_trade_no是否存在 - * @return true 或 false - **/ - public function IsRefund_idSet() - { - return array_key_exists('refund_id', $this->values); - } -} - -/** - * - * 下载对账单输入对象 - * @author widyhu - * - */ -class WxPayDownloadBill extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信支付分配的终端设备号,填写此字段,只下载该设备号的对账单 - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取微信支付分配的终端设备号,填写此字段,只下载该设备号的对账单的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断微信支付分配的终端设备号,填写此字段,只下载该设备号的对账单是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置下载对账单的日期,格式:20140603 - * @param string $value - **/ - public function SetBill_date($value) - { - $this->values['bill_date'] = $value; - } - /** - * 获取下载对账单的日期,格式:20140603的值 - * @return 值 - **/ - public function GetBill_date() - { - return $this->values['bill_date']; - } - /** - * 判断下载对账单的日期,格式:20140603是否存在 - * @return true 或 false - **/ - public function IsBill_dateSet() - { - return array_key_exists('bill_date', $this->values); - } - - - /** - * 设置ALL,返回当日所有订单信息,默认值SUCCESS,返回当日成功支付的订单REFUND,返回当日退款订单REVOKED,已撤销的订单 - * @param string $value - **/ - public function SetBill_type($value) - { - $this->values['bill_type'] = $value; - } - /** - * 获取ALL,返回当日所有订单信息,默认值SUCCESS,返回当日成功支付的订单REFUND,返回当日退款订单REVOKED,已撤销的订单的值 - * @return 值 - **/ - public function GetBill_type() - { - return $this->values['bill_type']; - } - /** - * 判断ALL,返回当日所有订单信息,默认值SUCCESS,返回当日成功支付的订单REFUND,返回当日退款订单REVOKED,已撤销的订单是否存在 - * @return true 或 false - **/ - public function IsBill_typeSet() - { - return array_key_exists('bill_type', $this->values); - } -} - -/** - * - * 测速上报输入对象 - * @author widyhu - * - */ -class WxPayReport extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信支付分配的终端设备号,商户自定义 - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取微信支付分配的终端设备号,商户自定义的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断微信支付分配的终端设备号,商户自定义是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - - /** - * 设置上报对应的接口的完整URL,类似:https://api.mch.weixin.qq.com/pay/unifiedorder对于被扫支付,为更好的和商户共同分析一次业务行为的整体耗时情况,对于两种接入模式,请都在门店侧对一次被扫行为进行一次单独的整体上报,上报URL指定为:https://api.mch.weixin.qq.com/pay/micropay/total关于两种接入模式具体可参考本文档章节:被扫支付商户接入模式其它接口调用仍然按照调用一次,上报一次来进行。 - * @param string $value - **/ - public function SetInterface_url($value) - { - $this->values['interface_url'] = $value; - } - /** - * 获取上报对应的接口的完整URL,类似:https://api.mch.weixin.qq.com/pay/unifiedorder对于被扫支付,为更好的和商户共同分析一次业务行为的整体耗时情况,对于两种接入模式,请都在门店侧对一次被扫行为进行一次单独的整体上报,上报URL指定为:https://api.mch.weixin.qq.com/pay/micropay/total关于两种接入模式具体可参考本文档章节:被扫支付商户接入模式其它接口调用仍然按照调用一次,上报一次来进行。的值 - * @return 值 - **/ - public function GetInterface_url() - { - return $this->values['interface_url']; - } - /** - * 判断上报对应的接口的完整URL,类似:https://api.mch.weixin.qq.com/pay/unifiedorder对于被扫支付,为更好的和商户共同分析一次业务行为的整体耗时情况,对于两种接入模式,请都在门店侧对一次被扫行为进行一次单独的整体上报,上报URL指定为:https://api.mch.weixin.qq.com/pay/micropay/total关于两种接入模式具体可参考本文档章节:被扫支付商户接入模式其它接口调用仍然按照调用一次,上报一次来进行。是否存在 - * @return true 或 false - **/ - public function IsInterface_urlSet() - { - return array_key_exists('interface_url', $this->values); - } - - - /** - * 设置接口耗时情况,单位为毫秒 - * @param string $value - **/ - public function SetExecute_time_($value) - { - $this->values['execute_time_'] = $value; - } - /** - * 获取接口耗时情况,单位为毫秒的值 - * @return 值 - **/ - public function GetExecute_time_() - { - return $this->values['execute_time_']; - } - /** - * 判断接口耗时情况,单位为毫秒是否存在 - * @return true 或 false - **/ - public function IsExecute_time_Set() - { - return array_key_exists('execute_time_', $this->values); - } - - - /** - * 设置SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看trade_state来判断 - * @param string $value - **/ - public function SetReturn_code($value) - { - $this->values['return_code'] = $value; - } - /** - * 获取SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看trade_state来判断的值 - * @return 值 - **/ - public function GetReturn_code() - { - return $this->values['return_code']; - } - /** - * 判断SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查看trade_state来判断是否存在 - * @return true 或 false - **/ - public function IsReturn_codeSet() - { - return array_key_exists('return_code', $this->values); - } - - - /** - * 设置返回信息,如非空,为错误原因签名失败参数格式校验错误 - * @param string $value - **/ - public function SetReturn_msg($value) - { - $this->values['return_msg'] = $value; - } - /** - * 获取返回信息,如非空,为错误原因签名失败参数格式校验错误的值 - * @return 值 - **/ - public function GetReturn_msg() - { - return $this->values['return_msg']; - } - /** - * 判断返回信息,如非空,为错误原因签名失败参数格式校验错误是否存在 - * @return true 或 false - **/ - public function IsReturn_msgSet() - { - return array_key_exists('return_msg', $this->values); - } - - - /** - * 设置SUCCESS/FAIL - * @param string $value - **/ - public function SetResult_code($value) - { - $this->values['result_code'] = $value; - } - /** - * 获取SUCCESS/FAIL的值 - * @return 值 - **/ - public function GetResult_code() - { - return $this->values['result_code']; - } - /** - * 判断SUCCESS/FAIL是否存在 - * @return true 或 false - **/ - public function IsResult_codeSet() - { - return array_key_exists('result_code', $this->values); - } - - - /** - * 设置ORDERNOTEXIST—订单不存在SYSTEMERROR—系统错误 - * @param string $value - **/ - public function SetErr_code($value) - { - $this->values['err_code'] = $value; - } - /** - * 获取ORDERNOTEXIST—订单不存在SYSTEMERROR—系统错误的值 - * @return 值 - **/ - public function GetErr_code() - { - return $this->values['err_code']; - } - /** - * 判断ORDERNOTEXIST—订单不存在SYSTEMERROR—系统错误是否存在 - * @return true 或 false - **/ - public function IsErr_codeSet() - { - return array_key_exists('err_code', $this->values); - } - - - /** - * 设置结果信息描述 - * @param string $value - **/ - public function SetErr_code_des($value) - { - $this->values['err_code_des'] = $value; - } - /** - * 获取结果信息描述的值 - * @return 值 - **/ - public function GetErr_code_des() - { - return $this->values['err_code_des']; - } - /** - * 判断结果信息描述是否存在 - * @return true 或 false - **/ - public function IsErr_code_desSet() - { - return array_key_exists('err_code_des', $this->values); - } - - - /** - * 设置商户系统内部的订单号,商户可以在上报时提供相关商户订单号方便微信支付更好的提高服务质量。 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,商户可以在上报时提供相关商户订单号方便微信支付更好的提高服务质量。 的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,商户可以在上报时提供相关商户订单号方便微信支付更好的提高服务质量。 是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置发起接口调用时的机器IP - * @param string $value - **/ - public function SetUser_ip($value) - { - $this->values['user_ip'] = $value; - } - /** - * 获取发起接口调用时的机器IP 的值 - * @return 值 - **/ - public function GetUser_ip() - { - return $this->values['user_ip']; - } - /** - * 判断发起接口调用时的机器IP 是否存在 - * @return true 或 false - **/ - public function IsUser_ipSet() - { - return array_key_exists('user_ip', $this->values); - } - - - /** - * 设置系统时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则 - * @param string $value - **/ - public function SetTime($value) - { - $this->values['time'] = $value; - } - /** - * 获取系统时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则的值 - * @return 值 - **/ - public function GetTime() - { - return $this->values['time']; - } - /** - * 判断系统时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则是否存在 - * @return true 或 false - **/ - public function IsTimeSet() - { - return array_key_exists('time', $this->values); - } -} - -/** - * - * 短链转换输入对象 - * @author widyhu - * - */ -class WxPayShortUrl extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置需要转换的URL,签名用原串,传输需URL encode - * @param string $value - **/ - public function SetLong_url($value) - { - $this->values['long_url'] = $value; - } - /** - * 获取需要转换的URL,签名用原串,传输需URL encode的值 - * @return 值 - **/ - public function GetLong_url() - { - return $this->values['long_url']; - } - /** - * 判断需要转换的URL,签名用原串,传输需URL encode是否存在 - * @return true 或 false - **/ - public function IsLong_urlSet() - { - return array_key_exists('long_url', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } -} - -/** - * - * 提交被扫输入对象 - * @author widyhu - * - */ -class WxPayMicroPay extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置终端设备号(商户自定义,如门店编号) - * @param string $value - **/ - public function SetDevice_info($value) - { - $this->values['device_info'] = $value; - } - /** - * 获取终端设备号(商户自定义,如门店编号)的值 - * @return 值 - **/ - public function GetDevice_info() - { - return $this->values['device_info']; - } - /** - * 判断终端设备号(商户自定义,如门店编号)是否存在 - * @return true 或 false - **/ - public function IsDevice_infoSet() - { - return array_key_exists('device_info', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置商品或支付单简要描述 - * @param string $value - **/ - public function SetBody($value) - { - $this->values['body'] = $value; - } - /** - * 获取商品或支付单简要描述的值 - * @return 值 - **/ - public function GetBody() - { - return $this->values['body']; - } - /** - * 判断商品或支付单简要描述是否存在 - * @return true 或 false - **/ - public function IsBodySet() - { - return array_key_exists('body', $this->values); - } - - - /** - * 设置商品名称明细列表 - * @param string $value - **/ - public function SetDetail($value) - { - $this->values['detail'] = $value; - } - /** - * 获取商品名称明细列表的值 - * @return 值 - **/ - public function GetDetail() - { - return $this->values['detail']; - } - /** - * 判断商品名称明细列表是否存在 - * @return true 或 false - **/ - public function IsDetailSet() - { - return array_key_exists('detail', $this->values); - } - - - /** - * 设置附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 - * @param string $value - **/ - public function SetAttach($value) - { - $this->values['attach'] = $value; - } - /** - * 获取附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据的值 - * @return 值 - **/ - public function GetAttach() - { - return $this->values['attach']; - } - /** - * 判断附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据是否存在 - * @return true 或 false - **/ - public function IsAttachSet() - { - return array_key_exists('attach', $this->values); - } - - - /** - * 设置商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置订单总金额,单位为分,只能为整数,详见支付金额 - * @param string $value - **/ - public function SetTotal_fee($value) - { - $this->values['total_fee'] = $value; - } - /** - * 获取订单总金额,单位为分,只能为整数,详见支付金额的值 - * @return 值 - **/ - public function GetTotal_fee() - { - return $this->values['total_fee']; - } - /** - * 判断订单总金额,单位为分,只能为整数,详见支付金额是否存在 - * @return true 或 false - **/ - public function IsTotal_feeSet() - { - return array_key_exists('total_fee', $this->values); - } - - - /** - * 设置符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 - * @param string $value - **/ - public function SetFee_type($value) - { - $this->values['fee_type'] = $value; - } - /** - * 获取符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型的值 - * @return 值 - **/ - public function GetFee_type() - { - return $this->values['fee_type']; - } - /** - * 判断符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型是否存在 - * @return true 或 false - **/ - public function IsFee_typeSet() - { - return array_key_exists('fee_type', $this->values); - } - - - /** - * 设置调用微信支付API的机器IP - * @param string $value - **/ - public function SetSpbill_create_ip($value) - { - $this->values['spbill_create_ip'] = $value; - } - /** - * 获取调用微信支付API的机器IP 的值 - * @return 值 - **/ - public function GetSpbill_create_ip() - { - return $this->values['spbill_create_ip']; - } - /** - * 判断调用微信支付API的机器IP 是否存在 - * @return true 或 false - **/ - public function IsSpbill_create_ipSet() - { - return array_key_exists('spbill_create_ip', $this->values); - } - - /** - * 设置订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。详见时间规则 - * @param string $value - **/ - public function SetTime_start($value) - { - $this->values['time_start'] = $value; - } - /** - * 获取订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。详见时间规则的值 - * @return 值 - **/ - public function GetTime_start() - { - return $this->values['time_start']; - } - /** - * 判断订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。详见时间规则是否存在 - * @return true 或 false - **/ - public function IsTime_startSet() - { - return array_key_exists('time_start', $this->values); - } - - - /** - * 设置订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。详见时间规则 - * @param string $value - **/ - public function SetTime_expire($value) - { - $this->values['time_expire'] = $value; - } - /** - * 获取订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。详见时间规则的值 - * @return 值 - **/ - public function GetTime_expire() - { - return $this->values['time_expire']; - } - /** - * 判断订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。详见时间规则是否存在 - * @return true 或 false - **/ - public function IsTime_expireSet() - { - return array_key_exists('time_expire', $this->values); - } - - - /** - * 设置商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠 - * @param string $value - **/ - public function SetGoods_tag($value) - { - $this->values['goods_tag'] = $value; - } - /** - * 获取商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠的值 - * @return 值 - **/ - public function GetGoods_tag() - { - return $this->values['goods_tag']; - } - /** - * 判断商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠是否存在 - * @return true 或 false - **/ - public function IsGoods_tagSet() - { - return array_key_exists('goods_tag', $this->values); - } - - - /** - * 设置扫码支付授权码,设备读取用户微信中的条码或者二维码信息 - * @param string $value - **/ - public function SetAuth_code($value) - { - $this->values['auth_code'] = $value; - } - /** - * 获取扫码支付授权码,设备读取用户微信中的条码或者二维码信息的值 - * @return 值 - **/ - public function GetAuth_code() - { - return $this->values['auth_code']; - } - /** - * 判断扫码支付授权码,设备读取用户微信中的条码或者二维码信息是否存在 - * @return true 或 false - **/ - public function IsAuth_codeSet() - { - return array_key_exists('auth_code', $this->values); - } -} - -/** - * - * 撤销输入对象 - * @author widyhu - * - */ -class WxPayReverse extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - - /** - * 设置微信的订单号,优先使用 - * @param string $value - **/ - public function SetTransaction_id($value) - { - $this->values['transaction_id'] = $value; - } - /** - * 获取微信的订单号,优先使用的值 - * @return 值 - **/ - public function GetTransaction_id() - { - return $this->values['transaction_id']; - } - /** - * 判断微信的订单号,优先使用是否存在 - * @return true 或 false - **/ - public function IsTransaction_idSet() - { - return array_key_exists('transaction_id', $this->values); - } - - - /** - * 设置商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no - * @param string $value - **/ - public function SetOut_trade_no($value) - { - $this->values['out_trade_no'] = $value; - } - /** - * 获取商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no的值 - * @return 值 - **/ - public function GetOut_trade_no() - { - return $this->values['out_trade_no']; - } - /** - * 判断商户系统内部的订单号,transaction_id、out_trade_no二选一,如果同时存在优先级:transaction_id> out_trade_no是否存在 - * @return true 或 false - **/ - public function IsOut_trade_noSet() - { - return array_key_exists('out_trade_no', $this->values); - } - - - /** - * 设置随机字符串,不长于32位。推荐随机数生成算法 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串,不长于32位。推荐随机数生成算法的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串,不长于32位。推荐随机数生成算法是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } -} - -/** - * - * 提交JSAPI输入对象 - * @author widyhu - * - */ -class WxPayJsApiPay extends WxPayDataBase -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appId'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appId']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appId', $this->values); - } - - - /** - * 设置支付时间戳 - * @param string $value - **/ - public function SetTimeStamp($value) - { - $this->values['timeStamp'] = $value; - } - /** - * 获取支付时间戳的值 - * @return 值 - **/ - public function GetTimeStamp() - { - return $this->values['timeStamp']; - } - /** - * 判断支付时间戳是否存在 - * @return true 或 false - **/ - public function IsTimeStampSet() - { - return array_key_exists('timeStamp', $this->values); - } - - /** - * 随机字符串 - * @param string $value - **/ - public function SetNonceStr($value) - { - $this->values['nonceStr'] = $value; - } - /** - * 获取notify随机字符串值 - * @return 值 - **/ - public function GetReturn_code() - { - return $this->values['nonceStr']; - } - /** - * 判断随机字符串是否存在 - * @return true 或 false - **/ - public function IsReturn_codeSet() - { - return array_key_exists('nonceStr', $this->values); - } - - - /** - * 设置订单详情扩展字符串 - * @param string $value - **/ - public function SetPackage($value) - { - $this->values['package'] = $value; - } - /** - * 获取订单详情扩展字符串的值 - * @return 值 - **/ - public function GetPackage() - { - return $this->values['package']; - } - /** - * 判断订单详情扩展字符串是否存在 - * @return true 或 false - **/ - public function IsPackageSet() - { - return array_key_exists('package', $this->values); - } - - /** - * 设置签名方式 - * @param string $value - **/ - public function SetSignType($value) - { - $this->values['signType'] = $value; - } - /** - * 获取签名方式 - * @return 值 - **/ - public function GetSignType() - { - return $this->values['signType']; - } - /** - * 判断签名方式是否存在 - * @return true 或 false - **/ - public function IsSignTypeSet() - { - return array_key_exists('signType', $this->values); - } - - /** - * 设置签名方式 - * @param string $value - **/ - public function SetPaySign($value) - { - $this->values['paySign'] = $value; - } - /** - * 获取签名方式 - * @return 值 - **/ - public function GetPaySign() - { - return $this->values['paySign']; - } - /** - * 判断签名方式是否存在 - * @return true 或 false - **/ - public function IsPaySignSet() - { - return array_key_exists('paySign', $this->values); - } -} - -/** - * - * 扫码支付模式一生成二维码参数 - * @author widyhu - * - */ -class WxPayBizPayUrl extends WxPayDataBaseSignMd5 -{ - /** - * 设置微信分配的公众账号ID - * @param string $value - **/ - public function SetAppid($value) - { - $this->values['appid'] = $value; - } - /** - * 获取微信分配的公众账号ID的值 - * @return 值 - **/ - public function GetAppid() - { - return $this->values['appid']; - } - /** - * 判断微信分配的公众账号ID是否存在 - * @return true 或 false - **/ - public function IsAppidSet() - { - return array_key_exists('appid', $this->values); - } - - - /** - * 设置微信支付分配的商户号 - * @param string $value - **/ - public function SetMch_id($value) - { - $this->values['mch_id'] = $value; - } - /** - * 获取微信支付分配的商户号的值 - * @return 值 - **/ - public function GetMch_id() - { - return $this->values['mch_id']; - } - /** - * 判断微信支付分配的商户号是否存在 - * @return true 或 false - **/ - public function IsMch_idSet() - { - return array_key_exists('mch_id', $this->values); - } - - /** - * 设置支付时间戳 - * @param string $value - **/ - public function SetTime_stamp($value) - { - $this->values['time_stamp'] = $value; - } - /** - * 获取支付时间戳的值 - * @return 值 - **/ - public function GetTime_stamp() - { - return $this->values['time_stamp']; - } - /** - * 判断支付时间戳是否存在 - * @return true 或 false - **/ - public function IsTime_stampSet() - { - return array_key_exists('time_stamp', $this->values); - } - - /** - * 设置随机字符串 - * @param string $value - **/ - public function SetNonce_str($value) - { - $this->values['nonce_str'] = $value; - } - /** - * 获取随机字符串的值 - * @return 值 - **/ - public function GetNonce_str() - { - return $this->values['nonce_str']; - } - /** - * 判断随机字符串是否存在 - * @return true 或 false - **/ - public function IsNonce_strSet() - { - return array_key_exists('nonce_str', $this->values); - } - - /** - * 设置商品ID - * @param string $value - **/ - public function SetProduct_id($value) - { - $this->values['product_id'] = $value; - } - /** - * 获取商品ID的值 - * @return 值 - **/ - public function GetProduct_id() - { - return $this->values['product_id']; - } - /** - * 判断商品ID是否存在 - * @return true 或 false - **/ - public function IsProduct_idSet() - { - return array_key_exists('product_id', $this->values); - } -} - diff --git a/public/php_sdk_v3.0.10/lib/WxPay.Exception.php b/public/php_sdk_v3.0.10/lib/WxPay.Exception.php deleted file mode 100755 index 98c91e506..000000000 --- a/public/php_sdk_v3.0.10/lib/WxPay.Exception.php +++ /dev/null @@ -1,13 +0,0 @@ -getMessage(); - } -} diff --git a/public/php_sdk_v3.0.10/lib/WxPay.Notify.php b/public/php_sdk_v3.0.10/lib/WxPay.Notify.php deleted file mode 100755 index 3ce91d647..000000000 --- a/public/php_sdk_v3.0.10/lib/WxPay.Notify.php +++ /dev/null @@ -1,105 +0,0 @@ -config = $config; - $msg = "OK"; - //当返回false的时候,表示notify中调用NotifyCallBack回调失败获取签名校验失败,此时直接回复失败 - $result = WxpayApi::notify($config, array($this, 'NotifyCallBack'), $msg); - if($result == false){ - $this->SetReturn_code("FAIL"); - $this->SetReturn_msg($msg); - $this->ReplyNotify(false); - return; - } else { - //该分支在成功回调到NotifyCallBack方法,处理完成之后流程 - $this->SetReturn_code("SUCCESS"); - $this->SetReturn_msg("OK"); - } - $this->ReplyNotify($needSign); - } - - /** - * - * 回调方法入口,子类可重写该方法 - //TODO 1、进行参数校验 - //TODO 2、进行签名验证 - //TODO 3、处理业务逻辑 - * 注意: - * 1、微信回调超时时间为2s,建议用户使用异步处理流程,确认成功之后立刻回复微信服务器 - * 2、微信服务器在调用失败或者接到回包为非确认包的时候,会发起重试,需确保你的回调是可以重入 - * @param WxPayNotifyResults $objData 回调解释出的参数 - * @param WxPayConfigInterface $config - * @param string $msg 如果回调处理失败,可以将错误信息输出到该方法 - * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 - */ - public function NotifyProcess($objData, $config, &$msg) - { - //TODO 用户基础该类之后需要重写该方法,成功的时候返回true,失败返回false - return false; - } - - /** - * - * 业务可以继承该方法,打印XML方便定位. - * @param string $xmlData 返回的xml参数 - * - **/ - public function LogAfterProcess($xmlData) - { - return; - } - - /** - * - * notify回调方法,该方法中需要赋值需要输出的参数,不可重写 - * @param array $data - * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调 - */ - final public function NotifyCallBack($data) - { - $msg = "OK"; - $result = $this->NotifyProcess($data, $this->config, $msg); - - if($result == true){ - $this->SetReturn_code("SUCCESS"); - $this->SetReturn_msg("OK"); - } else { - $this->SetReturn_code("FAIL"); - $this->SetReturn_msg($msg); - } - return $result; - } - - /** - * - * 回复通知 - * @param bool $needSign 是否需要签名输出 - */ - final private function ReplyNotify($needSign = true) - { - //如果需要签名 - if($needSign == true && - $this->GetReturn_code() == "SUCCESS") - { - $this->SetSign($this->config); - } - - $xml = $this->ToXml(); - $this->LogAfterProcess($xml); - WxpayApi::replyNotify($xml); - } -} \ No newline at end of file