Information and support for products of WithinWeb.com

 header image 1

How to sell serial license keys for digital goods using PHP-KeyCodes

July 1st, 2017 · No Comments

If you sell digital products online such as software programs, games, phone PIN numbers and so on, then PHP-KeyCodes can be a useful application to install on your web site.

It requires a web server running PHP and access to a MySQL database. It is easy to install with a one page install script and upload of files to your server.

If you have a requirement to sell codes on line then this is a better method than using someone else’s web site as you do not have to pay them any fees.

Using a license system for your software program helps to prevent fraud and allows you to send free trial versions to customers.

The key codes are loaded into the PHP-KeyCodes web site administration interface so that they are automatically sent whenever there is a purchase using PayPal.

The system will also send you an email when it is getting low on licence keys.

The usual way to use PHP-KeyCodes is to enter the codes into the admin area so that the next code in the list is taken and sent when there is a purchase.

The PHP script has been written in such a way as to allow you to modify the program to cover other situations. So for example you may have codes in a text file that you want to upload to the server. You could modify the code to use such a text file.

You could even have code that generates a key code depending on the user name or email address.

If you have particular requirements, then we would be willing to customize the code for you.

→ No CommentsTags: General PHP · PHP-KeyCodes

A guide to sell digital downloads online

June 23rd, 2017 · No Comments

Digital goods or electronic goods or digital products or e-goods are anything you can sell that is in a digital format. The types of products include ebooks, software, website templates, music, videos, licence codes and ringtones. The costs of adding a digital item to a shopping system is small so it can be a great way make a steady income.

Here are just a few of the perks to selling digital downloads:

• No inventory – you have no stock levels to maintain so you have no storage problems or supply problems.

• Costs the same to sell one or thousands.

• No postage costs.

• The customer will instantly receive the product.

• The transaction is quickly completed so you have the money in your account straight away.

Some online services specialize in selling digital goods, including invoicing, payment, and delivering the digital copy.

Alternatively you can have a shopping cart on your web site that you install yourself or get a developer to install for you.

Picking a service can be challenging, here’s some guidelines to help you get started:

1) Fees

Transaction and hosting fees will vary, some require a monthly subscription and others, just a percentage or both. Check which ones they require and what you can afford. Selling through PayPal is often a convenient way and they have a transaction fee.

2) Integration with your website

Make sure the service can integrate with your blog or website, it’s best to use a service that has a cart that can blend in with your website. Sometimes a provider has code you can cut and paste code into your web page.

3) Features

Here’s a few of the features that might be helpful:
Automatic product download
Have the option of no shipping
The ability to simultaneous sell tangible goods and e-goods

4) Security

It’s important that the purchase made by the client is secure. You should expect your customer, after purchasing your product, to receive a secure link to immediately download the purchased item. The link should expire within a certain amount of time. Some systems offer “digital stamping” with a unique ID so you can track who is sharing your digital download. Some services offer rules that allow you to choose # of clicks or # of days the link is valid.

5) Easy to Use

Make sure the transaction is smooth and easy for your customer, you want to make it easy so that your customer come back for more.

Here’s a great ecommerce guide from my site at
http://withinweb.com/global/hints_tips_and_tricks/digital_files.pdf
on further concepts for digital downloads.

My product PHP-eSeller is designed to sell digital goods from your web site using PayPal as the payment system. PHP-eSeller has a number of carts, and displays which enable you to integrate it to an existing site.

→ No CommentsTags: PHP-eSeller

Update to PHP-KeyCodes application

July 30th, 2016 · No Comments

PHP-KeyCodes admin area has been updated to improve its look at feel and give it a more modern appearance.  There is little in the way of technical change and so there is no requirement to upgrade any versions.   http://withinweb.com/phpkeycodes/demo.php

→ No CommentsTags: PHP-KeyCodes

How to stop the deduction by Amazon of 30% tax for non-US residence for book sales

May 11th, 2016 · No Comments

If you write and sell eBooks on Kindle and CreateSpace, and you are not a residence of the US, any sells made in the US have 30% tax deducted at source.  On top of that you will have to pay tax to your country of residence as you would for any untaxed income.

However there is an agreement between the US and other countries that enables you to have 0% deductions.  You still have to declare the earnings to your own tax office but you do save that 30% which can be quite significant.

To have 0% deducted is now fairly straight forward.  The process has improved quite considerably and you should be able to sort it out in half an hour and not have to phone the US tax office to get a tax number reference as you had to previously.

