Tom Muck's blog
21 posts
Showing 8
| Previous
| Next
(page 2 of 3)
Using GoDaddy with Cartweaver -- Transactions
Saturday, July 19, 2008 9:30:38 AM
GoDaddy provides an excellent service for domain registration and domain management, but when it comes to web hosting, there are a few gotchas to be aware of. One of them is the proxy server that is used for SSL. When you are setting up your e-store and using a payment gateway like Authorize.Net, you have to communicate via SSL behind the scenes. In ColdFusion, this is done with the <cfhttp> tag. In PHP, it is done with cURL or OpenSSL.
To convert the payment gateway file in Cartweaver to use the proxy server, you have to edit the file located in /cw3/CWLibrary/ProcessPayment/ for PHP or /cw3/CWTags/ProcessPayment/ for ColdFusion. A typical file would be CWIncAuthorizeNet.cfm or CWIncAuthorizeNet.php. For ColdFusion, the code looks like this:
<cfhttp url="https://secure.authorize.net/gateway/transact.dll"
method="post"
>
You would change it to this to use the proxy server:
<cfhttp url="https://secure.authorize.net/gateway/transact.dll"
method="post"
proxyserver="proxy.shr.secureserver.net"
proxyport="3128"
>
For PHP, the cURL code looks like this:
$url = "https://secure.authorize.net";
$path = "/gateway/transact.dll";
// post back to Authorize.net system
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url . $path);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
$authNetResult = curl_exec($ch);
curl_close ($ch);
You have to add a few lines for the proxy:
$url = "https://secure.authorize.net";
$path = "/gateway/transact.dll";
// post back to Authorize.net system
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url . $path);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
$authNetResult = curl_exec($ch);
curl_close ($ch);
If you still can't get it to work, call GoDaddy support. They can usually help. GoDaddy does not outsource their support overseas, unlike other companies, and is usually pretty good and easy to get on the phone.
Category tags: Cartweaver, ColdFusion, FAQ, PHP
Posted by Tom Muck
Add comment
|
View comments (4) |
Permalink
|
Trackbacks (0)
|
Digg This
Adding a second payment type in ColdFusion
Sunday, May 11, 2008 10:37:41 AM
This modification can be used for "Pay by Credit Card or Check" or for "Pay now or request a Quote". This is simply a matter of changing the credit card processor from your payment processor that is set up in the Application.cfm file to "none" on the fly, based on user input. The code for this modification in PHP is shown at http://www.tom-muck.com/cw/
You should be able to set up a form field on the order form to allow for checks to be sent on CWIncOrderForm.cfm:
<p>Pay by:<br />
Send check:
<input type="radio" name="paymenttype" value="0" checked="checked" />
Credit Card:
<input type="radio" name="paymenttype" value="1" />
</p>
then add a bit of code to the CWIncOrderForm.cfm file around line 43, right after <cfif IsDefined ('FORM.OrderFormNext')> :
<cfif isDefined("Form.paymenttype")>
<cfset session.paymenttype = form.paymenttype />
</cfif>
then a bit of code to the CWIncShowCart.cfm file:
<cfif IsDefined("Session.paymenttype")>
<cfswitch expression="#Session.paymenttype#">
<cfcase value="0">
<cfset request.paymentAuthType = "none">
<cfset request.paymentAuthName = "none">
</cfcase>
<cfcase value="1">
<cfset request.paymentAuthType = "gateway">
<cfset request.paymentAuthName = "CWIncAuthorizeNet.cfm">
</cfcase>
</cfswitch>
</cfif>
Also, if you want to change the confirmation emails based on the payment type, add this code to the top of CWIncConfirmation.cfm as well:
<cfif IsDefined("Session.paymenttype")>
<cfswitch expression="#Session.paymenttype#">
<cfcase value="0">
<cfset request.paymentAuthType = "none">
<cfset request.paymentAuthName = "none">
</cfcase>
<cfcase value="1">
<cfset request.paymentAuthType = "gateway">
<cfset request.paymentAuthName = "CWIncAuthorizeNet.cfm">
</cfcase>
</cfswitch>
</cfif>
Then you can make your changes in the email within the CFMAIL tag however you like, such as:
Your order has been received.
As soon as your payment is received you will receive a confirmation notice and your order will be shipped! Your order details are as follows.
#EmailContents#
You might also add a bit of code after the <h2>Order Details</h2> line:
<h2>Order Details</h2>
<cfif request.paymentAuthType EQ "none">
<p>Your order has been recieved. The order will be shipped when your check or money order is received.</p>
</cfif>
This could also be used to switch between a gateway and Paypal, or even 3 options -- credit card, check, or Paypal.
Update: If the customer is logged in already, the default payment option only is shown, but you can set up a link to change the payment type like this:
<a href="<cfoutput>#request.targetCheckOut#</cfoutput>"><strong>Change your payment type</strong></a>
Category tags: Dreamweaver, Cartweaver, ColdFusion, FAQ
Posted by Tom Muck
Add comment
|
View comments (2) |
Permalink
|
Trackbacks (0)
|
Digg This
Protect that download directory
Sunday, March 30, 2008 12:00:00 AM
When running a digital downloads store, you want to make sure your web visitors do not have access to the folder where your downloads are contained. This also applies to anyone using the Cartweaver Downloadable Products plug-in. Depending on your server, you have different options. If the web server is IIS, you can go into the admin and turn off anonymous access. If it is an Apache server, add an .htaccess file to the downloads folder like this:
Deny from all
or
Redirect /yourstorefolder/ http://yourdomain.com/yourstorefolder/error.php?error=No%20access%20allowed%20
That should take care of any attempts to download from the folder.
Note that not all web hosts allow the use of .htaccess. If not, you may have to contact the web host to ask them to turn off web access to this folder. You may also have access to an administrative panel for your web hosting account that has this functionality available.
Category tags: Cartweaver, ColdFusion, FAQ, PHP, Plug-ins
Posted by Tom Muck
Add comment
|
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
New price format string functionality in Cartweaver
Monday, March 03, 2008 6:19:11 PM
The lastest versions of Cartweaver PHP and ColdFusion contain a new price format string. This was a much requested feature, as many CW users wanted to format prices in a different way than it was set up by default. Some users might need to display prices with tax, prices without tax, both prices, tax amounts, etc. VAT formatting in particular needed a different format. We came up with a price format string in the getPriceList() function:
The function takes these arguments.
productID: The product ID to display.
allowBackOrders: Do we allow back orders?
taxRate: Rate of tax for the item
currentRecord: row number for CSS ids
showMax: flag to show max price along with min price
priceFormat: string with replaceable masks for price parts
Price format string new in 3.0.7 (PHP) and 3.0.9 (ColdFusion) to format price on results and details page for taxable items
$priceFormat in this format:
@@beforeDiscountPrice@@
@@currentPrice@@
@@tax@@
@@priceWithTax@@
@@taxAmount@@
Use in combination with showMax. By default, minimum and maximum price of product are shown ($1.00 - $5.00). Set to false to show only the minimum price. Then, priceFormat can be used to format the price like this:
for example, assuming a 50% discount, 5% tax rate, showing prices before tax and after tax:
@@beforeDiscountPrice@@ @@currentPrice@@ (@@priceWithTax@@ including @@tax@@% tax)
shows 2.00 - 10.00 (2.10 - 10.50 including 5% tax) 1.00 - 5.00 (1.05 - 5.25 including 5% tax)
Another example shows displaying minimum price only with 50% discount, 25% VAT, and showing price with VAT included and excluded:
@@beforeDiscountPrice@@ @@priceWithTax@@ (@@currentPrice@@ + @@taxAmount@@ VAT)
shows 2.50 (2.00 excluding.50 VAT) 1.25 (1.00 excluding .25 VAT)
A simple example with no discount and no tax, showing only minimum price:
Prices starting at @@currentPrice@@
shows: Prices starting at $1.00
The format string is called from the CWIncDetails and CWIncResults pages, but you can also set up a simple session variable or configuration item to handle this:
$_SESSION["PriceFormatString"] = "@@beforeDiscountPrice@@ @@priceWithTax@@ (@@currentPrice@@ + @@taxAmount@@ VAT)";
Or for CF:
<cfset Session.PriceFormatString = "@@beforeDiscountPrice@@ @@priceWithTax@@ (@@currentPrice@@ + @@taxAmount@@ VAT)">
UPDATE:
The getPriceList() function is called like this:
echo(getPriceList($productID,
$allowBackOrders,
$taxRate,
$currentRecord,
$showMax,
$priceFormat));
Essentially, you find the place on CWIncResults or CWIncDetails where the function is being called from, and adjust it to your liking:
echo(getPriceList($row_rsCWGetProduct["product_ID"],
$cartweaver->settings->allowBackOrders,
$taxRate,
',
true,
$priceFormatString));
Category tags: Dreamweaver, Cartweaver, ColdFusion, FAQ, PHP
Posted by Tom Muck
Add comment
|
View comments (5) |
Permalink
|
Trackbacks (0)
|
Digg This
Open House at Community MX
Monday, December 24, 2007 9:19:49 AM
Community MX is having an open house where visitors are able to view over 2400 articles and tutorials. Community MX is a subscription service, so this is a good opportunity to see what is available. The open house is from 12/24/2007 through 1/1/2008.
Some articles relevant to Cartweaver users are Using JumpStarts with Cartweaver, Featuring Minneapolis, Using a ColdFusion Custom Tag as a Site Template, Resending Undeliverable Mail in ColdFusion, Writing Readable SQL, PHP Site Simplification with Application.php. For a full list of what I've written for Community MX, see this page: http://www.communitymx.com/author.cfm?cid=1003
Category tags: Cartweaver, ColdFusion, PHP
Posted by Tom Muck
Add comment
|
View comments (1) |
Permalink
|
Trackbacks (0)
|
Digg This
Adding Payment Gateways and Processors
Friday, November 09, 2007 9:15:37 AM
There are literally hundreds of payment processors out there. We support a few out of the box, and have several others available as free downloads to customers, but it is not too difficult to add a new payment processor using an existing gateway/processor as a guide.
Basically there are two types of payment processors: gateway or processor. A gateway communicates behind the scenes (like Authorize.net) and processes the transaction in realtime, and a processor shows a form on a third-party web site, and credit card data is collected there (like Paypal.)
The basic procedure to create a new payment processor file in Cartweaver is to get the API from your payment processor, and use one of our payment processor files as a guide. Modify the form values in the file to use the names specified by your processor (for example, it might use "x-lastname" or "UserLastName" or "LastName"). Once you do this, you should be able to turn on the debugging email functionality, post test transactions to your payment processor, and proceed from there.
The next step is to parse the result, and all payment processors handle this differently. For example, Authorize.Net passes results in comma-delimited form, so this sample line would parse the result, for PHP:
$authNetCodes = explode(",",$authNetResult);
For ColdFusion, use the simple list functions:
<cfset request.TransactionResult = Val(ListFirst(cfhttp.fileContent))>
Some processors use name/value pairs in a querystring. The following will parse those types of results in PHP:
$resultArray = explode('&', $result);
foreach($resultArray as $val) {
$temp = explode('=', $val);
$response[$temp[0]] = $temp[1];
}
or for ColdFusion:
<cfset resultArray = ListToArray(result, "&")>
<cfset response = StructNew()>
<cfloop from="1" to="#ArrayLen(resultArray)#" index="i">
<cfset response[ListFirst(resultArray[i], "=")] = ListLast(resultArray[i], "=")>
</cfloop>
After this parsing, you can read the response array/struct values using the variable names described in the gateway API document, such as $response["success"]. The main point is that we have quite a few payment processors available, and although each one is different, you can probably locate code in these files that will assist you in creating a new payment processor file. For a list of which processors we support, check http://www.cartweaver.com/features/payments/
If you find out about the API and want me to take a look at it, let me know through my contact form. In the past I have converted payment processor files for customers for a fee, but it does not usually fit into my schedule.
Category tags: Cartweaver, ColdFusion, FAQ, PHP
Posted by Tom Muck
Add comment
|
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Locale settings in Cartweaver PHP
Sunday, November 04, 2007 9:54:34 PM
One of the frequent questions we get is about locales in Cartweaver PHP. Because of the varying nature of locale settings in Windows, Linux, Mac, and other systems running PHP, it is hard to come up with a reliable way to get the locale setting of the server. The locale setting is in application.php, and is how we determine how to format money and date/time displays. For Windows systems, the Dreamweaver setup server behavior takes care of this. A full list of Windows locales is at http://tom-muck.com/cw/windowslocales.cfm. Linux locales are not quite as easy. For that reason, we include a file at http://[yourserver]/cw3/setup/locales/CWGetLocales.php that lists your locales on your server. This is a Linux-only function, and does not work on all Linux server due to security restrictions. I have posted a list of locales on my Linux server at http://www.tom-muck.com/cw/linuxlocales.cfm.
If you are unable to obtain the locale setting on your server, and the listed locales do not work, you can modify the function in CWIncFunctions.php to hard-code the currency symbol like this:
// for CW3
function cartweaverMoney($theNum, $showCurrencySymbol = true, $stripComma = false) {
$currencySymbol = '$';
$theNum = number_format($theNum, 2, ".",",");
if($showCurrencySymbol) $theNum = $currencySymbol . $theNum;
if($stripComma) $theNum = str_replace(",","",$theNum);
return $theNum;
}
Some typical locales for US format are:
- en_US
- en_US.iso88591
- en_US.iso885915
- english-us
- eng
Category tags: Cartweaver, FAQ, PHP
Posted by Tom Muck
Add comment
|
View comments (0) |
Permalink
|
Trackbacks (0)
|
Digg This
Using Application.cfc with Cartweaver ColdFusion
Tuesday, October 16, 2007 7:22:18 PM
Cartweaver was designed for use with the Application.cfm file, but versions 7 and 8 of ColdFusion allow the use of an Application.cfc file, giving greater control over application events. Cartweaver can be used with Application.cfc with a few tweaks.
1. First, set up your Application.cfc with some settings (these would be from your cfapplication tag):
<cfcomponent>
<!--- Initialize the application --->
<cfscript>
this.name = "testCW"; // make sure every application has a unique name
this.applicationTimeout = createTimeSpan(7,0,0,0);
this.clientmanagement= "yes";
this.sessionmanagement = "yes";
this.sessiontimeout = createTimeSpan(0,0,30,0);
this.setClientCookies = "yes";
this.clientstorage="clientvariables"; // datasource for client variables
</cfscript>
2. Then, copy the <cfmodule> tag from your existing Application.cfm to your onRequestStart method.
<!--- On request start --->
<cffunction name="onRequestStart">
<cfargument name="requestname" required=true/>
<cfmodule
id = "CW3GlobalSettings"
template = "cw3/CWTags/CWTagGlobalSettings.cfm"
datasource = "yourdatasource"
etc..... >
</cffunction>
3. In the onError method, you'll have to create your own error handling to take the place of the error pages.
4. Rename OnRequestEnd.cfm at the store root to debugger.cfm and include this method in Application.cfc (if you want the debugging functionality of CW):
<cffunction name="onRequestEnd" output="true">
<cfargument type="String" name="targetPage" required=true/>
<cfinclude template="debugger.cfm">
</cffunction>
5. Include other methods, if needed (onSessionStart, onSessionEnd, etc).
6. Close the component tag:
</cfcomponent>
7. We include two files of frequently used functions in application.cfm because they are used thoughout the application, but that won't work in Application.cfc. Add these two include files to the rest of your presentation pages (results, details, confirmation, orderform, and showcart):
<cfinclude template="cw3/CWTags/CWIncFunctions.cfm">
<cfinclude template="cw3/CWTags/CWIncDiscountFunctions.cfm">
8. Then create an ApplicationProxy.cfc file at the store root with this in it:
<cfcomponent name="ApplicationProxy" extends="Application"></cfcomponent>
9. That is for the admin functionality, which will have it's own Application.cfc extending the site root Application.cfc. Put a new Application.cfc file at the root of /cw3/admin, including only the onRequestStart function:
<cfcomponent name="Application" extends="ApplicationProxy">
<cffunction name="onRequestStart">
<cfargument name="requestname" required=true/>
<cfset super.onRequestStart(requestname)>
<!--- Here, insert everything from the Application.cfm from the admin
folder
EXCEPT for the application.cfm include and the error handling ---->
</cffunction>
</cfcomponent>
That should be all that is required. There can be further optimizations, however this should give you a working site.
Category tags: Cartweaver, ColdFusion, FAQ
Posted by Tom Muck
Add comment
|
View comments (2) |
Permalink
|
Trackbacks (0)
|
Digg This
21 posts
Showing 8
| Previous
| Next
(page 2 of 3)
Before posting comments or trackbacks, please read the posting policy.
Blog RSS feed