4 Replies - 1287 Views - Last Post: 25 March 2013 - 11:44 AM Rate Topic: -----

#1 mallen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-March 13

Editing a payment gateway

Posted 23 March 2013 - 06:11 PM

I am working on a shopping cart that uses Authorize.net API. I am using the CIM method. I am able to send the XML and process the payment to Authorize.net But I can't get it to give me status errors in the message box in side my shopping cart system. Changing some of the val;ues I will either get E0002 error (which means incorrect format) or I get the default message "A configuration error occurred while processing this transaction " Anyone have experience working with this?

 var $cards = array("visa", "mc");
    var $status = array("1" => "CHARGED","4" => "PENDING");

    function AuthorizeNet () {
        parent::__construct();
        $this->setup('login','password','testmode');
    }

    function actions () {
        add_action('mycart_process_order',array(&$this,'process'));
    }

    
        function process () {
        global $Mycart;
        
        $message = $this->build();
        $Response = $this->send($message);
        
        $status = $Response->getElementContent('messages');
        
        
        if ($status == "1" || $status == "4") { 
        
             $message = $Response->getElementContent('code');
            $code = $Response->getElementContent('resultCode');
            
            if (empty($message)) {
                new MycartError(__("A configuration error occurred while processing this transaction. Please contact the site administrator.","Mycart"),'authnet_error',MYCART_TRXN_ERR);
                return;
            }
            new MycartError($message,'authnet_error',MYCART_TRXN_ERR,
                array('code'=>$code));
                return;
        }
        
        
        $transaction = $Response->getElement('transaction');
        $txnid = $transaction['CHILDREN']['Id']['CONTENT'];
        $txnstatus = $this->status[$status];
        $Mycart->Order->transaction($txnid,$txnstatus);

    }
    
    
    

    function build () {
        $Order = $this->Order;
    

 
$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
    $xml->createCustomerProfileTransactionRequest(array(
      'transaction' => array(
            'profileTransAuthCapture' => array(
                'amount' => '10.95',
                'tax' => array(
                    'amount' => '1.00',
                    'name' => 'state sales tax',
                    'description' => 'state sales tax'
                ),
                'shipping' => array(
                    'amount' => '2.00',
                    'name' => 'ground based shipping',
                    'description' => 'Ground based 5 to 10 day shipping'
                ),
                'lineItems' => array(
                    0 => array(
                        'itemId' => '1',
                        'name' => 'vase',
                        'description' => 'widget 1',
                        'quantity' => '18',
                        'unitPrice' => '45.00'
                    ),
                    1 => array(
                        'itemId' => '2',
                        'name' => 'widget 2',
                        'description' => 'widget ',
                        'quantity' => '10',
                        'unitPrice' => '85.00'
                    )
                ),
                'customerProfileId' => '129',
                'customerPaymentProfileId' => '119',
                'customerShippingAddressId' => '120',
                'order' => array(
                    'invoiceNumber' => 'INV13',
                    'description' => 'description of transaction',
                    'purchaseOrderNumber' => 'PON13'
                ),
                'taxExempt' => 'false',
                'recurringBilling' => 'false',
                'cardCode' => '000'
            )
        ),
     
        
    ));

 }    

    
    
    
function send ($message) {
        $url = 'https://apitest.authorize.net/xml/v1/request.api' ;
        $url2 = apply_filters('mycart_authorize_net_url',$url2);
        $response = parent::send($message,$url2);
        return new XMLdata($response);
    }

function response ($buffer) { //added to test error
        $_ = new stdClass();

        list($_->code,
             $_->subcode,
             $_->reasoncode,
             $_->reason,
             $_->authcode,
             $_->avs,
             $_->transactionid,
             $_->invoicenum,
             $_->description,
             $_->amount,
             $_->method,
             $_->type,
             $_->customerid,
             $_->firstname,
             $_->lastname,
             $_->company,
             $_->address,
             $_->city,
             $_->state,
             $_->zip,
             $_->country,
             $_->phone,
             $_->fax,
             $_->email,
             $_->ship_to_first_name,
             $_->ship_to_last_name,
             $_->ship_to_company,
             $_->ship_to_address,
             $_->ship_to_city,
             $_->ship_to_state,
             $_->ship_to_zip,
             $_->ship_to_country,
             $_->tax,
             $_->duty,
             $_->freight,
             $_->taxexempt,
             $_->ponum,
             $_->md5hash,
             $_->cvv2code,
             $_->cvv2response) = explode(",",$buffer);
        return $_;
    }    

    function settings () {
        $this->ui->cardmenu(0,array(
            'name' => 'cards',
            'selected' => $this->settings['cards']
        ),$this->cards);

        $this->ui->text(1,array(
            'name' => 'login',
            'value' => $this->settings['login'],
            'size' => '16',
            'label' => __('Enter your AuthorizeNet Login ID.','Mycart')
        ));

        $this->ui->password(1,array(
            'name' => 'password',
            'value' => $this->settings['password'],
            'size' => '24',
            'label' => __('Enter your AuthorizeNet Password or Transaction Key.','Mycart')
        ));

        $this->ui->checkbox(1,array(
            'name' => 'testmode',
            'checked' => $this->settings['testmode'],
            'label' => __('Enable test mode','Mycart')
        ));

    }

} // END class AuthorizeNet  



Is This A Good Question/Topic? 0
  • +

Replies To: Editing a payment gateway

#2 mallen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-March 13

Re: Editing a payment gateway

Posted 25 March 2013 - 05:16 AM

What do the dots represent here?

$response = parent::send($message,$url);


Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3197
  • View blog
  • Posts: 10,724
  • Joined: 12-December 12

Re: Editing a payment gateway

Posted 25 March 2013 - 05:34 AM

View Postmallen, on 25 March 2013 - 12:16 PM, said:

What do the dots represent here?

$response = parent::send($message,$url);


These are the scope resolution operator.
Was This Post Helpful? 0
  • +
  • -

#4 mallen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-March 13

Re: Editing a payment gateway

Posted 25 March 2013 - 05:47 AM

Thanks. Do you see anything above that I could fix to get the XML response?
Was This Post Helpful? 0
  • +
  • -

#5 mallen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 23-March 13

Re: Editing a payment gateway

Posted 25 March 2013 - 11:44 AM

What about this part

$message = $Response->getElementContent('code');// messages, message, responseCode
$code = $Response->getElementContent('resultCode');



Should it be something like this? I don't know where it failing.

$message = $Response->xml->getElementContent('code');// messages, message, responseCode
$code = $Response->xml->getElementContent('resultCode');


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1