Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/subscribe.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/subscribe.php  >  Download  
File: examples/subscribe.php
Role: Example script
Content type: text/plain
Description: Subscriptions
Class: Paypal Class
Create buttons and process Paypal payments
Author: By
Last change:
Date: 2008-10-29 07:04
Size: 2,856 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 a subscription
*/


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

/***************************** SUBSCRIPTION EXAMPLE *****************************/
/* Start Class */
$doSubscribe = new Paypal;

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


$doSubscribe->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
*/
$doSubscribe->addVar('business','itnnetwork@gmail.com');    /* Payment Email */
$doSubscribe->addVar('cmd','_xclick-subscriptions');
$doSubscribe->addVar('currency_code','USD');
$doSubscribe->addVar('item_name','Script Support');
$doSubscribe->addVar('item_number','PHPCLASS8');

/* Set Free Trials */
$doSubscribe->addVar('a1','0');    /* 0 Cost */
$doSubscribe->addVar('p1','1'); /* For 30 */
$doSubscribe->addVar('t1','M'); /* Days */
/* Allowed t's: D -> Days, W -> Weeks , M -> Months, Y -> Years */

/* a2 can also be another trial period */

/* Regular Subscription Rates */
$doSubscribe->addVar('a3','99');    /* 0 Cost */
$doSubscribe->addVar('p3','1');     /* For 1 */
$doSubscribe->addVar('t3','M');     /* Year */

/* Unlimited recurring payments (till cancelled) */
$doSubscribe->addVar('src','1');
/* Try payment again if it ever fails */
$doSubscribe->addVar('sr1','1');

/* No note, required */
$doSubscribe->addVar('no_note','1');

$doSubscribe->addVar('rm','2');            /* Return method must be POST (2) for this class */
/* Paypal IPN URL - MUST BE URL ENCODED */
$doSubscribe->addVar('notify_url','http://awesomephp.com/Demos/Classes/PaypalClass/examples/checkpayment.php');
$doSubscribe->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
*/
$doSubscribe->addButton(5);    /* Default subscription button */
/* or use custom buttons */
/*
$doSubscribe->addButton(6,'http://farm3.static.flickr.com/2154/2173129258_2c40a673f5.jpg?v=0');
*/
/* Show final form */
$doSubscribe->showForm();

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