PHP Classes

File: examples/addtocart2.php

Recommend this page to a friend!
  Classes of azizny   Paypal Class   examples/addtocart2.php   Download  
File: examples/addtocart2.php
Role: Example script
Content type: text/plain
Description: Add to cart Using Own Shopping Cart
Class: Paypal Class
Create buttons and process Paypal payments
Author: By
Last change:
Date: 15 years ago
Size: 2,655 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
Will not use Paypal Cart, but our own cart
*/


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

/***************************** ADD TO CART (NOT 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('upload','1'); /* Third Party Cart */

/* We will add 2 items to cart, you can add more, just change the _X number incrementally */
$doAddToCart->addVar('item_name_1','Script Support');
$doAddToCart->addVar('item_number_1','PHPCLASS8');
$doAddToCart->addVar('amount_1','99.25');
$doAddToCart->addVar('quantity_1','2');

$doAddToCart->addVar('item_name_2','Script Support 2');
$doAddToCart->addVar('item_number_2','PHPCLASS7');
$doAddToCart->addVar('amount_2','990.25');
$doAddToCart->addVar('quantity_2','1');


$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>';
?>