authorize.net 你好世界收费信用卡错误:无效响应



试图让 Hello World 示例 Authorize.net 工作

这里安装的作曲家是json。 几乎与他们的例子相同。

{
"require": {
"symfony/console": "^3.3",
"php": ">=5.6",
"ext-curl": "*",
"authorizenet/authorizenet": ">=1.9.3"    
}
}

以下内容是从SSH剪切和粘贴的

>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files

我在 Hello World PHP 示例中唯一更改的是我的沙盒登录 ID 和交易密钥以及供应商/自动加载.php的路径。

我在这里缺少什么来让此示例返回除

向信用卡收费错误:响应无效

这个问题的解决方案相当简单。 在这里发布解决方案以向前支付。 首先,这就是基本工作作曲家所需的全部内容.json

{
"require": {
"symfony/console": "^3.3",
"authorizenet/authorizenet": ">=1.9.3"    
}
}

你可能甚至不需要交响乐。顺便说一下,我正在运行php 5.6和TLS 1.2,这是必需的。

其次,示例代码中存在范围问题。 以下是信用卡示例代码的前几行,可在 authorize.net 浏览器沙箱中正常工作。

function chargeCreditCard($amount)
{
$merchantAuthentication = new AnetAPIMerchantAuthenticationType();
$merchantAuthentication->setName(SampleCodeConstants::MERCHANT_LOGIN_ID);
$merchantAuthentication->setTransactionKey(SampleCodeConstants::MERCHANT_TRANSACTION_KEY);

这是我在我的 php 脚本中将其更改为不起作用的内容。

function chargeCreditCard(){
$merchantAuthentication = new AnetAPIMerchantAuthenticationType();
$merchantAuthentication->setName($AuthorizeLoginID);
$merchantAuthentication->setTransactionKey($AuthorizeTransKey); 

这是我将其更改为确实有效的内容。

function chargeCreditCard(){
global $AuthorizeLoginID, $AuthorizeTransKey;
$merchantAuthentication = new AnetAPIMerchantAuthenticationType();
$merchantAuthentication->setName($AuthorizeLoginID);
$merchantAuthentication->setTransactionKey($AuthorizeTransKey); 

有点生气自己没有早点看到凭据的范围问题,但我最终通过消除过程弄清楚了。

最新更新