Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/addtocart.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of azizny  >  Paypal Class  >  examples/addtocart.php  >  Download  
File: examples/addtocart.php
Role: Example script
Content type: text/plain
Description: Add to cart using Paypal Cart
Class: Paypal Class
Create buttons and process Paypal payments
Author: By
Last change:
Date: 2008-10-29 07:02
Size: 2,421 bytes
 

Contents

Class file image Download
<?php

/**************************************************/
/*
Released by AwesomePHP.com, under the GPL License, a
copy of it should be attached to the zip file, or
you can view it on http://AwesomePHP.com/gpl.txt
*/
/**************************************************/

/*
This file will display
a form to make an add to cart
*/


/* Get Paypal Class */
require_once('../paypal.class.php');

/***************************** ADD TO CART (HOSTED) EXAMPLE *****************************/
/* Start Class */
$doAddToCart = new Paypal;

/*
Do you want to test payments
before you actually make a real
payment? If So use the test mode:


$doAddToCart->useSandBox(true);


You will also need to create a sandbox account
https://developer.paypal.com/
and then create a test account to which you will
use when making the test payments
*/

/*
Add variables to Form 
PARAMTERS MUST ADHERE TO PAYPAL STANDARDS
View all paramters @ PaypalVariables.html
located in main folder of this class
*/
$doAddToCart->addVar('business','itnnetwork@gmail.com');    /* Payment Email */
$doAddToCart->addVar('cmd','_cart');
$doAddToCart->addVar('currency_code','USD');
$doAddToCart->addVar('add','1');        /* Add to Cart */

/* Use display to show cart, (WILL NOT ADD THE ITEM ) 
$doAddToCart->addVar('display','1');
*/

/* Item to Add */
$doAddToCart->addVar('item_name','Script Support');
$doAddToCart->addVar('item_number','PHPCLASS8');
$doAddToCart->addVar('amount','99.25');
$doAddToCart->addVar('quantity','2');


$doAddToCart->addVar('rm','2');            /* Return method must be POST (2) for this class */
/* Paypal IPN URL - MUST BE URL ENCODED */
$doAddToCart->addVar('notify_url','http://awesomephp.com/Demos/Classes/PaypalClass/examples/checkpayment.php');
$doAddToCart->addVar('cancel_return','http://awesomephp.com/Demos/Classes/PaypalClass/examples/checkpayment.php');
/*
Thank you Page (if any) - not included in this package*/
/* 
$doDonate->addVar('return','thanks.html');
*/

/*
Now add a button
*/
$doAddToCart->addButton(2);    /* Default add-to-cart button */
/* or use custom buttons */
/*
$doAddToCart->addButton(6,'http://farm1.static.flickr.com/82/buddyicons/78814628@N00.jpg');
*/
/* Show final form */
$doAddToCart->showForm();

/*
To get the form in URL Form (when supported)
You use:
*/
echo '<a href="'.$doAddToCart->getLink().'">Click Here</a>';
?>