|
|
|
|
@ -7,6 +7,7 @@ use Alipay\EasySDK\Kernel\Util\ResponseChecker;
|
|
|
|
|
use Alipay\EasySDK\Kernel\Config;
|
|
|
|
|
use App\Events\RechargeSucceed;
|
|
|
|
|
use App\Models\Recharge;
|
|
|
|
|
use App\Models\Refund;
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
|
|
class AlipayF2F
|
|
|
|
|
@ -51,6 +52,33 @@ class AlipayF2F
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function refund(Refund $refund) {
|
|
|
|
|
try {
|
|
|
|
|
$config = $this->getOptions();
|
|
|
|
|
$result = Factory::setOptions($config)::payment()
|
|
|
|
|
->common()
|
|
|
|
|
->refund($refund->serial,$refund->money);
|
|
|
|
|
$responseChecker = new ResponseChecker();
|
|
|
|
|
//处理响应或异常
|
|
|
|
|
if ($responseChecker->success($result)) {
|
|
|
|
|
$transaction_id = $result->tradeNo;
|
|
|
|
|
$update = [
|
|
|
|
|
"paid_at" => date("Y-m-d H:i:s"),
|
|
|
|
|
"payment_serial" => $transaction_id
|
|
|
|
|
];
|
|
|
|
|
$refund->update($update);
|
|
|
|
|
} else {
|
|
|
|
|
Log::info("支付宝退款失败:".$result->code.";".$result->msg);
|
|
|
|
|
$refund->increment("try_times");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
Log::info("支付宝退款失败:".$exception->getCode().";".$exception->getMessage());
|
|
|
|
|
$refund->increment("try_times");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getOptions()
|
|
|
|
|
{
|
|
|
|
|
$options = new Config();
|
|
|
|
|
|