码迷,mamicode.com
首页 > 其他好文 > 详细

lokielse/omnipay-alipay 即时到账退款

时间:2017-06-24 16:26:47      阅读:769      评论:0      收藏:0      [点我收藏+]

标签:重命名   gac   退款   use   []   文件   function   div   sel   

  

 1        使用有密退款
 2        $gateway = Omnipay::create(‘Alipay_LegacyExpress‘);
 3         $gateway->setSignType($sign_type); 
 4         $gateway->setReturnUrl($return_url);
 5         $gateway->setNotifyUrl($notify_url);
 6         $gateway->setSellerEmail($seller_email);
 7         $gateway->setPartner($partner);
 8         $gateway->setKey($key); 
 9         $data = [
10                 ‘refund_date‘ => date(‘Y-m-d H:i:s‘),
11                 "seller_user_id"  => trim($seller_id),
12                 ‘batch_no‘=> date(‘Ymd‘) . substr($r_order[‘third_part_order_id‘], 8),
13                 ‘batch_num‘ => 1,//退款笔数与refund_items数组中保持一致
14                 ‘_input_charset‘ => ‘UTF-8‘,
15                 ‘refund_items‘=> [
16                     [
17                         ‘out_trade_no‘ => $r_order[‘third_part_order_id‘],
18                         ‘amount‘ => $r_order[‘amount‘]/100.0,
19                         ‘reason‘ => ‘Userrefund‘
20                     ]
21                 ],
22             ];    
23          $request = $gateway->refund($data);
24          $response = $request->send();
25          $url = $response->getRedirectUrl();#在浏览器中打开此url就可以看到有密退款界面
此库中并没有提供即时到账无密退款服务 手动添加一把

1在LegacyAppGateway.php文件中加一个方法
   public function refundNoPwd(array $parameters = [])
    {
        return $this->createRequest(LegacyRefundNoPwdRequest::class, $parameters);
    }

2复制一份LegacyRefundRequest.php文件在当前目录下重命名为
LegacyRefundNoPwdRequest.php
3.把LegacyRefundNoPwdRequest.php文件中的
protect $server = ‘refund_fastpay_by_platform_pwd‘;
改为
protect  $server=‘refund_fastpay_by_platform_nopwd‘;

ok其他后续操作同有密退款 只需把生成的url用curl发出即可收到支付宝的返回值

 

lokielse/omnipay-alipay 即时到账退款

标签:重命名   gac   退款   use   []   文件   function   div   sel   

原文地址:http://www.cnblogs.com/a-flydog/p/7073542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!