$alipay_config['service'],
'partner' => $alipay_config['partner'],
'notify_url' => ROOT_URL . 'api/pay/' . $data['type'] . '/pc_notify_url.php',
'seller_user_id' => $alipay_config['seller_id'],
'refund_date' => date('Y-m-d H:i:s'),
'batch_no' => $batch_no,
'batch_num' => $batch_num,
'detail_data' => $detail_data,
'_input_charset' => trim(strtolower($alipay_config['input_charset'])),
];
$alipaySubmit = new AlipaySubmit($alipay_config);
$url = $alipaySubmit->alipay_gateway_new . $alipaySubmit->buildRequestParaToString($parameter);
$response = '';
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = (string)curl_exec($ch);
curl_close($ch);
} else {
$response = (string)@file_get_contents($url);
}
// 成功时一般为 XML,含 T
if ($response && (stripos($response, 'T') !== false || stripos($response, 't') !== false)) {
$return = dr_return_data(1, dr_lang('退款成功'), [
'batch_no' => $batch_no,
'trade_no' => $trade_no,
'response' => $response,
]);
} else {
$msg = dr_lang('支付宝退款失败');
if ($response && preg_match('/([^<]+)<\/error>/i', $response, $m)) {
$msg = $m[1];
} elseif ($response && preg_match('/([^<]+)<\/msg>/i', $response, $m)) {
$msg = $m[1];
}
$return = dr_return_data(0, $msg, ['response' => $response, 'batch_no' => $batch_no]);
}
}