I have an existing shopping cart that is set up for Paypal and works exactly as we want it to. The company now says we must use authorize.net and not Paypal. I am not a php programmer so I am a bit at a loss how to hook up the cart to authorize.net. It appears that all I need to so is get the amount form the "subtotal" field and pass that to the "$amount" field in the direct_post.php page that I am working on. The direct_post.php page seems to work perfectly and I am sure that anyone knowing even a bit about php would have no problem with this.
We want to stay with the existing cart as it has the features that our customers are asking for and don't want to spent a lot of time building something that is already as we want it.
Here is the direct_post.php page:
<?php require_once 'anet_php_sdk/AuthorizeNet.php'; // Include the SDK you downloaded in Step 2 $api_login_id = 'MyLoginID'; $transaction_key = 'MyTransactionKey'; $amount = "5.99"; $fp_timestamp = time(); $fp_sequence = "123" . time(); // Enter an invoice or other unique number. $fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp) ?> <form method='post' action="https://test.authorize.net/gateway/transact.dll"> <input type='hidden' name="x_login" value="<?php echo $api_login_id?>" /> <input type='hidden' name="x_fp_hash" value="<?php echo $fingerprint?>" /> <input type='hidden' name="x_amount" value="<?php echo $amount?>" /> <input type='hidden' name="x_fp_timestamp" value="<?php echo $fp_timestamp?>" /> <input type='hidden' name="x_fp_sequence" value="<?php echo $fp_sequence?>" /> <input type='hidden' name="x_version" value="3.1"> <input type='hidden' name="x_show_form" value="payment_form"> <input type='hidden' name="x_test_request" value="false" /> <input type='hidden' name="x_method" value="cc"> <input type='submit' value="Click here for the secure payment form"> </form>
Here is the relavent part of the checkout page:
<?php include_once('jcart/jcart.php'); session_start(); ?> <?php $jcart->display_cart();?>
And here is the function for the subtotal:
private function update_subtotal() { $this->itemCount = 0; $this->subtotal = 0; if(sizeof($this->items > 0)) { foreach($this->items as $item) { $this->subtotal += ($this->qtys[$item] * $this->prices[$item]); // Total number of items $this->itemCount += $this->qtys[$item]; } } }
Any help you can give me would be greatly appreciated.
โ12-15-2012 10:21 AM
โ12-17-2012 02:52 PM