Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 3 of 3 FirstFirst 123
Results 31 to 35 of 35
  1. #31
    New Coder
    Join Date
    Mar 2013
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Maybe I should not use the original send() method and instead use the AuthnetXML class with the process() method since we know that sends and recieves ok.

  2. #32
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yep, I'd definitely try that. Since $message is of type AuthnetXML, you should be able to execute the process() method on it. Given what I see of that class, it should populate data, but I'm not sure exactly with what. This is a deficiency of a weak datatype language like PHP.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  3. #33
    New Coder
    Join Date
    Mar 2013
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I know that this section of code sends data to Authorize.net and get back a response.

    PHP Code:
    function build () {
            
    $Order $this->Order;
        

     
        
    $xml = new AuthnetXML(AUTHNET_LOGINAUTHNET_TRANSKEYAuthnetXML::USE_DEVELOPMENT_SERVER);
        
    $xml->createCustomerProfileTransactionRequest(array(
          
    'transaction' => array(
                
    'profileTransAuthCapture' => array(
                    
    'amount' => '10.95',
                    
    'tax' => array(
                        
    'amount' => '1.00',
                        
    'name' => 'your state sales tax',
                        
    'description' => 'description state sales tax'
                    
    ),
                    
    'shipping' => array(
                        
    'amount' => '2.00',
                        
    'name' => 'ground based shipping',
                        
    'description' => 'Ground based 5 to 10 day shipping'
                    
    ),
                    
    'lineItems' => array(
                        
    => array(
                            
    'itemId' => '1',
                            
    'name' => 'widget',
                            
    'description' => 'description of widget',
                            
    'quantity' => '18',
                            
    'unitPrice' => '45.00'
                        
    ),
                        
    => array(
                            
    'itemId' => '2',
                            
    'name' => 'widget2',
                            
    'description' => 'description widget 2',
                            
    'quantity' => '10',
                            
    'unitPrice' => '85.00'
                        
    )
                    ),
                    
    'customerProfileId' => '129',
                    
    'customerPaymentProfileId' => '119',
                    
    'customerShippingAddressId' => '120',
                    
    'order' => array(
                        
    'invoiceNumber' => 'INV26',
                        
    'description' => 'description of transaction',
                        
    'purchaseOrderNumber' => 'PON26'
                    
    ),
                    
    'taxExempt' => 'false',
                    
    'recurringBilling' => 'false',
                    
    'cardCode' => '000'
                
    )
            ),
          
            
        )); 
    And if I use this:

    PHP Code:
    echo "Response: " $xml->messages->message->code  "<br><br>";//returns "Ok"
    echo "Code: " $xml->messages->resultCode .  "<br><br>";// returns "I00001" 
    So how can I call the process method? I probably need to rename it since there is a process function also. Off the main gateway page require('AuthnetXML.class.php');
    Then some this like parent::Process($xml);
    I really appreciate you helping me with this.

  4. #34
    New Coder
    Join Date
    Mar 2013
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I was able to get it to process an order. I need to work out the "PENDING" and "CHARGED" . I echo out the results and can see it is "Ok" with code of "I00001" so it should save the order as "CHARGED" but they all get saved as "PENDING".

    PHP Code:
    require('/../../core/model/XML.php');
    require(
    'config.inc.php');
    require(
    'AuthnetXML.class.php');
    class 
    AuthorizeNet extends GatewayFramework implements GatewayModule {

        var 
    $cards = array("visa""mc");
        var 
    $status = array("I00001" => "CHARGED","I000027" => "PENDING");
        var 
    $liveurl "https://apitest.authorize.net/xml/v1/request.api/"
        var 
    $secure true;

        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 $xml->messages->resultCode;
            
            if (
    $status == "I00002"){ //anything but I00001
        
                
    $message $xml->messages->message->code//result text message
                
                
    $code $xml->messages->resultCode;//resultCode number
                
                
    if (empty($message)) { 
                    new 
    MycartError(__("A configuration error occurred while processing this transaction. Please contact the site administrator.","Mycart"),'authnet_error',MYCART_TRXN_ERR);
                    
    //var_dump($Response);
                    
    return;
                }
                new 
    MycartError($message,'authnet_error',MYCART_TRXN_ERR);
                    return;
            }
            
            
            
    //$transaction = $Response->getElement('transaction');
            //$txnid = $transaction['CHILDREN']['Id']['CONTENT'];
            
    $txnid "12347";//hard coded for now
            
    $txnstatus $xml->messages->resultCode;
            
    $Mycart->Order->transaction($txnid,$txnstatus);

        }
        

        

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

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

    echo 
    "Response: " $xml->messages->message->code  "<br><br>";
    echo 
    "Code: " $xml->messages->resultCode .  "<br><br>";
    echo 
    "Raw request: " $xml "<br><br>";

    echo 
    "Raw response: " $response->customerProfileId "<br><br>";

    return 
    $xml;//end function

     
    }    


        
        
    function 
    send ($message) {
        
            
    $url 'https://apitest.authorize.net/xml/v1/request.api';
            
    $url apply_filters('mycart_authorize_net_url',$url);
            
        } 

  5. #35
    New Coder
    Join Date
    Mar 2013
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I am going to mark this as solved since I have resolved my original issue.


 
Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •