nmc9 / nuvei-helper

Nuvei 集成助手

维护者

详细信息

github.com/nmc9/Nuvei-Helper

源代码

安装: 23

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 2

分支: 2

v1.6.1 2020-07-10 13:32 UTC

This package is auto-updated.

Last update: 2024-09-27 20:25:43 UTC


README

基于此库 https://github.com/jqueguiner/PivotalPayment

Nuvei

Nuvei 的 PHP 库 http://www.pivotalpayments.com/ca/fr/

要求

CURL (php_curl) XMLRPC (php_xmlrpc) 多字节字符串 PHP 扩展 (php_mbstring)

安装

将 GitHub 仓库的内容放入您项目中的目标目录($DIR)。根据需要,在您的数据库中创建事务表(SQL 模型文件位于

  • Data/dataModel.sql

实时使用

//$DIR see section installation below
require_once($DIR.DIRECTORY_SEPARATOR.'Pivotal.php');

$paymentParams['ORDERID'] = $orderId;
$paymentParams['AMOUNT'] = $amount;
$paymentParams['CURRENCY'] = $currency;
$paymentParams['CARDNUMBER'] = $cardNumber;
$paymentParams['CARDHOLDERNAME'] = $cardHolderName;
//month two digits (09 for september)
$paymentParams['MONTH'] = $cardMonth;
//year two digits (16 for 2016)
$paymentParams['YEAR'] = $cardYear;
//CVV 3 or 4 Digits depending on vendor
$paymentParams['CVC'] = $cardCVC;

//'live' for live environment
//'test' for test environment
$pivotal = new Pivotal('live',$paymentParams);

//configure your db to autosave transactions
$pivotal->_dbConfig = array('server' => 'localhost', 'login' => 'root', 'password' => 'root', 'database' => 'myDb');

//transactions won't be saved in the DB
$response = $pivotal->sendPayment();

//transactions will be saved in the DB
//true option stands for transaction recording in the database (table is "transaction" see installation section")
$response = $pivotal->sendPayment(true);

测试使用

测试卡包含在库中

//$DIR see section installation below
require_once($DIR.DIRECTORY_SEPARATOR.'Pivotal.php');

$pivotal_config = new Pivotal_Config('test');

//get test card number for the selected vendor (Visa)
//get the holdername and CVV too
//all test variables are under the Data Directory (TestCards.json)
//live and Test URL are in Data Directory (MainConfig.json)
//live and Test terminals are in Data Directory (Terminals.json)

$card = $pivotal_config->readVendorTestCard('visa');

$paymentParams['ORDERID'] = rand(10,10000);
$paymentParams['AMOUNT'] = 1000;
$paymentParams['CURRENCY'] = 'CAD';
$paymentParams['CARDNUMBER'] = $card['CardNumber'];
$paymentParams['CARDHOLDERNAME'] = $card['CardHolderName'];
$paymentParams['MONTH'] = '09';
$paymentParams['YEAR'] = '16';
$paymentParams['CVC'] = $card['CVC'];

$pivotal = new Pivotal('test',$paymentParams);

$response = $pivotal->sendPayment();

支付验证输出

//if success
array(
	'UNIQUEREF' => 'GW5CWTXWIW',
	'RESPONSECODE' => 'A',
	'RESPONSETEXT' => 'APPROVAL',
	'APPROVALCODE' => '475318',
	'DATETIME' => '2014-11-10T17:25:58',
	'AVSRESPONSE' => 'X',
	'CVVRESPONSE' => 'M',
	'HASH' => 'b035f8f72f4be9df404d6268b55c02b0',
	'STATUS' => true
)

or
//if error
array(
	'ERRORSTRING' => 'The error description',
	'STATUS' => false
)

构建支付表单

支付表单助手包含在库中,并基于 https://github.com/jessepollak/card 插件

card

//$DIR see section installation below
require_once($DIR.DIRECTORY_SEPARATOR.'Helper'.DIRECTORY_SEPARATOR.'form.php');

//$action = formAction see https://w3schools.org.cn/tags/att_form_action.asp for more info
$action = 'PaymentProcessURL.php';

$pivotal_form = new Pivotal_Form($action);
echo $pivotal_form->buildForm();

额外

此库还提供正则表达式以检测卡片供应商(正则表达式位于 Data/CardTypes.json 中),您可以根据卡号读取供应商

//$DIR see section installation below
require_once($DIR.DIRECTORY_SEPARATOR.'Pivotal.php');

$pivotal_config = new Pivotal_Config('test');

//this clean and compare the card number to regular expression config located under Data/CardTypes.json
//please feel free to add new credit card type but keep in mind the the order in the CardTypes.json is important and that last pattern found = output
//so be sure to have VISA, MASTERCARD before resellers (VISA DEBIT is part of VISA for instance which means that VISA should be before VISA DEBIT)

$vendor = $pivotal_config->getCardType('1234567890123456');

信用卡正则表达式

以下是迄今为止已知的信用卡正则表达式,请随时贡献以使此库更加精确。

  • Maestro
  • JCB
  • Diners
  • 美国
  • Express
  • Visa
  • 万事达卡
  • 借记卡万事达卡
  • 英国国内 Maestro
  • Solo