Download the PHP package tshimologomoeng/payfast-php without Composer
On this page you can find all versions of the php package tshimologomoeng/payfast-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tshimologomoeng/payfast-php
More information about tshimologomoeng/payfast-php
Files in tshimologomoeng/payfast-php
Package payfast-php
Short Description Modern PHP package for PayFast payment integration
License MIT
Informations about the package payfast-php
PayFast PHP Package
Modern PHP package for PayFast payment integration with automatic signature generation and webhook handling.
Features
- ✅ Simple payment integration
- ✅ Onsite payments (embedded checkout)
- ✅ Recurring billing (subscriptions)
- ✅ Tokenization payments
- ✅ Split payments
- ✅ Automatic signature generation
- ✅ Webhook (ITN) validation
- ✅ Sandbox/Production mode toggle
- ✅ PHP 8.1+ with full type safety
Installation
Requirements
- PHP 8.1 or higher
- cURL extension
- HTTPS required for onsite payments
Table of Contents
- Simple Payment Integration
- Onsite Payments
- Recurring Billing (Subscriptions)
- Tokenization
- Split Payments
- Webhook Handler
- Testing
Simple Payment Integration
Redirect users to PayFast's payment page.
or you can send the data to your frontend and directed them from there.
Onsite Payments
Embed PayFast's payment form directly on your checkout page.
Important: Requires HTTPS for security.
PHP Setup
For complete JavaScript implementation, see PayFast Onsite Documentation.
Recurring Billing (Subscriptions)
Set up automatic recurring payments.
Important: Passphrase is required for subscriptions.
Subscription Frequencies
SubscriptionFrequency::DailySubscriptionFrequency::WeeklySubscriptionFrequency::MonthlySubscriptionFrequency::QuarterlySubscriptionFrequency::BiannuallySubscriptionFrequency::Annually
Free Trial
Set initial amount to R0.00 for a free trial period:
Tokenization
Save customer payment details for future ad-hoc charges.
Update Card Details
Generate a link for customers to update their saved card:
Split Payments
Instantly split payments with a third party merchant.
Note: Must be enabled on your PayFast account.
Calculation Examples:
- Percentage only: R400 with 10% = R360 to you, R40 to third party
- Amount only: R400 with R50 = R350 to you, R50 to third party
- Both: R400 with 10% + R5 = (R400 - R40) - R5 = R355 to you, R45 to third party
- With max: R400 with 10%, max R20 = R380 to you, R20 to third party
Webhook Handler
Simple Payment Webhook
Subscription Webhook
Webhook Security
The webhook handler performs these security checks:
- ✅ Signature verification - Ensures data wasn't tampered with
- ✅ IP validation - Confirms request is from PayFast servers
- ✅ Amount validation - Verifies payment amount matches expected
- ✅ Server confirmation - Validates with PayFast's servers
Available Payment Methods
You can force a specific payment method using the PaymentMethod enum:
Available options:
PaymentMethod::EFT- Electronic Funds TransferPaymentMethod::Credit_Card- Credit CardPaymentMethod::Debit_Card- Debit CardPaymentMethod::Apple_Pay- Apple PayPaymentMethod::Samsung_Pay- Samsung PayPaymentMethod::Google_Pay- Google PayPaymentMethod::Capitec_Pay- Capitec PayPaymentMethod::SnapScan- SnapScanPaymentMethod::Zapper- ZapperPaymentMethod::Mobicred- MobicredPaymentMethod::MoreTyme- MoreTymePaymentMethod::Store_card- Store CardPaymentMethod::Mukuru- MukuruPaymentMethod::SCode- SCodePaymentMethod::Masterpass_Scan_to_Pay- Masterpass
Testing
Running Tests
Or add to composer.json:
Then run:
PayFast Sandbox Credentials
For testing, use PayFast's sandbox credentials:
- Merchant ID:
10000100 - Merchant Key:
46f0cd694581a - Sandbox URL:
https://sandbox.payfast.co.za
Test Card Details
Use these test cards in sandbox mode:
- Successful payment: 4000 0000 0000 0002
- Failed payment: 4000 0000 0000 0010
Configuration
Sandbox vs Production
Using Passphrase (Recommended)
For added security, set a passphrase in your PayFast dashboard and include it:
Note: Passphrase is required for subscriptions and tokenization.
Error Handling
API Reference
PayfastSimpleIntegration
Constructor
Methods
set_customer_details()
set_transaction_details()
get_payment_url()
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-feature-name) - Commit your changes (
git commit -m 'your-message (informative)') - Push to the branch (
git push origin feature/your-feature-name) - Open a Pull Request
License
MIT License - see LICENSE file for details
Support
-name
- 📧 Email: [email protected]
- 🐛 Issues: GitHub Issues
- 📚 PayFast Docs: https://developers.payfast.co.za
Changelog
2.0.0 (Current)
- ✨ Added onsite payments
- ✨ Added recurring billing/subscriptions
- ✨ Added tokenization
- ✨ Added split payments
- ✨ Added custom exceptions
- ✨ Added tests
- 📝 Improved documentation
1.0.2
- Fixed autoload issues
- Improved documentation
- Added webhook validation
1.0.0
- Initial release
- Simple payment integration
- Webhook handler
Note: This is an unofficial package and is not affiliated with PayFast. Always refer to the official PayFast documentation for the latest API specifications.