WxPay.NativePay.php 630 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class NativePay
  3. {
  4. public function GetPrePayUrl($productId)
  5. {
  6. $biz = new WxPayBizPayUrl();
  7. $biz->SetProduct_id($productId);
  8. $values = WxpayApi::bizpayurl($biz);
  9. $url = 'weixin://wxpay/bizpayurl?' . $this->ToUrlParams($values);
  10. return $url;
  11. }
  12. private function ToUrlParams($urlObj)
  13. {
  14. $buff = '';
  15. foreach ($urlObj as $k => $v) {
  16. $buff .= $k . '=' . $v . '&';
  17. }
  18. $buff = trim($buff, '&');
  19. return $buff;
  20. }
  21. public function GetPayUrl($input)
  22. {
  23. if ($input->GetTrade_type() == 'NATIVE') {
  24. $result = WxPayApi::unifiedOrder($input);
  25. return $result;
  26. }
  27. }
  28. }
  29. require_once 'WxPay.Api.php';
  30. ?>