PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Mubashir Ali   Paypal Invoice API   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: This file contains the sample- There are two PayPal Invoice API services are used that are CreateInvoice and SendInvoice. For other API services the structure has been defined.
Class: Paypal Invoice API
Create and manage invoices Paypal Invoicing API
Author: By
Last change: $this is replaced with $ppInv.
$this was causing the FATEL ERROR. Now that error is removed
Date: 12 years ago
Size: 5,259 bytes
 

Contents

Class file image Download
<?php

   
/**
     * @author Mubashir Ali (Lahore, Pakistan)
     * saad_ali6@yahoo.com
     * @category Paypal Invoice API
     * @@abstract This class performs the PAYPAL INVOICE API's operations
     * @since 23-12-2011
     * @version 1.0
     * @todo Basic functionalities are performed - workflow of pending tasks still left
     * There is sample Array data is also entered to view the demo
     */

   
$API_Username = "xxxxxxxxxxxxxxxxx.xxx.xxx";
   
$API_Password = "xxxxxxxxxx";
   
$Signature = "xxxxxxxxxxxxxxxxx.xxxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxx";
   
$business = "xxxxxxxx@xxxxxx.xxx";

    require_once(
'class.invoice.php');
   
   
$ppInv = new PaypalInvoiceAPI("sandbox"); //pass 'live' for actual paypal account

    /**
     * Populate Data
     */
   
$aryData['language'] = "en_US";
   
$aryData['merchantEmail'] = $business;

   
$aryData['payerEmail'] = "xxx@xxx.xxx";
   
$aryData['currencyCode'] = "USD";
   
//$aryData['orderId'] = "0001";
   
$aryData['orderId'] = strtotime('now');
   
$aryData['invoiceDate'] = "2011-12-31T05:38:48Z";
   
$aryData['dueDate'] = "2011-12-31T05:38:48Z";
   
$aryData['paymentTerms'] = "Net45"; //[DueOnReceipt, DueOnDateSpecified, Net10, Net15, Net30, Net45]
   
$aryData['discountPercent'] = "5";
   
$aryData['discountAmount'] = "5.00";
   
$aryData['invoiceTerms'] = "These are Inovice Terms and Conditions";
   
$aryData['invoiceNote'] = "These are Invoice notes";
   
$aryData['merchantMemo'] = "This is Merchant Memo";
   
$aryData['shippingAmount'] = "10.00";
   
$aryData['shippingTaxName'] = "S Tax Name";
   
$aryData['shippingTaxRate'] = "5.00";
   
$aryData['logoURL'] = "Company Logo URL";

   
$aryData['merchantFirstName'] = "Merchant First Name";
   
$aryData['merchantLastName'] = "Merchant Last Name";
   
$aryData['merchantBusinessName'] = "Merchant Business Name";
   
$aryData['merchantPhone'] = "132131232-1321-3131";
   
$aryData['merchantFax'] = "12-312-312-123";
   
$aryData['merchantWebsite'] = "Merchant Website";
   
$aryData['merchantCustomValue'] = "Company Custom Value";

   
$aryData['merchantLine1'] = "Merchant Address Line 1";
   
$aryData['merchantLine2'] = "Merchant Address Line 2";
   
$aryData['merchantCity'] = "Merchant City";
   
$aryData['merchantState'] = "Merchant State";
   
$aryData['merchantPostalCode'] = "Zip Code";
   
$aryData['merchantCountryCode'] = "US";

   
$aryData['billingFirstName'] = "Billing First Name";
   
$aryData['billingLastName'] = "Billing Last Name";
   
$aryData['billingBusinessName'] = "Billing Business Name";
   
$aryData['billingPhone'] = "Billing Phone";
   
$aryData['billingFax'] = "Billing Fax";
   
$aryData['billingWebsite'] = "Billing Website";
   
$aryData['billingCustomValue'] = "Billing Custom Value";

   
$aryData['billingLine1'] = "Billing Line 1";
   
$aryData['billingLine2'] = "Billing Line 2";
   
$aryData['billingCity'] = "Billing City";
   
$aryData['billingState'] = "Billing State";
   
$aryData['billingPostalCode'] = "Billing Postal Code";
   
$aryData['billingCountryCode'] = "US";

   
$aryData['shippingFirstName'] = "Shipping First Name";
   
$aryData['shippingLastName'] = "Shipping Last Name";
   
$aryData['shippingBusinessName'] = "Shipping Business Name";
   
$aryData['shippingPhone'] = "Shipping Phone";
   
$aryData['shippingFax'] = "Shipping Fax";
   
$aryData['shippingWebsite'] = "Shipping Website";
   
$aryData['shippingCustomValue'] = "Shipping Custom Value";

   
$aryData['shippingLine1'] = "Shipping Line 1";
   
$aryData['shippingLine2'] = "Shipping Line 2";
   
$aryData['shippingCity'] = "Shipping City";
   
$aryData['shippingState'] = "Shipping State";
   
$aryData['shippingPostalCode'] = "Shipping Postal Code";
   
$aryData['shippingCountryCode'] = "US";

   
$aryItems[0]['name'] = "Item 1";
   
$aryItems[0]['description'] = "Item 1 Description";
   
$aryItems[0]['date'] = "2011-12-31T05:38:48Z";
   
$aryItems[0]['quantity'] = "2";
   
$aryItems[0]['unitprice'] = "10.00";
   
$aryItems[0]['taxName'] = "I Tax Name";
   
$aryItems[0]['taxRate'] = "5.00";

   
/**
     * Create Invoice Task
     */
   
echo "<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />";
   
$res = $ppInv->doCreateInvoice($aryData, $aryItems);

// echo "<pre>";
// print_r($res);
// echo "</pre>";

   
if($res['responseEnvelope.ack']== "Success")
    {
        echo
"<br />Success Creating Invoice: '{$res['invoiceID']}'";

        echo
"<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />";
       
       
$res_send = $ppInv->doSendInvoice($res['invoiceID']);

   
// echo "<pre>";
    // print_r($res_send);
    // echo "</pre>";

       
if($res_send['responseEnvelope.ack']== "Success")
        {
            echo
"<br />Success Sending Invoice";
        }
        else
        {
           
//Get Error String
           
echo $ppInv->formatErrorMessages($res_send);
        }
    }
    else
    {
       
//Get Error String
       
echo $ppInv->formatErrorMessages($res);
    }


?>