Log into your KDP Kindle account where you books are listed, click on the Account link.  You may have to log in again at this point.  The page that is displayed shows account and tax information.  Click on the View/Provide Tax Information button.  Now click on the Tax Interview button which will then take you to a series of questions.

Go through the questions.  I choose ‘individual’ as the type of organization which is probably what most people will do.  The important question is your tax reference – select that you are not a US resident and then enter in your NI (National Insurance number) or UTR (Unique Tax Reference), or the equivalent tax reference that is used in your country, then go through the rest of the questions.

A form will display (W8-Form) at the end which should show your tax deduction is 0%.  If you don’t see 0%, you must have selected something wrong, so cancel out and start again.

Take a screen shot of the form for record purposes.

You now have to sign the form electronically.

You do need to keep a record of sales as you may have to pass that value on to your tax office.  Amazon will send either a physical tax report or an email to you which you should retain if the tax office wants proof.

HMRC is the UK tax office and I have found them to be quite helpful if you are just declaring a small amount of un-taxed income (less than £2,500) when you are in full employment.  You don’t have to do a full tax return and they will just modify your tax code over the phone.  Obviously if there is much more untaxed income such as capital gains or company payments or you are self-employed then you will have to do a tax return, but many people are just writing a book to earn a small amount of cash while they are in full employment.

→ No CommentsTags: eBooks

Top 5 Raspberry Pi Projects

March 20th, 2016 · No Comments

Not in any particular order, here are my favorite Raspberry 5 projects.

(1) Install WordPress on a Raspberry Pi

Project – Pi WebServer

(2) Use a Raspberry Pi as a Network Storage Device

How to Turn a Raspberry Pi into a Low-Power Network Storage Device

(3) Create a VPN on a Raspberry Pi

Building A Raspberry Pi VPN Part One: How And Why To Build A Server

(4) Using a Raspberry Pi as a media server

http://www.instructables.com/id/Raspberry-Pi-Media-Server-MiniDLNA/

 

(5) Use a Raspberry Pi as a Wireless Access Point

How to Set up a Raspberry Pi as a Wireless Access Point

→ No CommentsTags: Other

Adding a virtual directory (folder) to Apache XAMPP or similar application

December 18th, 2015 · No Comments

Suppose that you have installed XAMPP at c:\xampp This will mean you place your web files at C:\xampp\htdocs

Now you want to start developing your project, so what you could do is copy all your files to the C:\xampp\htdocs or create another folder
such as C:\xampp\htdocs\myproject

However, this is not always convenient so how do you create an alias, leaving your files where they are.

First, open the httpd.conf file, it’s located in this directory:
C:\Program Files\xampp\apache\conf

You can access this from the XAMPP control panel by clicking the “config” button.

Add these lines on the bottom of the httpd.conf file:

Alias /sources “c:/myproject”

Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted

Note that in we must use “Forward Slash” or / in the folder definition

Restart XAMPP or stop and start Apache from the control panel.

Open your web browser and test it by go to http://localhost/myproject

→ No CommentsTags: General PHP

Update to PayPal IPN

December 18th, 2015 · No Comments

In Sept 2016 PayPal are changing their requirement for posting IPN messages back to PayPal for verification.

They are making the post url as https. My current versions of scripts already post to https so there should not be any change required, however, they also suggest that https://ipnpb.paypal.com/cgi-bin/webscr should be used in the future rather than https://www.paypal.com/cgi-bin/websc

Change:

https://www.paypal.com/cgi-bin/webscr

to

https://ipnpb.paypal.com/cgi-bin/webscr

→ No CommentsTags: PayPal · PHP-eSeller · PHP-KeyCodes · PHP-Register · PHP-SecureArea

PayPal upgrade to Certificate which may affect IPN based programs and scripts

September 29th, 2015 · No Comments

There appears to be quite a bit of chat about the changes that PayPal are making to their system to allow SHA-256 during September 2015. This is to do with improving the SSL (Secure Socket Layer) security and is used over https systems.

A part of their message is:

“PayPal is upgrading the certificate for www.paypal.com to SHA-256. This endpoint is also used by merchants using the Instant Payment Notification (IPN) product.”

PayPal IPN can be used over non SSL, that is using http – that is why many developers like it because it does not need SSL certificates on their web servers which can be expensive especially if you are a small trader. You don’t really want to have to purchase certificates if you are selling a small number of items.

So the kind of systems that are affected are those that use https and which use PayPal API to provide secure connections from your server to the PayPal server.

