DEVPROCB DEVPROCB - 1 year ago 142
PHP Question

How to use without framework

I am having problems just getting to work. I feel Like I am missing something, but not sure what it is. I follow this guide here on the website: I have composer setup correctly I believe, but when I run the sample code I get an error

Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /home/admin/web/*****/public_html/pricing/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82

Note: The stars in the location after "/web/" were to hide the domain that was listed for security reasons.

Any clue how I can get this to work?

Does anyone have a step by step guide to integrate into a custom built platform? We are just trying to send the basic information needed to charge a card and receive a response back.

Answer Source

To anyone running into issues with Trying to quickly integrate into their pay system or website. Below is the code I used to built/customized to get this to work. The framework is not needed unless you are creating a fully integrated system, which is not clearly indicated on the site. You are obviously going to have to expand on this code further, but this should be what anyone needs to integrate into authorize quickly.

$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 = '';

 $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);

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

$message = $response[3];

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

case 4: // Hold for review
break ;

echo $message;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download