WxPay.NativePay.php 722 B

123456789101112131415161718192021222324252627282930313233
  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. ?>