開發框架: laravel:8
通過composer下載: composer require yansongda/pay:^2
https:
alipay.fund.trans.uni.transfer 轉賬介面 ( 強制公鑰證照,下面配置中的 ali_public_key 引數 )
ERROR_GATEWAY: Get Alipay API Error:Invalid Arguments - isv.missing-app-cert-sn
ERROR_GATEWAY: Get Alipay API Error:Invalid Arguments - isv.invalid-signature
<?php
return [
'alipay' => [
'app_id' => '你的支付寶appid',
'sign_type' => 'RSA2',
'notify_url' => env("APP_URL").'/api/alipayMobileNotifyUrl',
'return_url' => env("APP_URL").'/api/alipayMobileNotifyUrl',
'ali_public_key' => "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmFD6E1wuPtgw3wTZSbH0xt3CaSs/CKDKMfcwDRvx2tCsMH8X8S7LH2SwsTZMfhg7o9TxQH2+UUJhJHNqogHtWNO9V7ocGhou46e/myyLFA1a3+bjpH2Z9Y5bDZT1YQdC0TVUCnUdwjYBdrLmBwJS6UAso+DPw6jJLjVjyOB14koCPXIaHziggG+y0p+Y6c+a43hrLvYkFzcI8kauc5NPZdiMJKT1orFe4WN1IIgHE+fvAsTqcioImjWY+OSaIgWmYJdbBHbBybkZ3NkyHcno4zxKw0Gd4fbX98sob6qPrKUuHsy7SJhYn8oeAVDi9VuPbQlsVo8OtvCnpT65LS7fL5wIDAQasAB",
'private_key'=>"MIIEowIBAAKCAQEAmFD6E1wuPtgw3wTZSbH0xt3CaSs/CKDKMfcwDRvx2tCsMH8X8S7LH2SwsTZMfhg7o9TxQH2+UUJhJHNqogHtWNO9V7ocGhou46e/myyLFA1a3+bjpH2Z9Y5bDZT1YQdC0TVUCnUdwjYBdrLmBwJS6UAso+DPw6jJLjVjyOB14koCPXIHziggG+y0p+Y6c+a43hrLvYkFzcI8kauc5NPZdiMJKT1orFe4WN1IIgHE+fvAsTqcioImjWYas+OSaIgWmYJdbBHbBybkZ3NkyHcno4zxKw0Gd4fbX98sob6qPrKUuHsy7SJhYn8oeAVDi9VuPbQlsVo8OdtvC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SjZcPIGJMTe8X2LtrdioFMZBMhhifdEDg6LeMZ2asLl0f5r5UQGck72z8wu1j8UrBC971qTXetwdw4hdKEOpUAjbWfCuthr+jGHHx+ZbgF7szwcIiKtOHzZlrTY3Rm7KadaOaYjO75amHX9SwlNlGD/j2",
'app_cert_public_key' => base_path('storage/cert/appCertPublicKey_2021003114639213.crt'),
'alipay_root_cert' => base_path('storage/cert/alipayRootCert.crt'),
'ali_public_key' => base_path('storage/cert/alipayCertPublicKey_RSA2.crt'),
'log' => [
'file' => storage_path('logs/alipay.log'),
],
],
];
$order = 123456789;
$price = 100;
$id = 1;
$config = config('alipay.alipay');
$aliOrder = [
'out_biz_no' => $order,
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
'trans_amount' => $price,
'biz_scene' => 'DIRECT_TRANSFER',
'remark' => '支付寶提現',
'payee_info' => [
'identity' => $binginfo["alipay"],
'identity_type' => 'ALIPAY_LOGON_ID',
'name' => $binginfo["truename"]
]
];
$result = \Yansongda\Pay\Pay::alipay($config)->transfer($aliOrder);
if (!($result['code'] == 10000 && $result['msg'] === 'Success')) {
writeLog('ali_pay_success', ['msg' => '支付寶提現失敗' . $order["order_num"], 'returnData' => $result]);
return $this->errorResponse($result['sub_msg']);
}
DB::table("withdorder")->where("id", $id)
->update(["desc" => $desc, "status" => $status, "update_time" => date("Y-m-d H:i:s")]);
$log["user_id"] = $user_id;
$log["month_day"] = date("m-d H:i");
$log["amount_money"] = $price;
$log["add_time"] = date("Y-m-d H:i:s", time());
$log["descript"] = $descript;
Paymentsum::getPaylog($log);
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結