Convert Figma logo to code with AI

yansongda logolaravel-pay

可能是我用过的最优雅的 Alipay/WeChat/Unipay 的 laravel 支付扩展包了

1,071
183
1,071
0

Top Related Projects

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

PHP library for the Stripe API.

5,922

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

  1. 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);
  1. Handling a payment notification:
use Yansongda\LaravelPay\Facades\Pay;

$data = Pay::alipay()->verify();
  1. Refunding a payment:
use Yansongda\LaravelPay\Facades\Pay;

$order = [
    'out_trade_no' => '1514027114',
    'refund_amount' => '0.01',
];

$result = Pay::alipay()->refund($order);

Getting Started

  1. Install the package via Composer:
composer require yansongda/laravel-pay
  1. Publish the configuration file:
php artisan vendor:publish --provider="Yansongda\LaravelPay\PayServiceProvider" --tag=laravel-pay
  1. 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',
],
  1. 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
5,922

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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