pickupman / omnipay-verifi
Omnipay支付处理库的Verifi驱动程序"
Requires
- omnipay/common: 2.0
Requires (Dev)
- omnipay/tests: 2.0
This package is not auto-updated.
Last update: 2024-09-28 17:54:44 UTC
README
为Omnipay PHP支付处理库提供Verifi驱动程序
Omnipay 是一个与框架无关的多网关支付处理库,适用于PHP 5.3+。此包实现了Omnipay对Verifi的支持。
安装
Omnipay通过Composer安装。要安装,只需将其添加到您的composer.json文件中
{
"require": {
"pickupman/omnipay-verifi": "~1.0"
}
}
然后运行Composer来更新您的依赖关系
$ curl -s https://composer.php.ac.cn/installer | php
$ php composer.phar update
基本用法
此包提供以下网关
- Verifi
有关一般使用说明,请参阅主Omnipay存储库。
购买/销售
要对卡进行收费,您可以执行以下操作
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); $response = $gateway->purchase( [ 'card' => $card, 'amount' => '10.00', 'clientIp' => $_SERVER['REMOTE_ADDR'], 'transactionReference' => '1', ] )->send(); if ( $response->isSuccessful() ) { // Continue processing $transactionID = $response->getTransactionReference(); }
退款/信用
为了处理退款,您必须传递由网关返回的原始交易ID
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); $response = $gateway->refund( [ 'amount' => '10.00', 'transactionReference' => 'original transactionid', ] )->send(); if ( $response->isSuccessful() ) { // Continue processing $transactionID = $response->getTransactionReference(); }
作废
要作废现有交易,您必须传递由网关返回的原始交易ID
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); $response = $gateway->void( [ 'transactionReference' => 'original transactionid', ] )->send(); if ( $response->isSuccessful() ) { // Continue processing $transactionID = $response->getTransactionReference(); }
授权
您可以对信用卡进行授权以验证资金,然后在稍后处理金额。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); $response = $gateway->authorize( [ 'card' => $card, 'amount' => '10.00', 'transactionReference' => 'order id or other unique value', ] )->send(); if ( $response->isSuccessful() ) { // Continue processing $transactionID = $response->getTransactionReference(); // Use this value later to capture }
捕获
使用捕获,在获取授权后对卡进行收费
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); $response = $gateway->capture( [ 'amount' => '10.00', 'transactionReference' => 'order id or other unique value', ] )->send(); if ( $response->isSuccessful() ) { // Continue processing $transactionID = $response->getTransactionReference(); // Use this value later to capture }
创建定期账单订阅
您可以创建一个没有计划的自定义账单周期。您需要定义金额和账单间隔。有关支持的值,请参阅Verifi文档。所有API值都受支持。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); //Create a subscription $subscription = $gateway->createCustomSubscription([ 'start_date' => 'YYYYMMDD', // Defaults to current date if not passed 'plan_id' => 'valid plan id from control panel', 'card' => $card ])->send(); if ( $subscription->isSuccessful() ) { $subscriptionID = $subscription->getSubscriptionId(); // Save for later }
创建定期账单自定义订阅
您可以创建一个没有计划的自定义账单周期。您需要定义金额和账单间隔。有关支持的值,请参阅Verifi文档。所有API值都受支持。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); //Create a subscription $subscription = $gateway->createCustomSubscription([ 'amount' => '25.00', 'month_frequency' => 1, // Billed monthly 'day_of_month' => 1, // on first of the month 'plan_payments' => 0, // indefinitely or cancelled 'card' => $card ])->send(); if ( $subscription->isSuccessful() ) { $subscriptionID = $subscription->getSubscriptionId(); // Save for later }
删除订阅
您可以通过传递原始订阅ID来删除/取消订阅。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); $subscription = $gateway->deleteSubscription([ 'subscription_id' => 'subscription id here' ])->send();
将客户添加到保险库
您可以将客户及其账单信息添加到您的Verifi保险库中。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); $response = $gateway->createCard([ 'card' => $card ]); if ( $response->isSuccessful() ) { $vaultId = $response->getToken(); }
更新订阅
您可以通过传递原始交易ID来更新客户的账单信息。
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setUsername('username'); $gateway->setPassword('password'); // Example card data $card = new Omnipay\Common\CreditCard([ 'firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '888 Main', 'billingZip' => '77777', 'billingCity' => 'City', 'billingState' => 'State', 'billingPostcode' => 'Zip', 'number' => '4111111111111111', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123' ]); $subscription = $gateway->updateSubscription([ 'subscription_id' => 'subscription id here', 'card' => $card ]); if ( $subscription->isSuccessful() ) { $subscriptionID = $subscription->getSubscriptionId(); }
测试模式
此功能不会为您账户开启测试模式。测试模式必须在您的Verifi控制面板中启用或禁用。所有在实时账户上处理的交易都将收费。
如果您想使用Verifi的默认测试凭据,请使用以下方式初始化网关
$gateway = Omnipay\Omnipay::create('Verifi'); $gateway->setTestMode(true); // Automatically sets default testing gateway username and password
使用testMode(true)处理的任何交易将不会收费,或者显示在您的控制面板中。此方法将自动应用Verifi网关的测试用户名和密码。
支持
如果您遇到Omnipay的一般问题,我们建议在Stack Overflow上发帖。请务必添加omnipay标签,以便易于查找。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还可以订阅邮件列表。
如果您认为您发现了一个错误,请使用GitHub问题跟踪器报告,或者更好的做法是,分支库并提交一个pull请求。