Top Related Projects
Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
PHP library for the Stripe API.
A framework agnostic, multi-gateway payment processing library for PHP 5.6+
Quick Overview
Laravel-pay is a payment integration package for Laravel, providing a unified API for multiple payment gateways. It supports popular Chinese payment platforms such as Alipay and WeChat Pay, making it easier for developers to implement payment functionality in their Laravel applications.
Pros
- Unified API for multiple payment gateways
- Easy integration with Laravel applications
- Supports popular Chinese payment platforms
- Actively maintained and updated
Cons
- Limited to Chinese payment gateways
- Documentation primarily in Chinese
- May require additional configuration for international use
- Learning curve for developers unfamiliar with Chinese payment systems
Code Examples
- Creating a pay order:
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_trade_no' => time(),
'total_amount' => '1',
'subject' => 'test subject - 测试',
];
$result = Pay::alipay()->web($order);
- Handling a payment notification:
use Yansongda\LaravelPay\Facades\Pay;
$data = Pay::alipay()->verify();
- Refunding a payment:
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_trade_no' => '1514027114',
'refund_amount' => '0.01',
];
$result = Pay::alipay()->refund($order);
Getting Started
- Install the package via Composer:
composer require yansongda/laravel-pay
- Publish the configuration file:
php artisan vendor:publish --provider="Yansongda\LaravelPay\PayServiceProvider" --tag=laravel-pay
- Configure your payment gateways in
config/pay.php
:
'alipay' => [
'app_id' => 'your-app-id',
'ali_public_key' => 'your-alipay-public-key',
'private_key' => 'your-private-key',
],
'wechat' => [
'app_id' => 'your-app-id',
'mch_id' => 'your-merchant-id',
'key' => 'your-key',
],
- Use the
Pay
facade in your controllers or services to interact with payment gateways.
Competitor Comparisons
Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
Pros of Cashier-Stripe
- Officially maintained by Laravel, ensuring long-term support and compatibility
- Comprehensive documentation and extensive community support
- Seamless integration with Stripe's subscription and billing features
Cons of Cashier-Stripe
- Limited to Stripe payment gateway only
- May be overkill for simple payment processing needs
- Steeper learning curve for developers new to Stripe's ecosystem
Code Comparison
Laravel-pay:
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_trade_no' => '1234567890',
'total_amount' => '1',
'subject' => 'test subject',
];
$result = Pay::alipay()->web($order);
Cashier-Stripe:
use Laravel\Cashier\Cashier;
$user->newSubscription('default', 'price_monthly')
->create($paymentMethod);
$user->charge(100, $paymentMethod);
Key Differences
- Laravel-pay supports multiple payment gateways (Alipay, WeChat Pay), while Cashier-Stripe focuses solely on Stripe
- Cashier-Stripe provides more advanced subscription and billing features out of the box
- Laravel-pay offers a simpler API for basic payment processing across different gateways
Both packages have their strengths, with Laravel-pay being more versatile for multiple payment gateways and Cashier-Stripe excelling in Stripe-specific features and subscription management.
PHP library for the Stripe API.
Pros of stripe-php
- Comprehensive SDK for Stripe's payment platform, offering a wide range of features and payment methods
- Extensive documentation and community support
- Regular updates and maintenance by Stripe's team
Cons of stripe-php
- Focused solely on Stripe, limiting flexibility for multi-gateway integrations
- Steeper learning curve for developers new to Stripe's ecosystem
- Requires more setup and configuration compared to Laravel-specific packages
Code Comparison
stripe-php:
\Stripe\Stripe::setApiKey('sk_test_...');
$charge = \Stripe\Charge::create([
'amount' => 2000,
'currency' => 'usd',
'source' => 'tok_visa',
'description' => 'Example charge',
]);
laravel-pay:
$order = [
'out_trade_no' => time(),
'total_amount' => '1',
'subject' => 'test subject',
];
return Pay::alipay()->web($order);
Key Differences
- laravel-pay is specifically designed for Laravel, offering easier integration with the framework
- stripe-php provides more detailed control over Stripe-specific features
- laravel-pay supports multiple payment gateways (Alipay, WeChat Pay) out of the box, while stripe-php focuses solely on Stripe
- stripe-php requires more setup but offers more flexibility for complex Stripe integrations
- laravel-pay provides a simpler API for basic payment processing tasks in Laravel applications
A framework agnostic, multi-gateway payment processing library for PHP 5.6+
Pros of Omnipay
- Supports a wide range of payment gateways (100+)
- Provides a consistent interface for different payment providers
- Well-established project with a large community and extensive documentation
Cons of Omnipay
- Not specifically designed for Laravel, requiring additional setup
- May have more complexity due to its broad scope
- Slower release cycle and updates compared to Laravel-specific packages
Code Comparison
Laravel-pay:
use Yansongda\Pay\Pay;
$config = [
'alipay' => [ ... ],
'wechat' => [ ... ],
];
$pay = Pay::config($config);
$result = $pay->driver('alipay')->gateway('web')->pay($order);
Omnipay:
use Omnipay\Omnipay;
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('your-username');
$gateway->setPassword('your-password');
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD'])->send();
Summary
Laravel-pay is tailored for Laravel applications with a focus on popular Chinese payment gateways, offering simpler integration for these specific use cases. Omnipay provides a more comprehensive solution for multiple payment gateways globally but may require additional setup for Laravel projects. The choice between the two depends on the specific payment gateways needed and the desired level of integration with Laravel.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Pay
ä¾èµ
- php >= 8.0
- composer
- laravel || lumen >= 8.0
å®è£
composer require yansongda/laravel-pay:~3.7.0
laravel ç¨æ·
é ç½®æ件
php artisan vendor:publish --provider="Yansongda\LaravelPay\PayServiceProvider" --tag=laravel-pay
lumen ç¨æ·
é ç½®æ件
请æå¨å¤å¶é ç½®æ件
service provider
$app->register(Yansongda\LaravelPay\PayServiceProvider::class);
使ç¨æ¹æ³
æ¯ä»å®
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_trade_no' => time(),
'total_amount' => '1',
'subject' => 'test subject - æµè¯',
];
return Pay::alipay()->web($order);
// ä¸é¢è¿ä¸ªæ¹æ³ä¹å¯ä»¥
// return Pay::web($order);
微信
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_trade_no' => time(),
'body' => 'subject-æµè¯',
'total_fee' => '1',
'openid' => 'onkVf1FjWS5SBIixxxxxxxxx',
];
$result = Pay::wechat()->mp($order);
æé³æ¯ä»
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'out_order_no' => date('YmdHis').mt_rand(1000, 9999),
'total_amount' => 1,
'subject' => 'é«åµ©è¾¾ - test - subject - 01',
'body' => 'é«åµ©è¾¾ - test - body - 01',
'valid_time' => 600,
'expand_order_info' => json_encode([
'original_delivery_fee' => 15,
'actual_delivery_fee' => 10
])
];
$result = Pay::douyin()->mini($order);
æ±èé¶è¡(eèæ¯ä»)
use Yansongda\LaravelPay\Facades\Pay;
$order = [
'outTradeNo' => time().'',
'proInfo' => 'subject-æµè¯',
'totalFee'=> 1,
];
$result = Pay::jsb()->scan($order);
å ·ä½ä½¿ç¨è¯´æè¯·ä¼ éè³ https://github.com/yansongda/pay
License
MIT
Top Related Projects
Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
PHP library for the Stripe API.
A framework agnostic, multi-gateway payment processing library for PHP 5.6+
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot