PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Szilágyi Gábor   Paypal Open Cart   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example php script
Class: Paypal Open Cart
Generate buttons to pay for products in Paypal
Author: By
Last change:
Date: 11 years ago
Size: 1,156 bytes
 

Contents

Class file image Download
<?php

//Example to use paypal object

include_once("paypal.class.php");

//You can set default options with constructor method
$paypalObject = new paypal("_cart","1","utf-8","paypal@yourdomain.com");

//Or other methods
$paypalObject->setCMD("_cart");
//For multiple items
$paypalObject->setUPLOAD(1);
$paypalObject->setCHARSET("utf-8");
$paypalObject->setMerchantID("paypal@yourdomain.com");
$paypalObject->setRETURN("http://www.yourdomain.com/payment-succesfull");

//Default way to add items to cart by passing to array (one for names and one for amounts)
$products = array("Test product 1","Test product 2");
$prices = array(100,200);
$paypalObject->setItems($products);
$paypalObject->setAmounts($prices);

//Other way is use the addItemToCart method (first param: item name, second param: amount)
$paypalObject->addItemToCart("Test product 3",300);

//Set the submit button ID and displayed text
$paypalObject->submitButtonID = "sendPaypal";
$paypalObject->submitButtonText = "Pay on paypal";

//Generate paypal form (parameter used to set submit button)
$cartForm = $paypalObject->cart(true);

echo
$cartForm;

?>