abdelwahidjobs/payment-checkout-api
Composer 安装命令:
composer require abdelwahidjobs/payment-checkout-api
包简介
Multi-provider PHP SDK for Payment Checkout APIs (PayPal & Stripe)
README 文档
README
This package is an enhanced multi-provider payment SDK that supports both PayPal and Stripe payment processing through a unified interface. It provides a simple, fluent API to create, capture, and refund payments with both sandbox and production environments supported.
Features:
- ✅ Unified interface for PayPal and Stripe payments
- ✅ Complete refund functionality for both providers
- ✅ Order creation and capture
- ✅ Sandbox and production environment support
- ✅ Comprehensive error handling
- ✅ Full working examples included
Installation
PayPal Checkout SDK Package requires PHP 7.4 or higher.
INFO: If you are using an older version of php this package may not function correctly.
The supported way of installing PayPal Checkout SDK package is via Composer.
composer require phpjuice/paypal-checkout-sdk
Quick Start Examples
This SDK includes comprehensive working examples to get you started quickly:
Available Example Files
example_usage.php- Basic usage examples for both PayPal and Stripecorrected_test.php- Corrected PayPal implementation exampleworking_example_with_refunds.php- Complete example with refund functionalityexample_refund_usage.php- Dedicated refund examples and advanced usage
Running the Examples
- Replace credential placeholders with your actual API keys in any example file
- Run:
php example_usage.php(or any other example file) - Follow the output instructions for completing payments
Setup
Credentials Setup
PayPal Credentials
Get client ID and client secret from PayPal Developer Console:
- Create a new REST API app
- Copy Client ID and Client Secret
Stripe Credentials
Get API keys from Stripe Dashboard:
- Copy Secret Key (starts with
sk_) - Copy Publishable Key (starts with
pk_)
Basic Provider Setup
use PayPal\Checkout\Factory\PaymentProviderFactory; // PayPal Provider $paypalProvider = PaymentProviderFactory::create('paypal', 'sandbox', [ 'client_id' => 'your_paypal_client_id', 'client_secret' => 'your_paypal_client_secret' ]); // Stripe Provider $stripeProvider = PaymentProviderFactory::create('stripe', 'sandbox', [ 'secret_key' => 'sk_test_your_stripe_secret_key', 'publishable_key' => 'pk_test_your_stripe_publishable_key' ]);
Usage
Creating Orders (Unified Interface)
The same code works for both PayPal and Stripe providers:
use PayPal\Checkout\Orders\Order; use PayPal\Checkout\Orders\PurchaseUnit; use PayPal\Checkout\Orders\Amount; // Create order (same for both providers) $order = new Order(); $order->setIntent('CAPTURE'); // Create purchase unit $purchaseUnit = new PurchaseUnit(); $purchaseUnit->setAmount(new Amount('100.00', 'USD')); $purchaseUnit->setReferenceId('order-' . time()); $order->addPurchaseUnit($purchaseUnit); // Create payment with either provider $response = $paymentProvider->createOrder($order); $responseData = json_decode($response->getBody(), true); echo "Payment ID: " . $responseData['id'];
PayPal-Specific Usage
// PayPal returns approval URL for customer foreach ($responseData['links'] as $link) { if ($link['rel'] === 'approve') { echo "Customer Approval URL: " . $link['href']; break; } }
Stripe-Specific Usage
// Stripe returns client_secret for frontend integration echo "Client Secret: " . $responseData['client_secret'];
Refund Processing
Both providers support full and partial refunds through a unified interface:
use PayPal\Checkout\Refunds\RefundRequest; // Create refund request $refundRequest = new RefundRequest('25.00', 'USD'); // Partial refund $refundRequest->setInvoiceId('refund-' . time()) ->setNoteToPayer('Refund processed as requested') ->setReason('requested_by_customer'); // Process refund (works with both PayPal capture IDs and Stripe payment intent IDs) $refundResponse = $paymentProvider->refundPayment($paymentId, $refundRequest);
Order Details
Retrieve order/payment details:
// Get order details (works for both providers) $detailsResponse = $paymentProvider->showOrder($orderId); $details = json_decode($detailsResponse->getBody(), true);
Example Files Overview
example_usage.php
Complete basic usage examples demonstrating:
- PayPal and Stripe payment creation
- Order details retrieval
- Dynamic provider selection
- Error handling patterns
corrected_test.php
Focused PayPal example showing:
- Proper PayPal order structure
- JSON output for debugging
- Comprehensive error handling
- Working PayPal implementation
working_example_with_refunds.php
Comprehensive example featuring:
- Multi-provider payment creation (PayPal & Stripe)
- Complete refund functionality for both providers
- Refund request creation and processing
- Summary of all implemented features
example_refund_usage.php
Dedicated refund examples including:
- Full and partial refund processing
- Advanced refund request configuration
- Multi-provider refund testing
- Production-ready refund patterns
Getting Started
- Choose the example file that best matches your needs
- Replace credential placeholders with your actual API keys
- Run:
php filename.php - Follow console output for next steps
Changelog
Please see the changelog for more information on what has changed recently.
Contributing
Please see CONTRIBUTING.md for details and a todo list.
Security
If you discover any security related issues, please email author instead of using the issue tracker.
Credits
License
Please see the LICENSE file for more information.
abdelwahidjobs/payment-checkout-api 适用场景与选型建议
abdelwahidjobs/payment-checkout-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「checkout」 「paypal」 「stripe」 「phpjuice」 「multi-provider」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 abdelwahidjobs/payment-checkout-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abdelwahidjobs/payment-checkout-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 abdelwahidjobs/payment-checkout-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PayPal SDK for ExpressCheckout and AdaptivePayments. Supports recurring payments, simple payments, parallel payments and chained payments.
A PayPal IPN (Instant Payment Notification) listener for PHP
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
Adds a 'checkout' to a SilverStripe site which links to an Estimate and adds the ability to setup and pay
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-26