如何在没有框架的情况下使用authorize.net

问题描述 投票:1回答:1

我只是让authorize.net工作有问题。我觉得我错过了什么,但不确定它是什么。我在网站上遵循本指南:http://developer.authorize.net/hello_world/我相信我有正确的作曲家设置,但是当我运行示例代码时出现错误

致命错误:在/ home / admin / web / ***** / public_html / pricing / vendor / authorizenet / authorizenet / lib / net / authorize / api中找不到类'Goetas \ Xsd \ XsdToPhp \ Jms \ Handler \ BaseTypesHandler'第82行/controller/base/ApiOperationBase.php

注意:“/ web /”之后的位置中的星标是为了隐藏出于安全原因列出的域。

任何线索我怎么能让这个工作?

有没有人有一个分步指南将authorize.net集成到一个自定义构建的平台?我们只是尝试发送充值卡所需的基本信息并收到回复。

php composer-php authorize.net
1个回答
-1
投票

对于试图将authorize.net快速集成到付费系统或网站中的问题。下面是我用来构建/定制的代码,以使其工作。除非您要创建一个完全集成的系统,否则不需要该框架,该系统未在网站上明确指出。您显然将不得不进一步扩展此代码,但这应该是任何人需要快速集成到授权中。

$params = array(

'x_invoice_num' => 'test',
'x_amount' => '5',
'x_exp_date' => '1202',
'x_address' => 'test',
'x_zip' => '12345',
'x_first_name' => 'test',
'x_last_name' => 'test',
'x_relay_response' => false,
'x_type' => 'AUTH_CAPTURE',
'x_method' => 'CC',
'x_login' => 'yourlogin code goes here',
'x_tran_key' => 'your trans key goes here',
'x_card_num' => '4111111111111111',
'x_card_code' => '143',
'x_delim_data' => true,
'x_delim_char' => '|',
'x_relay_response' => false
 );

 $postString = '';
 foreach ($params as $key => $value)
 $postString .= $key.'='.urlencode($value).'&';
 $postString = trim($postString, '&');
 $url = 'https://secure.authorize.net/gateway/transact.dll';

 $request = curl_init($url);
 curl_setopt($request, CURLOPT_HEADER, 0);
 curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($request, CURLOPT_POSTFIELDS, $postString);
 curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false);
 $postResponse = curl_exec($request);
 curl_close($request);
 print_r($postResponse);

 $response = explode('|', $postResponse);
 if (!isset($response[7]) || !isset($response[3]) ||            !isset($response[9]))
{
 $msg = 'Authorize.net returned a malformed response for cart';
 if (isset($response[7]))
 $msg .= ' '.(int)$response[7];
 die('Authorize.net returned a malformed response, aborted.');
 }

$message = $response[3];

switch ($response[0]) // Response code
{
case 1: // Payment accepted
print_r($response[1]);
break ;

case 4: // Hold for review
print_r($response[4]);
break ;

default:
echo $message;

exit;
}
© www.soinside.com 2019 - 2024. All rights reserved.