vantiv/cnp-payments-sdk
最新稳定版本:12.47.0
Composer 安装命令:
composer require vantiv/cnp-payments-sdk
包简介
The Vantiv eCommerce PHP SDK is a PHP implementation of the [Vantiv eCommerce](https://developer.vantiv.com/community/ecommerce). XML API. This SDK was created to make it as easy as possible to connect process your payments with Vantiv eCommerce
关键字:
README 文档
README
WARNING:
All major version changes require recertification to the new version. Once certified for the use of a new version, Vantiv modifies your Merchant Profile, allowing you to submit transaction to the Production Environment using the new version. Updating your code without recertification and modification of your Merchant Profile will result in transaction declines. Please consult you Implementation Analyst for additional information about this process.
About Vantiv eCommerce
Vantiv eCommerce powers the payment processing engines for leading companies that sell directly to consumers through internet retail, direct response marketing (TV, radio and telephone), and online services. Vantiv eCommerce is the leading authority in card-not-present (CNP) commerce, transaction processing and merchant services.
About this SDK
The Vantiv eCommerce PHP SDK is a PHP implementation of the Vantiv eCommerce. XML API. This SDK was created to make it as easy as possible to connect process your payments with Vantiv eCommerce. This SDK utilizes the HTTPS protocol to securely connect to Vantiv eCommerce. Using the SDK requires coordination with the Vantiv eCommerce team in order to be provided with credentials for accessing our systems.
Each PHP SDK release supports all of the functionality present in the associated Vantiv eCommerce XML version (e.g., SDK v9.3.2 supports Vantiv eCommerce XML v9.3). Please see the online copy of our XSD for Vantiv eCommerce XML to get more details on what the Vantiv eCommerce payments engine supports.
This SDK was implemented to support the PHP programming language and was created by Vantiv eCommerce. Its intended use is for online transaction processing utilizing your account on the Vantiv eCommerce payments engine.
See LICENSE file for details on using this software.
Source Code available from : https://github.com/Vantiv/cnp-sdk-for-php
Please contact Vantiv eCommerce to receive valid merchant credentials in order to run tests successfully or if you require assistance in any way. We are reachable at sdksupport@fisglobal.com
SDK PHP Dependencies
Up to date list available at Packagist
Setup
Using with composer
If you are using a composer to manage your dependencies, you can do the following in your project directory:
- Install the composer using command:
curl -sS https://getcomposer.org/installer | php
- Move into the cnp-sdk-for-php directory and install dependencies via composer (ensure the path to composer.phar is correct).
cd cnp-sdk-for-php
php ../composer.phar install
- Configure the SDK:
cd cnp/sdk
php Setup.php
- Return to the cnp-sdk-for-php directory, then run the attached sample:
<?php require_once realpath(dirname(__FILE__)).'/vendor/autoload.php'; #sale $sale_info = array( 'id' => '42', 'orderId' => '1', 'amount' => '10010', 'orderSource' => 'ecommerce', 'billToAddress' => array( 'name' => 'John Smith' , 'addressLine1' => ' 1 Main St.', 'city' => 'Burlington' , 'state' => 'MA' , 'zip' => '0183-3747', 'country' => 'US'), 'card' => array( 'number' => '5112010000000003', 'expDate' => '0112', 'cardValidationNum' => '349', 'type' => 'MC' ) ); $initialize = new cnp\sdk\CnpOnlineRequest(); $saleResponse =$initialize->saleRequest($sale_info); #display results echo ("Response: " . (cnp\sdk\XmlParser::getNode($saleResponse,'response')) . "<br>"); echo ("Message: " . cnp\sdk\XmlParser::getNode($saleResponse,'message') . "<br>"); echo ("Vantiv eCommerce Transaction ID: " . cnp\sdk\XmlParser::getNode($saleResponse,'cnpTxnId'));
php your_sample_name
Using without composer
If you're not, you have to add a require for each and every class that's going to be used.
- Configure the SDK
cd into cnp/sdk php Setup.php
-
Add the cnp folder and require the path for your file
-
run your file
php your_file
Clone Repo
- Install the Vantiv eCommerce PHP SDK from git.
git clone git://github.com/Vantiv/cnp-sdk-for-php.git
php ~/composer.phar install
- Once the SDK is downloaded run our setup program to generate a configuration file.
cd cnp-sdk-for-php/lib
php Setup.php
Running the above commands will create a configuration file in the lib directory.
- Create a php file similar to:
<?php require_once realpath(dirname(__FILE__)) . '/CnpOnline.php'; // Visa $10.00 sale $hash_in = array( 'id' => '42', 'amount'=>'106', 'orderId' => '123213', 'orderSource'=>'ecommerce', 'card'=>array( 'type'=>'VI', 'number' =>'4100000000000001', 'expDate' =>'1000') ); //Perform the transaction on the Vantiv eCommerce Platform $initialize = new CnpOnlineRequest(); $saleResponse = $initialize->saleRequest($hash_in); // Display Result echo ("Message: " . XMLParser::getNode($saleResponse,'message') . "<br>"); echo ("Vantiv eCommerce Transaction ID: " . XMLParser::getNode($saleResponse,'cnpTxnId'));
As of 8.13.1, you may also use a tree-oriented style to get the response values:
<?php require_once realpath(dirname(__FILE__)) . '/CnpOnline.php'; // Visa $10.00 sale $hash_in = array( 'id' => '42', 'amount'=>'106', 'orderId' => '123213', 'orderSource'=>'ecommerce', 'card'=>array( 'type'=>'VI', 'number' =>'4100000000000001', 'expDate' =>'1000') ); //Perform the transaction on the Vantiv eCommerce Platform $initialize = new CnpOnlineRequest($treeResponse=true); $saleResponse = $initialize->saleRequest($hash_in); // Display Result echo ("Message: " . $saleResponse->saleResponse->message . "<br>"); echo ("Vantiv eCommerce Transaction ID: " . $saleResponse->saleResponse->cnpTxnId);
NOTE: you may have to change the path to match that of your filesystems.
If you get an error like:
PHP Fatal error: require_once(): Failed opening required '/home/gdake/git/cnp-sdk-for-php/CnpOnline.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/gdake/git/cnp-sdk-for-php/foo.php on line 2
You need to change the second line of your script to load the real location of CnpOnline.php
If you get an error like:
PHP Fatal error: require(): Failed opening required '/home/gdake/cnp-sdk-for-php/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/gdake/cnp-sdk-for-php/cnp/sdk/CnpOnline.php on line 42
You probably had a problem with composer. You can safely remove line 42 if you are not using batch processing, or you can edit it to point at our dependencies that you've downloaded in another way.
-
Next run this file using php on the command line or inside a browser. You should see the following result provided you have connectivity to the Vantiv eCommerce certification environment. You will see an HTTP error if you don't have access to the Vantiv URL
Message: Valid Format Vantiv eCommerce Transaction ID:
More examples can be found here php Gists
Please contact Vantiv eCommerce Inc. with any further questions. You can reach us at sdksupport@fisglobal.com
vantiv/cnp-payments-sdk 适用场景与选型建议
vantiv/cnp-payments-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 134.75k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ecommerce」 「payments」 「sdk」 「vantiv」 「CNP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vantiv/cnp-payments-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vantiv/cnp-payments-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vantiv/cnp-payments-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nevogate Payment Gateway SDK
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A PHP (and Laravel) package to interface with the Snipcart api.
Customer notes for Contao Isotope eCommerce checkout.
Scanpay module for Magento 2
统计信息
- 总下载量: 134.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 35
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04