Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member RDesignista's Avatar
    Join Date
    Feb 2012
    Location
    Coconut Tree City
    Posts
    822
    Member #
    30921
    Liked
    123 times
    Hi,

    I'm wondering if anybody here has played around a lot with Authorize.net.

    I am okay with PHP calculations and I've set up shopping carts to use Authorize.net, but what I want to do now is to simply store a dollar amount in a variable ($total), add to it, add discounts, and then charge that variable amount to Authorize.net. I haven't found a good answer to this yet... do you simply set this up via their AIM API?

    Insight would be appreciated.

    -R

  2.  

  3. #2
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    I'd assume you do all of these calculations before you post to their API. Maybe this sort of thing?

    PHP Code:
    <?php

    $products 
    = array("Golf Club" => "100.00");
    $discounts = array("0.1"); //10% off

    $post_values = array(
      
    "x_amount" => getTransactionAmount($products$discounts),
        
    //All others here
    );

    //Test it
    echo $post_values['x_amount'];

    /**
    * Gets the total amount taking into consideration multiple
    * products and discounts
    * @param  [array]  $products
    * @param  [array]  $discounts
    * @return [string] Number formatted to 2 decimal places as a string
    */
    function getTransactionAmount(array $products, array $discounts) {

      
    $total = (float) 0;

        
    //Set the total cost
        
    foreach($products as $product_name => $product_price)
            
    $total .= (float) $product_price;

        
    //Apply the discounts
        
    foreach($discounts as $discount)
            
    $total $total - ($total $discount);

        return (string) 
    number_format($total2);
    }
    There doesn't seem to be any discounts you can add for this to be calculated on their side anyway, looking at the documentation (http://developer.authorize.net/guide...tml/wwhelp.htm)
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    I haven't used their AIM API in years, but I know it's possible to do so. Like Ganners said, you need to do all the processing required to get to the total on your side, post an XML request to their API and then deal with the response.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Senior Member RDesignista's Avatar
    Join Date
    Feb 2012
    Location
    Coconut Tree City
    Posts
    822
    Member #
    30921
    Liked
    123 times
    Wonderful. Thanks Ganners. Did you just type that out from the top of your head?

    Yes, I knew that you could process discounts or add fees/taxes via PHP math, but I wasn't sure if it was the proper way if you were going to relay payment through the Authorize.net API.

    THanks guys. Will be taking a look at that example tomorrow.

    -R

  6. #5
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    I did just write it yes, I did test it as well though so it will work.

    I believe it is the proper way, and it will certainly work. I don't see any other field names you could submit which could cater for this so you'd assume something doesn't exist for it.

    Just make sure you keep it tidy, object oriented. Create some unit tests if you're worried it might break or have issues.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:12 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com