IPN over plain http will be supported as it currently is, so you will still be able to supply a plain http link to your IPN listener script. However if your IPN listener script is sSL/TLS enabled it will have to be SHA-256 complaint and your listening server will need to be able to accept SHA-256 certificates.

So do the changes affect the scripts on www.Withinweb.com that use IPN? Well the answer to that is NO, it does not affect the scripts at all.

PHP-eSeller, PHP-SecureArea and PHP-KeyCodes use a simple method of handshake between PayPal to verify that the transaction has taken place and hence no modifications are need to the applications.

→ No CommentsTags: PayPal · PHP-eSeller · PHP-KeyCodes · PHP-Register · PHP-SecureArea

A Shopping Cart using PHP Sessions

July 2nd, 2015 · 1 Comment

This posts illustrates a relatively simple shopping cart using PHP sessions to store the cart details, quantities and total cart amount. The cart has an ‘add to cart’, ‘remove from cart’ and displays the total value of the cart.

This post is taken from part of the book PHP Tutorials: Programming with PHP and MySQL which is available as a paper back printed version or as a downloadable Kindle version. Click here for paper back version.

The following listing is the complete cart:

<?php session_start();
#cart.php - A simple shopping cart with add, and remove links
 //---------------------------
 //initialise sessions

//Define the products and cost
$products = array("product A", "product B", "product C");
$amounts = array("19.99", "10.99", "2.99");

 if ( !isset($_SESSION["total"]) ) {

   $_SESSION["total"] = 0;
   for ($i=0; $i< count($products); $i++) {
    $_SESSION["qty"][$i] = 0;
   $_SESSION["amounts"][$i] = 0;
  }
 }

 //---------------------------
 //Reset
 if ( isset($_GET['reset']) )
 {
 if ($_GET["reset"] == 'true')
   {
   unset($_SESSION["qty"]); //The quantity for each product
   unset($_SESSION["amounts"]); //The amount from each product
   unset($_SESSION["total"]); //The total cost
   unset($_SESSION["cart"]); //Which item has been chosen
   }
 }

 //---------------------------
 //Add
 if ( isset($_GET["add"]) )
   {
   $i = $_GET["add"];
   $qty = $_SESSION["qty"][$i] + 1;
   $_SESSION["amounts"][$i] = $amounts[$i] * $qty;
   $_SESSION["cart"][$i] = $i;
   $_SESSION["qty"][$i] = $qty;
 }

  //---------------------------
  //Delete
  if ( isset($_GET["delete"]) )
   {
   $i = $_GET["delete"];
   $qty = $_SESSION["qty"][$i];
   $qty--;
   $_SESSION["qty"][$i] = $qty;
   //remove item if quantity is zero
   if ($qty == 0) {
    $_SESSION["amounts"][$i] = 0;
    unset($_SESSION["cart"][$i]);
  }
 else
  {
   $_SESSION["amounts"][$i] = $amounts[$i] * $qty;
  }
 }
 ?>
 <h2>List of All Products</h2>
 <table>
   <tr>
   <th>Product</th>
   <th width="10px">&nbsp;</th>
   <th>Amount</th>
   <th width="10px">&nbsp;</th>
   <th>Action</th>
   </tr>
 <?php
 for ($i=0; $i< count($products); $i++) {
   ?>
   <tr>
   <td><?php echo($products[$i]); ?></td>
   <td width="10px">&nbsp;</td>
   <td><?php echo($amounts[$i]); ?></td>
   <td width="10px">&nbsp;</td>
   <td><a href="?add=<?php echo($i); ?>">Add to cart</a></td>
   </tr>
   <?php
 }
 ?>
 <tr>
 <td colspan="5"></td>
 </tr>
 <tr>
 <td colspan="5"><a href="?reset=true">Reset Cart</a></td>
 </tr>
 </table>
 <?php
 if ( isset($_SESSION["cart"]) ) {
 ?>
 <br/><br/><br/>
 <h2>Cart</h2>
 <table>
 <tr>
 <th>Product</th>
 <th width="10px">&nbsp;</th>
 <th>Qty</th>
 <th width="10px">&nbsp;</th>
 <th>Amount</th>
 <th width="10px">&nbsp;</th>
 <th>Action</th>
 </tr>
 <?php
 $total = 0;
 foreach ( $_SESSION["cart"] as $i ) {
 ?>
 <tr>
 <td><?php echo( $products[$_SESSION["cart"][$i]] ); ?></td>
 <td width="10px">&nbsp;</td>
 <td><?php echo( $_SESSION["qty"][$i] ); ?></td>
 <td width="10px">&nbsp;</td>
 <td><?php echo( $_SESSION["amounts"][$i] ); ?></td>
 <td width="10px">&nbsp;</td>
 <td><a href="?delete=<?php echo($i); ?>">Delete from cart</a></td>
 </tr>
 <?php
 $total = $total + $_SESSION["amounts"][$i];
 }
 $_SESSION["total"] = $total;
 ?>
 <tr>
 <td colspan="7">Total : <?php echo($total); ?></td>
 </tr>
 </table>
 <?php
 }
 ?>

