对于 lokielse/omnipay-alipay 功能扩展,新增无密退款及 readme 详细示例 (支付 / 退款 (有密,无密) / 支付回调 / 退款回调)

对于lokielse/omnipay-alipay功能扩展,新增无密退款及readme详细示例(支付 / 退款(有密,无密) / 支付回调 / 退款回调)
jacky-zeng/omnipay-alipay

使用有密退款

   $gateway = Omnipay::create('Alipay_LegacyExpress');
    $gateway->setSignType($sign_type); 
    $gateway->setReturnUrl($return_url);
    $gateway->setNotifyUrl($notify_url);
    $gateway->setSellerEmail($seller_email);
    $gateway->setPartner($partner);
    $gateway->setKey($key); 
    $data = [
            'refund_date' => date('Y-m-d H:i:s'),
            "seller_user_id"  => trim($seller_id),
            'batch_no'=> date('Ymd') . substr($r_order['third_part_order_id'], 8),
            'batch_num' => 1,//退款笔数与refund_items数组中保持一致
            '_input_charset' => 'UTF-8',
            'refund_items'=> [
                [
                    'out_trade_no' => $r_order['third_part_order_id'],
                    'amount' => $r_order['amount']/100.0,
                    'reason' => 'Userrefund'
                ]
            ],
        ];    
     $request = $gateway->refund($data);
     $response = $request->send();
     $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发出即可收到支付宝的返回值

gaodevops