PayApi.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace backend\models;
  3. class PayApi extends BaseApi
  4. {
  5. public $apiUrl = 'pay';
  6. /**
  7. * 支付
  8. * @param array $data
  9. * @return array
  10. */
  11. public function outPay($data)
  12. {
  13. $result = $this->post($this->apiUrl . '/outpay', $data);
  14. if ($result['code'] == 1) {
  15. return $this->returnArray(1, $result['data'], 'OK');
  16. } else {
  17. return $this->returnArray(0, [], $result['message']);
  18. }
  19. }
  20. /**
  21. * 异步回调
  22. * @param array $data
  23. * @param int $payType
  24. * @return array
  25. */
  26. public function callNotify($data, $payType)
  27. {
  28. !isset($data['payType']) && $data['payType'] = $payType;
  29. file_put_contents('huiqi2.txt',$payType);
  30. $result = $this->post($this->apiUrl . '/notify', $data);
  31. if ($result['code'] == 1) {
  32. return $this->returnArray(1, $result['data'], $result['message']);
  33. } else {
  34. return $this->returnArray(0, $result['data'], $result['message']);
  35. }
  36. }
  37. /**
  38. * 同步回调
  39. * @param array $data
  40. * @param int $payType
  41. * @return array
  42. */
  43. public function callReturn($data, $payType)
  44. {
  45. !isset($data['payType']) && $data['payType'] = $payType;
  46. $result = $this->post($this->apiUrl . '/return', $data);
  47. if ($result['code'] == 1) {
  48. return $this->returnArray(1, $result['data'], $result['message']);
  49. } else {
  50. return $this->returnArray(0, $result['data'], $result['message']);
  51. }
  52. }
  53. /**
  54. * 更新銀行數據庫的金額
  55. * @param array $data
  56. * @return array
  57. */
  58. public function callUpdata($data)
  59. {
  60. $result = $this->post($this->apiUrl . '/updata', $data); //发起请求
  61. if ($result['code'] == 1) {
  62. return $this->returnArray(1, $result['data'], $result['message']);
  63. } else {
  64. return $this->returnArray(0, $result['data'], $result['message']);
  65. }
  66. }
  67. /**
  68. * 获取銀行數據庫的金額
  69. * @param array $data
  70. * @return array
  71. */
  72. public function callGetmoney($data)
  73. {
  74. $result = $this->post($this->apiUrl . '/getmoney', $data); //发起请求
  75. if ($result['code'] == 1) {
  76. return $this->returnArray(1, $result['data'], $result['message']);
  77. } else {
  78. return $this->returnArray(0, $result['data'], $result['message']);
  79. }
  80. }
  81. }