You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/vendor/alipaysdk/easysdk/php/test/TestAccount.php

45 lines
2.2 KiB

11 months ago
<?php
namespace Alipay\EasySDK\Test;
use Alipay\EasySDK\Kernel\Config;
class TestAccount
{
public function getTestAccount()
{
$options = new Config();
$options->protocol = 'https';
$options->gatewayHost = 'openapi.alipay.com';
$options->appId = '<-- 请填写您的AppId例如2019022663440152 -->';
$options->signType = 'RSA2';
$options->alipayPublicKey = '<-- 请填写您的支付宝公钥例如MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAumX1EaLM4ddn1Pia4SxTRb62aVYxU8I2mHMqrcpQU6F01mIO/DjY7R4xUWcLi0I2oH/BK/WhckEDCFsGrT7mO+JX8K4sfaWZx1aDGs0m25wOCNjp+DCVBXotXSCurqgGI/9UrY+QydYDnsl4jB65M3p8VilF93MfS01omEDjUW+1MM4o3FP0khmcKsoHnYGs21btEeh0LK1gnnTDlou6Jwv3Ew36CbCNY2cYkuyPAW0j47XqzhWJ7awAx60fwgNBq6ZOEPJnODqH20TAdTLNxPSl4qGxamjBO+RuInBy+Bc2hFHq3pNv6hTAfktggRKkKzDlDEUwgSLE7d2eL7P6rwIDAQAB -->';
$options->merchantPrivateKey = $this->getPrivateKey($options->appId);
return $options;
}
public function getTestCertAccount()
{
$options = new Config();
$options->protocol = 'https';
$options->gatewayHost = 'openapi.alipay.com';
$options->appId = '<-- 请填写您的AppId例如2019051064521003 -->';
$options->signType = 'RSA2';
$options->alipayCertPath = '<-- 请填写您的支付宝公钥证书文件路径例如dirname(__FILE__) . "/resources/fixture/alipayCertPublicKey_RSA2.crt" -->';
$options->alipayRootCertPath = '<-- 请填写您的支付宝根证书文件路径例如dirname(__FILE__) . "/resources/fixture/alipayRootCert.crt" -->';
$options->merchantCertPath = '<-- 请填写您的应用公钥证书文件路径例如dirname(__FILE__) . "/resources/fixture/appCertPublicKey_2019051064521003.crt" -->';
$options->merchantPrivateKey = $this->getPrivateKey($options->appId);
return $options;
}
private function getPrivateKey($appId)
{
$filePath = dirname(__FILE__) . '/resources/fixture/privateKey.json';
$stream = fopen($filePath, 'r');
fwrite($stream, '$filePath');
$result = json_decode(stream_get_contents($stream));
return $result->$appId;
}
}