phpjuice/paypal-checkout-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpjuice/paypal-checkout-sdk

Composer 安装命令:

composer require phpjuice/paypal-checkout-sdk

包简介

PayPal's PHP SDK for Checkout REST APIs

README 文档

README

Tests Latest Stable Version Maintainability Total Downloads License

This Package is a PHP SDK wrapper around version 2 of the PayPal rest API. It provides a simple, fluent API to create and capture orders with both sandbox and production environments supported.

To learn all about it, head over to the extensive documentation.

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

Setup

PayPal Checkout SDK is designed to simplify using the new PayPal checkout api in your app.

Setup Credentials

Get client ID and client secret by going to https://developer.paypal.com/developer/applications and generating a REST API app. Get Client ID and Secret from there.

Setup a Paypal Client

Inorder to communicate with PayPal platform we need to set up a client first :

Create a client with sandbox environment :

// import namespace
use PayPal\Http\Environment\SandboxEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

// create a new sandbox environment
$environment = new SandboxEnvironment($clientId, $clientSecret);

// create a new client
$client = new PayPalClient($environment);

Create a client with production environment :

// import namespace
use PayPal\Http\Environment\ProductionEnvironment;
use PayPal\Http\PayPalClient;

// client id and client secret retrieved from PayPal
$clientId = "<<PAYPAL-CLIENT-ID>>";
$clientSecret = "<<PAYPAL-CLIENT-SECRET>>";

// create a new sandbox environment
$environment = new ProductionEnvironment($clientId, $clientSecret);

// create a new client
$client = new PayPalClient($environment);

INFO: head over to the extensive documentation.

Usage

Create an Order

// Import namespace
use PayPal\Checkout\Requests\OrderCreateRequest;
use PayPal\Checkout\Orders\AmountBreakdown;
use PayPal\Checkout\Orders\Item;
use PayPal\Checkout\Orders\Order;
use PayPal\Checkout\Orders\PurchaseUnit;

// Create a purchase unit with the total amount
$purchase_unit = new PurchaseUnit(AmountBreakdown::of('100.00'));

// Create & add item to purchase unit
$purchase_unit->addItem(Item::create('Item 1', '100.00', 'USD', 1));

// Create a new order with intent to capture a payment
$order = new Order();

// Add a purchase unit to order
$order->addPurchaseUnit($purchase_unit);

// Create an order create http request
$request = new OrderCreateRequest($order);

// Send request to PayPal
$response = $client->send($request);

// Parse result
$result = json_decode((string) $response->getBody());
echo $result->id; // id of the created order
echo $result->intent; // CAPTURE
echo $result->status; // CREATED

INFO: head over to the extensive documentation.

Capture an Order

// Import namespace
use PayPal\Checkout\Requests\OrderCaptureRequest;

// Create an order capture http request
$request = new OrderCaptureRequest($order_id);

// Send request to PayPal
$response = $client->send($request);

// Parse result
$result = json_decode((string) $response->getBody());
echo $result->id; // id of the captured order
echo $result->status; // CAPTURED

INFO: head over to the extensive documentation.

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

license. Please see the Licence for more information.

Tests Latest Stable Version Maintainability Total Downloads License

phpjuice/paypal-checkout-sdk 适用场景与选型建议

phpjuice/paypal-checkout-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.92k 次下载、GitHub Stars 达 59, 最近一次更新时间为 2020 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「checkout」 「paypal」 「phpjuice」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 phpjuice/paypal-checkout-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 phpjuice/paypal-checkout-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 phpjuice/paypal-checkout-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 62.92k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 60
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 59
  • Watchers: 5
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-30