virgo / alipay
alipay set
v1.0.10
2022-03-09 11:16 UTC
Requires
- php: >=7.2
- ext-bcmath: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-simplexml: *
- guzzlehttp/guzzle: 6.*|7.*
This package is not auto-updated.
Last update: 2025-03-06 05:27:42 UTC
README
alipay
$config = [
'APPID' => '202100********',
'APP_PRIVATE_KEY' => 'AE*******',
// 'APP_PRIVATE_KEY_FILE' => '',
'app_cert_path' => '',
'ALIPAY_PUBLIC_KEY' => '',
'RETURN_URL' => 'https://m.alipay.com/Gk8NF23',
'app_cert_path' => './crt/appCertPublicKey.crt',
'alipay_root_path' => './crt/alipayRootCert.crt',
'alipay_public_path' => './crt/alipayCertPublicKey_RSA2.crt',
'LOGS_DIR' => './logs',
];
$alipayFund = new \Alipay\AlipayFund\AlipayFund($config);
$alipayFund->setTimeout(10);
//$alipayFund->setCharset('utf-8');
//$alipayFund->setFormat('json');
//$alipayFund->setSignType('RSA2');
//$alipayFund->setVersion('1.0');
//批次下单
if (0) {
$batchNo = md5(uniqid());
//支付方
$payer = new \Alipay\AlipayFund\Info\Parties('208812*****41234', '黄龙国际有限公司');
//$payer->typeLogonId();
//$payer->typeUserId();
//收款方
$payeeList = new \Alipay\AlipayFund\Info\PayeeList();
$payee = new \Alipay\AlipayFund\Info\Parties('208812*****41234', '黄龙国际有限公司');
$payeeList->appendPayee($payee, md5(uniqid()), '0.01', '转账');
$payee1 = new \Alipay\AlipayFund\Info\Parties('208812*****41234', '黄龙国际有限公司2');
$payeeList->appendPayee($payee1, md5(uniqid()), '0.02', '转账');
$request = $alipayFund->batchCreate($payer, $payeeList, $batchNo, '转账标题');
$request->setAppAuthToken('');
$response = $alipayFund->execute($request);
var_dump(
$response->isSuccess(),
$response->getError(),
$response->getBody(),
$response->getBatchNo(),
$response->getBatchTransId(),
$response->getCode()
);
}
//批次支付
if (0) {
$batchTransId = '202001160013496991';
$request = $alipayFund->transPay($batchTransId);
$response = $alipayFund->execute($request);
var_dump($response->getBody()
);
}
//余额查询
if (0) {
$alipayUserId = '2088241***********';
$request = $alipayFund->accountQuery($alipayUserId);
/*** @var $response \Alipay\AlipayFund\Response\AlipayFundAccountQueryResponse */
$response = $alipayFund->execute($request);
var_dump($response->isSuccess(),
$response->getError(),
$response->getAvailableAmount(),
$response->getFreezeAmount()
);
}
//单笔转账
if (0) {
$batchNo = md5(uniqid());
//收款方
$payeeList = new \Alipay\AlipayFund\Info\PayeeList();
$amount = '0.1';
$payee = new \Alipay\AlipayFund\Info\Parties('zhifubao@qq.com', '收款人');
$payee->typeLogonId();
$request = $alipayFund->trans($batchNo, $amount, $payee, '代发');
/*** @var $response \Alipay\AlipayFund\Response\AlipayFundTransUniTransferResponse */
$response = $alipayFund->execute($request);
var_dump(
$response->isSuccess(),
$response->getOrderId(),
$response->getPayFundOrderId(),
$response->getError()
);
}
//电子保单申请
if (0) {
// $payFundOrderId = '20220309020070011500130007594491';
//
// $request = $alipayFund->batchEreceiptApply($payFundOrderId);
//
// /**
// * @var $response \Alipay\AlipayFund\Response\AlipayFundBatchBillEreceiptApplyResponse
// */
// $response = $alipayFund->execute($request);
// var_dump($response->isSuccess());
// var_dump($response->getError());
// var_dump($response->getFileId());
//
// $fileId = $response->getFileId();
$fileId = '209752782';
if (!$fileId) {
echo 222;
}
$request = $alipayFund->batchEreceiptQuery($fileId);
/**
* @var $response \Alipay\AlipayFund\Response\AlipayFundBatchBillEreceiptQueryResponse
*/
$response = $alipayFund->execute($request);
var_dump($response->isSuccess());
var_dump($response->getError());
var_dump($response->getDownloadUrl());
$url = $response->getDownloadUrl();
if ($url) {
$pdf = file_get_contents($url);
file_put_contents('./1.pdf', $pdf);
}
}