duan89197 2016-08-27 00:40
浏览 14

集成Authorize.net和codeigniter

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题