paypal/merchant-sdk-php
最新稳定版本:v3.12.0
Composer 安装命令:
composer require paypal/merchant-sdk-php
包简介
PayPal Merchant SDK for PHP
README 文档
README
PayPal PHP Merchant SDK
The merchant SDK can be used for integrating with the Express Checkout, Mass Pay, Web Payments Pro APIs.
TLSv1.2 Update
The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. Click here for more information
A new
modehas been created to test if your server/machine handles TLSv1.2 connections. Please usetlsmode instead ofsandboxto verify. You can return back tosandboxmode once you have verified. Please have a look at this Sample Configuration.
POODLE Update
- Because of the Poodle vulnerability, PayPal has disabled SSLv3.
- To enable TLS encryption, the changes were made to PPHttpConfig.php in SDK Core to use a cipher list specific to TLS encryption.
/** * Some default options for curl * These are typically overridden by PPConnectionManager */ public static $DEFAULT_CURL_OPTS = array( CURLOPT_SSLVERSION => 1, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute CURLOPT_USERAGENT => 'PayPal-PHP-SDK', CURLOPT_HTTPHEADER => array(), CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSL_VERIFYPEER => 1, CURLOPT_SSL_CIPHER_LIST => 'TLSv1', );
- There are two primary changes done to curl options:
All these changes are included in the recent release, along with many other bug fixes.
Support
Please contact PayPal Technical Support for any live or account issues.
Prerequisites
PayPal's PHP Merchant SDK requires
- PHP 5.3 and above
- curl/openssl PHP extensions
Running the sample
To run the bundled sample, first copy the samples folder to your web server root. You will then need to install the SDK as a dependency using composer (PHP V5.3+ only).
Using the SDK
To use the SDK,
- Create a
composer.jsonfile with the following contents.
{
"name": "me/shopping-cart-app",
"require": {
"paypal/merchant-sdk-php":"3.8.*"
}
}
- Install the SDK as a dependency using
composer. To downloadcomposer, follow installation instructions provided in Composer documentation. - Require
PPBootStrap.phpin your application. - Choose how you would like to configure the SDK - You can either
- Create a hashmap containing configuration parameters and pass it to the service object OR
- Create a
sdk_config.inifile and set the PP_CONFIG_PATH constant to point to the directory where this file exists.
- Instantiate a service wrapper object and a request object as per your project's needs.
- Invoke the appropriate method on the service object.
For example,
// Sets config file path(if config file is used) and registers the classloader require("PPBootStrap.php"); // Array containing credentials and confiuration parameters. (not required if config file is used) $config = array( 'mode' => 'sandbox', 'acct1.UserName' => 'jb-us-seller_api1.paypal.com', 'acct1.Password' => 'WX4WTU3S8MY44S7F' ..... ); // Create request details $itemAmount = new BasicAmountType($currencyId, $amount); $setECReqType = new SetExpressCheckoutRequestType(); $setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails; // Create request $setECReq = new SetExpressCheckoutReq(); $setECReq->SetExpressCheckoutRequest = $setECReqType; ...... // Perform request $paypalService = new PayPalAPIInterfaceServiceService($config); $setECResponse = $paypalService->SetExpressCheckout($setECReq); // Check results if(strtoupper($setECResponse->Ack) == 'SUCCESS') { // Success }
Authentication
The SDK provides multiple ways to authenticate your API call.
$paypalService = new PayPalAPIInterfaceServiceService($config); // Use the default account (the first account) configured in sdk_config.ini $response = $paypalService->SetExpressCheckout($setECReq); // Use a specific account configured in sdk_config.ini $response = $paypalService->SetExpressCheckout($setECReq, 'jb-us-seller_api1.paypal.com'); // Pass in a dynamically created API credential object $cred = new PPCertificateCredential("username", "password", "path-to-pem-file"); $cred->setThirdPartyAuthorization(new PPTokenAuthorization("accessToken", "tokenSecret")); $response = $paypalService->SetExpressCheckout($setECReq, $cred);
SDK Configuration
The SDK allows you to configure the following parameters-
- Integration mode (sandbox / live)
- (Multiple) API account credentials.
- HTTP connection parameters
- Logging
Dynamic configuration values can be set by passing a map of credential and config values (if config map is passed the config file is ignored)
$config = array( 'mode' => 'sandbox', 'acct1.UserName' => 'jb-us-seller_api1.paypal.com', 'acct1.Password' => 'WX4WTU3S8MY44S7F' ..... ); $service = new PayPalAPIInterfaceServiceService($config);
Alternatively, you can configure the SDK via the sdk_config.ini file.
define('PP_CONFIG_PATH', '/directory/that/contains/sdk_config.ini'); $service = new PayPalAPIInterfaceServiceService();
You can refer full list of configuration parameters in wiki page.
Instant Payment Notification (IPN)
Please refer to the IPN-README in 'samples/IPN' directory.
Links
- API Reference - https://developer.paypal.com/webapps/developer/docs/classic/api/#merchant
- If you need help using the SDK, a new feature that you need or have a issue to report, please visit https://github.com/paypal/merchant-sdk-php/issues
paypal/merchant-sdk-php 适用场景与选型建议
paypal/merchant-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.85M 次下载、GitHub Stars 达 225, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「sdk」 「paypal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 paypal/merchant-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 paypal/merchant-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 paypal/merchant-sdk-php 相关的其它包
同方向 / 同关键字的高下载量 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
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.
Alfabank REST API integration
统计信息
- 总下载量: 4.85M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 231
- 点击次数: 14
- 依赖项目数: 16
- 推荐数: 1
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-01-04