config = $config_info; $options = new AliCon(); $options->protocol = 'https'; $options->gatewayHost = 'openapi.alipay.com'; $options->signType = 'RSA2'; $options->appId = $config_info['appid']; // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 $options->merchantPrivateKey = $config_info['private_key'] ?? ""; //'<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->'; //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 $options->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; // '<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->'; //可设置异步通知接收服务地址(可选) $options->notifyUrl = ''; //"<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->"; //可设置AES密钥,调用AES加解密相关接口时需要(可选) $options->encryptKey = $config_info['encryptKey']; //"<-- 请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA== -->"; $options->alipayCertPath = ''; //'<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->'; $options->alipayRootCertPath = ''; //'<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt" -->'; $options->merchantCertPath = ''; //'<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->'; Factory::setOptions($options); } /*** * 直通商户进件 * @param $bizParams * @return mixed|string */ public function simpleCreate($bizParams) { try { $textParams = []; //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) $result = Factory::util() ->generic() ->execute("ant.merchant.expand.indirect.zft.simplecreate", $textParams, $bizParams); return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_simplecreate_response']; } catch (\Exception $e) { return $e->getMessage(); } } public function query($external_id = '', $order_id = '') { try { $textParams = []; if ($external_id) { $bizParams = [ 'external_id' => $external_id ]; } else if ($order_id) { $bizParams = [ 'order_id' => $order_id ]; } //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) $result = Factory::util() ->generic() ->execute("ant.merchant.expand.indirect.zftorder.query", $textParams, $bizParams); return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zftorder_query_response']; } catch (\Exception $e) { return $e->getMessage(); } } public function upload($image_type = '', $image_content) { try { $textParams = [ 'image_type' => $image_type, ]; $fileParams = [ 'image_content' => $image_content, ]; //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) $result = Factory::util() ->generic() ->fileExecute("ant.merchant.expand.indirect.image.upload", $textParams, [], $fileParams); return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_image_upload_response']; } catch (\Exception $e) { return $e->getMessage(); } } /*** * 验签 * @param $param * @return bool */ public function verifySgin($param) { $res = Factory::payment() ->common() ->verifyNotify($param); return $res; } /** * Common: 发起支付宝请求 * Author: wu-hui * Time: 2023/01/31 16:06 * @param $api * @param array $params * @param array $textParams * @return mixed|string */ public function requestApi($api, $params = [], $textParams = []){ try { $result = Factory::util()->generic()->execute($api,$textParams,$params); return json_decode($result->httpBody, true); } catch (\Exception $e) { return $e->getMessage(); } } }