The cart example uses the following sessions to maintain the state of the cart:

$_SESSION[“qty”][i] Stores the quantity for each product
$_SESSION[“amounts”][i] Stores the price from each product
$_SESSION[“cart”][i] Identifies which items have been added to the cart
$_SESSION[“total”] Stores the total cost

The sessions are actually arrays so in the case of:

$_SESSION[“qty”][i]

is the quantity for the element with number i.

Description of the shopping cart code

We start by defining PHP to use sessions by:

session_start();

This has to be at the very top of the PHP page.

Next we set up our products and populate our sessions. In this example we are using a fixed array of product descriptions and amounts. You may want to do this in your application or you could read in the data into the $product and $amounts array from a database.

//---------------------------
 //initialise sessions

 //Define the products and cost
 $products = array("product A", "product B", "product C");
 $amounts = array("19.99", "10.99", "2.99");

 if ( !isset($_SESSION["total"]) ) {

  $_SESSION["total"] = 0;

  for ($i=0; $i< count($products); $i++) {
   $_SESSION["qty"][$i] = 0;
   $_SESSION["amounts"][$i] = 0;
 }
}

The following code will reset and clear the sessions when the Reset Cart link is selected.

//---------------------------
  //Reset
  if ( isset($_GET['reset']) )
   {
    if ($_GET["reset"] == 'true')
    {
     unset($_SESSION["qty"]); //The quantity for each product
     unset($_SESSION["amounts"]); //The amount from each product
     unset($_SESSION["total"]); //The total cost
     unset($_SESSION["cart"]); //Which item has been chosen
   }
}

The following code adds an item to the sessions when the ‘Add to Cart’ link is clicked:

//---------------------------
//Add
if ( isset($_GET["add"]) )
{
$i = $_GET["add"];

$qty = $_SESSION["qty"][$i] + 1;

$_SESSION["amounts"][$i] = $amounts[$i] * $qty;
$_SESSION["cart"][$i] = $i;
$_SESSION["qty"][$i] = $qty;
}

and the following deletes an item from the cart when the ‘Delete from Cart’ link is clicked:

 //---------------------------
 //Delete
 if ( isset($_GET["delete"]) )
 {
   $i = $_GET["delete"];
   $qty = $_SESSION["qty"][$i];
   $qty--;
   $_SESSION["qty"][$i] = $qty;

 //remove item if quantity is zero
 if ($qty == 0) {
   $_SESSION["amounts"][$i] = 0;
   unset($_SESSION["cart"][$i]);
 }
 else
 {
   $_SESSION["amounts"][$i] = $amounts[$i] * $qty;
 }
 }

The rest of the code is the visual display using a table and various loops to show the product lists and the cart details together with the links.

This post is taken from part of the book PHP Tutorials: Programming with PHP and MySQL which is available as a paper back printed version or as a downloadable Kindle version. Click here for paper back version.

→ 1 CommentTags: eBooks · General PHP

Word Large Documents with different header / footer

June 2nd, 2015 · No Comments

It is not immediately obvious how to do different header / footer for different Chapters in a long document.

The main control of this is by section breaks.  For each section that requires a different header / footer you use a new section break.

In word 2013, go to “PAGE LAYOUT” and select “Breaks”.  In the drop down list select Section Breaks -> Next Page
This inserts a section break and starts a new section on the next page.  Other versions of word will be similar.

Create your header in the normal way by double clicking on the head of the Word document.

Once you have your section breaks set up, the next important step is to control the linking between headers in different sections.  To do this you go into editing of the header by double clicking on it.  In the menu bar you should see “Link to Previous”.  If you are in the second section of a document, you click on this to unlink the header of the second section.  You can then edit the header in the second section and that will allow you to have a different header in that second section.

You can now do other clever things such as different header / footer for odd / even pages and that is controlled from the header menu bar by ticking the appropriate tick boxes.

→ No CommentsTags: eBooks