Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Creating custom PayPal billing invoices


Recommended Posts

This modification was created for a store which offers downloadable products as well as customization services for those products. We needed a way to create custom invoices based on quotes provided to customers. We also wanted a simple way for customers to pay their invoices so that their orders and invoices were updated automatically via PayPal IPN and viewable within their account history.


This modification allows you to integrate a billing system (invoices) within your catalog which will allow your customers to pay their invoices via PayPal directly from their accounts. Invoices are updated via PayPal IPN and viewable from the customer's account history.


Although created for one-time invoices, this could be modified for recurring payments by adding the extra PayPal variables for subscriptions to the account_history_info.php file.


1. Install osCommerce PayPal IPN contribution http://www.oscommerce.com/community/contributions,2679 (tested with v1.4)


2. Install Step by Step Manual Order contribution v1.8 http://www.oscommerce.com/community/contributions,1589 (Which will allow you to create new accounts and orders via admin.)


3. Create a new product in your catalog entitled "Customization Services" and DISABLE the status so that the product is not active/viewable within the public catalog. (for our catalog we set the price to $0.00 and the price is defined within each invoice that is created.)


4. open account_history_info.php (make a backup copy before modifying!)



You will need to know the product ID for the new Customization Services product and also the value of completed orders (quickest way is to click on each in your admin panel and get the value from the address bar).



around line 193 in account_history_info.php find:



for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {

echo ' <tr>' . "\n" .

' <td class="main" align="right" width="100%">' . $order->totals[$i]['title'] . '</td>' . "\n" .

' <td class="main" align="right">' . $order->totals[$i]['text'] . '</td>' . "\n" .

' </tr>' . "\n";




After this add




//define the status id for completed orders here

$completedpymt = 3;


//define the product id of the product "Customization Services" here

$iProduct = 18;


$product_info_query = tep_db_query("select p.products_id, o.orders_status from " . TABLE_ORDERS_PRODUCTS . " as p, " . TABLE_ORDERS . " as o where o.orders_id = '" . $HTTP_GET_VARS['order_id'] . "' AND p.orders_id = '" . $HTTP_GET_VARS['order_id'] . "'");

$product_info = tep_db_fetch_array($product_info_query);

$products_id = $product_info['products_id'];

$status = $product_info['orders_status'];


//if order status is not completed and product ID is "Customization Services" then display link for paypal payment


if (($products_id == $iProduct) && ($status != $completedpymt)) {

$form_action_url = 'https://secure.paypal.com/cgi-bin/webscr';


echo '<tr><td align="right" valign"bottom" colspan="2"><br><br>';

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');


echo tep_draw_hidden_field('cmd', '_xclick');

echo tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_IPN_ID);

echo tep_draw_hidden_field('item_name', STORE_NAME .' Customization Services ('. HTTP_SERVER .')');

echo tep_draw_hidden_field('amount', str_replace('$', '', $order->info['total']));

echo tep_draw_hidden_field('notify_url', tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', '', 'SSL', false, false));

echo tep_draw_hidden_field('no_note', '1');

echo tep_draw_hidden_field('no_shipping', '1');

echo tep_draw_hidden_field('custom', $customer_info['customers_id']);

echo tep_draw_hidden_field('currency_code', 'USD');

echo tep_draw_hidden_field('invoice', $HTTP_GET_VARS['order_id']);

echo tep_draw_hidden_field('return', tep_href_link(ACCOUNT_HISTORY_INFO, '', 'SSL'));

echo tep_draw_hidden_field('cancel_return', tep_href_link(ACCOUNT_HISTORY_INFO, '', 'SSL'));

echo tep_draw_hidden_field('cbt', 'Complete your Order Confirmation');

echo tep_draw_hidden_field('bn', 'osCommerce PayPal IPN v1.0');



echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";

echo '</td></tr>';






To create an invoice from admin side for existing customers:


1. Click on Customers >> Create Order

2. To include the order specifications or quote details, add the info to the comments section at the bottom of the next page.

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,


your post comes the closest to what I'm looking for, and i searched for a while in the forum.


I'm working on a shop that will offer standard physical products as well as downloadable software products.

In addition the software products need a monthly subscription (or membership / recurring fee) and I would like to have the recurring fee supported either by PayPal or Credit Card but would like to manage the subscription products (mainly frequency, price) as well as subsciber details (user, sign-up date, .payment / billing history) within OSC.


Have you managed to support recurring subscription fees with these changes ?


Could this be managed with the product attribute options ?


Or does anybody know of a contribution out there that supports recurring fees ?




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...