π¦ Complete Package
ITS PayPal Payment System
A complete, standalone PayPal payment system with server-side OAuth2 verification, multi-plan support, affiliate tracking, and drop-in simplicity. 685 lines of code. PHP 5.6+ compatible.
π¦ Package Contents
| File | Lines | Purpose |
| pricing.php | 250 | Main pricing page with plans + payment popup |
| checkout.php | 180 | Server-side PayPal verification + sale recording |
| db_config.php | 55 | Database connection + PayPal credentials |
| schema.sql | 80 | All required database tables + seed data |
| README.md | 120 | Full setup instructions + documentation |
β
Features
β Multi-Plan Support β Add unlimited products via a simple PHP array
β PayPal Smart Buttons β Gold, pill-shaped, fully responsive
β Server-Side OAuth2 Verification β Confirms every order
β Duplicate Prevention β UNIQUE index on payment_id
β Affiliate Tracking β Pass ?id=TOKENKEY for commissions
β Download Token β 64-char hex for digital delivery
β Isolated CSS β Drop into any page without conflicts
β Single Currency (GBP) β No conversion complexity
β PHP 5.6+ Compatible β Works on virtually any server
β Sandbox & Live Modes β One toggle to switch
β Dual Database β mysqli + PDO fallback
β FormData POST β Reliable on all servers
π How It Works
1
Customer visits pricing page, sees your plans
2
Clicks "View Plans & Pay" β popup opens
3
Selects a plan β PayPal button renders
4
Clicks PayPal β logs in and approves
5
onApprove fires β POST to checkout.php
6
checkout.php verifies via OAuth2 API
7
Sale recorded in database
8
Customer redirected to success
ποΈ Payment Flow Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PAYMENT FLOW ARCHITECTURE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
β β Customer β β PayPal JS β β PayPal Orders β β
β β clicks βββββΆβ SDK Button βββββΆβ API v2 β β
β β "Pay" β β (Client) β β (OAuth2 Verify)β β
β ββββββββββββ ββββββββββββββββ ββββββββββ¬βββββββββ β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β checkout.php β β
β β β’ Receives orderID via FormData POST β β
β β β’ Server-to-server verification via OAuth2 β β
β β β’ Saves to its_product_sales table β β
β β β’ Generates download_token (64-char hex) β β
β β β’ Duplicate prevention (UNIQUE on payment_id) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Security Layers
π
Client β PayPal handles card data
π
Transport β HTTPS + encryption
β
Verification β Server OAuth2
π‘οΈ
Duplicate β UNIQUE index
π Quick Start Guide
1
Run schema.sql in your MySQL database
2
Edit db_config.php with credentials
3
Customise $customPlans array
4
Upload all files to your server
5
Test with PayPal Sandbox
6
Set SANDBOX to false β go live!
β Adding New Products
Edit the $customPlans array in pricing.php. The PayPal button automatically works with whatever you add. No JavaScript changes needed.
array(
'id' => 'my-product',
'name' => 'My Product',
'price' => '99.00',
'period' => '/one-time',
'features' => 'Feature 1 Β· Feature 2 Β· Feature 3',
'badge' => '',
'commission' => '19.80'
),
π Affiliate Tracking
Add ?id=PARTNER_TOKEN to any link. Query sales by tokenkey to calculate commissions.
pricing.php?id=abc123
SELECT tokenkey, SUM(amount) AS total
FROM its_product_sales
WHERE tokenkey = 'abc123'
GROUP BY tokenkey;
βοΈ Requirements
π PHP 5.6 or higher
ποΈ MySQL 5.7 or higher
π curl, mysqli (or PDO), openssl
π³ PayPal Business Account