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發出即可收到支付寶的返回值