| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace Aix\Pay\Contracts;
- use Aix\Pay\Data\PayOrder;
- use Yansongda\Pay\Pay;
- class AliPay implements PayInterface
- {
- protected $alipay;
- protected $config = [
- 'app_id' => '',
- 'notify_url' => '',
- 'return_url' => '',
- 'ali_public_key' => '',
- 'private_key' => '',
- 'log' => [ // optional
- 'file' => './logs/alipay/alipay.log',
- 'level' => 'debug', // 建议生产环境等级调整为 info,开发环境为 debug
- 'type' => 'daily', // optional, 可选 daily.
- 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
- ],
- ];
- /**
- * AliPay constructor.
- */
- public function __construct()
- {
- $this->config['app_id']=config('aix.system.pay.alipay.app_id');
- $this->config['notify_url']=route('payhook.ali');
- $this->config['ali_public_key']=config('aix.system.pay.alipay.ali_public_key');
- $this->config['private_key']=config('aix.system.pay.alipay.private_key');
- $this->config['log']['file']=storage_path('logs/alipay.log');
- $this->alipay=Pay::alipay($this->config);
- }
- /**
- * 扫码支付
- * @param PayOrder $payOrder
- * @return mixed
- */
- public function scan(PayOrder $payOrder)
- {
- $order = [
- 'out_trade_no' => $payOrder->trade_no.time(),
- 'total_amount' => $payOrder->price,
- 'subject' => $payOrder->subject,
- 'body' => $payOrder->detail,
- ];
- return $this->alipay->scan($order);
- }
- public function web(PayOrder $payOrder)
- {
- $order = [
- 'out_trade_no' => $payOrder->trade_no.time(),
- 'total_amount' => $payOrder->price,
- 'subject' => $payOrder->subject,
- 'body' => $payOrder->detail,
- 'return_url' => $payOrder->return_url,
- ];
- return $this->alipay->web($order);
- }
- /**
- * 回调验签
- * @return mixed
- * @throws \Yansongda\Pay\Exceptions\InvalidArgumentException
- * @throws \Yansongda\Pay\Exceptions\InvalidConfigException
- * @throws \Yansongda\Pay\Exceptions\InvalidSignException
- */
- public function verify()
- {
- return $this->alipay->verify();
- }
- /**
- * 回调回复
- * @return mixed
- */
- public function success()
- {
- return $this->alipay->success();
- }
- /**
- * 手机网页支付
- * @param PayOrder $payOrder
- * @return mixed
- */
- public function wap(PayOrder $payOrder)
- {
- $order = [
- 'out_trade_no' => $payOrder->trade_no.time(),
- 'total_amount' => $payOrder->price,
- 'subject' => $payOrder->subject,
- 'body' => $payOrder->detail,
- 'return_url' => $payOrder->return_url,
- ];
- return $this->alipay->wap($order);
- }
- }
|