Hello I have a web application and I would like to start integrating charging debit/credit cards online and I am confused as to why my code is not working. I am new to online payments and the documention to start is very unclear. I am using Codeigniter 3. Here is some sample code from what I am using
/* Included at the top of the file*/
use assets\libraries\authorize\lib
et\authorize\api\contract\v1 as AnetAPI;
use assets\libraries\authorize\lib
et\authorize\api\controller as AnetController;
/* Model Function */
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(""); //ID
$merchantAuthentication->setTransactionKey(""); //Key
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("card was here"); //This had actual value
$creditCard->setExpirationDate("expire was here");//This had actual value
$creditCard->setCardCode("code was here"); //This had actual value
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
$order = new AnetAPI\OrderType();
$order->setDescription("desceiption was here"); //This had actual value
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
$transactionRequestType->setAmount(1.00);
$transactionRequestType->setOrder($order);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId);
$request->setTransactionRequest( $transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(
et\authorize\api\constants\ANetEnvironment::PRODUCTION);
if ($response != null)
{
$tresponse = $response->getTransactionResponse();
if (($tresponse != null) && ($tresponse->getResponseCode()== \SampleCode\Constants::RESPONSE_OK) )
{
echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "
";
echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "
";
}
else
{
echo "Charge Credit Card ERROR : Invalid response
";
}
}
else
{
echo "Charge Credit card Null response returned";
}
No error is being returned from the script but no money is being charged and I am confused why. If anyone could tell me the correct way to get started and how to accept a payment online It would be VERY appreciated.