Difference between revisions of "Checkout & Payment"

From Spiffy Stores Knowledge Base

Line 120: Line 120:
 
<pre>
 
<pre>
 
<?php
 
<?php
 
 
 
error_reporting(E_ALL);
 
error_reporting(E_ALL);
 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
Line 139: Line 138:
 
   $customer_id = trim($_GET['id']);
 
   $customer_id = trim($_GET['id']);
 
    
 
    
   if (preg_match('/^\d{11}$/', $customer_id) == 1)
+
   if (preg_match('/^\d{8}$/', $customer_id) == 1) // This validates the number of digits (e.g. 8)
 
   {
 
   {
 
     if (validation_routine($customer_id))
 
     if (validation_routine($customer_id))
Line 153: Line 152:
 
   else
 
   else
 
   {
 
   {
     $message = 'must be nn digits';
+
     $message = 'must be 8 digits';
 
   }
 
   }
 
}
 
}

Revision as of 20:12, 20 May 2009

Choosing your Payment Methods

Before you can accept orders from your customers, you will need to choose one or more methods for accepting payments. Each of the methods have varying fees and costs associated with them, so you should shop around to see which one is right for you.

Spiffy Stores supports a few external credit card payment gateways. These allow your customers to use their credit card directly in your store. You will need to set up a separate account with one of these gateways in order to use them for sales.

Accept External Payment service

An External Payment service is where your customer is redirected to an external web site to make their payment. Usually the payment can be made by Credit Card or funds transfer from a bank account. Once the payment has been processed, the customer is redirected back to your Spiffy Store and a Order Confirmation page is displayed for them.

Currently, PayPal Website Payments Standard is the only External Payment service supported by Spiffy Stores.

The advantage of this kind of service is that you don't need a merchant account to accept credit cards, and it is an ideal way to start out a new online store.

You can sign up here for a PayPal Website Payments Standard account.

Accept Credit Card payments

Direct Payment Gateways allow you to accept credit or debit card payments without leaving the Spiffy Stores checkout.

All Direct Payment Gateways will require you to have a merchant account with your bank. In addition, gateway fees will also apply unless you choose to select Manual Payments, in which case you will need to process the payments manually..

A credit card gateway is not included in the cost of your store. Gateway suppliers each have their own fee structure and eligibility requirements.

Supported Gateways

Once you have obtained your account details, you will need to select the gateway and enter your credentials into the provided fields.

You will also need to indicate which credit cards you are able to accept.

If you want to provide any special instructions to a customer who chooses to pay by credit card, click on the Show details link and enter the text of your message in the provided text box.

Finally, if your credit card gateway supports the feature, you may choose to Authorize payments, and then Capture the funds at a later date when the order is finalized. This is useful if the exact amount of the order cannot be determined at checkout time, and you can process an authorization for a larger amount, and then capture the final amount before shipping the order.

Manual Payments

The final form of payment consists of manual payments such as

  • Cheque
  • Bank Deposit
  • Money Order

You can select from one of the default options, or create your own manual payment descriptions.

For each manual payment, you can add some custom text that will be displayed to the customer when they choose this payment method. For example, you will need to provide your bank account details if you choose to accept payments by Bank Deposit.

For all manual payments, you will need to mark the order as paid manually once the payment for the order has been received.

Additional Checkout Comments

You can enable this option to allow the customer to add comments to the order. This allows a customer to make special requests or to inform you of some special delivery details.

You can also customize the prompt that is displayed on the checkout page, if the default is not sufficient.

Customer Account Number

TheCcustomer Account Number field is generally used for wholesalers, who want to allow customers to make purchases using a pre-existing account number.

When enabled, the customer account number is collected in a new field that appears on the first page of the checkout. If the customer enters their account number, the number is then optionally validated and will be displayed under the customer's contact details on the "view order" page in your toolbox once the order has been completed.

Validating a Customer Account Number

The Customer Account Number can be validated using a script hosted on an external server. This is done by sending the customer number in a specific URL address to a server, which then validates the number and returns an XML response indicating whether the number is valid or invalid.

The XML response should be in the following format;

 <response>
    <customer>
       <id>123456789</id>
       <valid>valid</valid>
    </customer>
 </response>

You can also return an error or confirmation message if you wish. The example below shows this as well as an invalid response.

 <response>
    <customer>
       <id>1234567890</id>
       <valid>invalid</valid>
       <msg>must be 11 digits</msg>
    </customer>
 </response>

Validating using a Database

You may wish to validate the account number against a customer database located on your server at "http://yourdomain.com"

To validate that the account number is correct, you will need to create a script at "http://yourdomain.com/customer.php", for example, and pass the account number as a parameter to this URL.

Thus, "http://yourdomain.com/customer.php?id=1234567890" will attempt to validate that the account number "1234567890" is valid.

The URL entered into the "Provide a URL to validate the Customer Account Number" field in your checkout preferences in this instance would be http://yourdomain.com/customer.php?id={id} which passes the {id} parameter from your store checkout to the customer.php script on your server.

When a customer enters a customer account number in the checkout, the checkout posts the query to your external script, and your script would check the customer number and then return an XML response saying whether the customer number is valid.

Validating using an Algorithm

Another use for this function is to validate the customer number using an algorithm, which many larger companies may use to create their customer numbers.

To validate that a customer number is correct, you could create a script at "http://yourdomain.com/customer.php" that we pass information to, which then checks against the algorithm to see if the customer number is valid.

The URL entered into the "Provide a URL to validate the Customer Account Number" field in your checkout preferences in this instance would also be http://yourdomain.com/customer.php?id={id} which passes the {id} parameter from your store checkout to the customer.php script on your server.

When a customer enters a customer number in the checkout, the checkout posts the query to your external script, and your script checks the customer number against the algorithm, and returns an XML response saying whether the customer number is valid.

Sample Code

The following is a sample validation script written in PHP. You may use any web language to write the validation routines, from PHP, Python, Perl, Ruby on Linux platforms, to ASP and .NET on Windows platforms.

<?php
error_reporting(E_ALL);
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-type: text/xml");

function validation_routine($number) {
  // Enter your validation code here....

  // Set result to TRUE or FALSE
  return result;
}

$customer_id_valid = 'invalid';

if (isset($_GET['id']))
{
  $customer_id = trim($_GET['id']);
  
  if (preg_match('/^\d{8}$/', $customer_id) == 1) // This validates the number of digits (e.g. 8)
  {
    if (validation_routine($customer_id))
    {
      $customer_id_valid = 'valid';
      $message = 'is valid';
    }
    else
    {
      $message = 'is invalid';
    }
  }
  else
  {
    $message = 'must be 8 digits';
  }
}
else
{
  $message = 'not supplied';
}  

/* Dom document */
$dom = new DOMDocument("1.0","iso-8859-1");

/* Create all elements */
$response = $dom->createElement("response"); //root element
$customer = $dom->createElement("customer");
$id = $dom->createElement("id", $customer_id);
$valid = $dom->createElement("valid", $customer_id_valid);
$msg = $dom->createElement("msg", $message);

/* Now place them in the correct place in the tree */

$response->appendChild($customer);
$customer->appendChild($id);
$customer->appendChild($valid);
$customer->appendChild($msg);

$dom->appendChild($response);

echo $dom->saveXML();
?>

Additional Content & Scripts

You can include custom html, tracking pixels and even scripts on the last page of the checkout. See Conversion Tracking for more information.