PayApi.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. $result = $this->post($this->apiUrl . '/notify', $data);
  30. if ($result['code'] == 1) {
  31. return $this->returnArray(1, $result['data'], $result['message']);
  32. } else {
  33. return $this->returnArray(0, $result['data'], $result['message']);
  34. }
  35. }
  36. /**
  37. * 同步回调
  38. * @param array $data
  39. * @param int $payType
  40. * @return array
  41. */
  42. public function callReturn($data, $payType)
  43. {
  44. !isset($data['payType']) && $data['payType'] = $payType;
  45. $result = $this->post($this->apiUrl . '/return', $data);
  46. if ($result['code'] == 1) {
  47. return $this->returnArray(1, $result['data'], $result['message']);
  48. } else {
  49. return $this->returnArray(0, $result['data'], $result['message']);
  50. }
  51. }
  52. /**
  53. * 更新銀行數據庫的金額
  54. * @param array $data
  55. * @return array
  56. */
  57. public function callUpdata($data)
  58. {
  59. $result = $this->post($this->apiUrl . '/updata', $data); //发起请求
  60. if ($result['code'] == 1) {
  61. return $this->returnArray(1, $result['data'], $result['message']);
  62. } else {
  63. return $this->returnArray(0, $result['data'], $result['message']);
  64. }
  65. }
  66. /**
  67. * 获取銀行數據庫的金額
  68. * @param array $data
  69. * @return array
  70. */
  71. public function callGetmoney($data)
  72. {
  73. $result = $this->post($this->apiUrl . '/getmoney', $data); //发起请求
  74. if ($result['code'] == 1) {
  75. return $this->returnArray(1, $result['data'], $result['message']);
  76. } else {
  77. return $this->returnArray(0, $result['data'], $result['message']);
  78. }
  79. }
  80. }