paynl / omnipay-paynl
Pay.nl 对 Omnipay 支付处理库的驱动程序
5.0.0
2023-12-04 10:46 UTC
Requires
- ext-json: *
- omnipay/common: ~3
Requires (Dev)
- monolog/monolog: ^1.23
- omnipay/tests: ~3
- php-coveralls/php-coveralls: ^2.1
This package is auto-updated.
Last update: 2024-09-04 12:28:06 UTC
README
PAY. Omnipay 驱动
描述
PAY. 对 Omnipay 支付处理库的驱动
支持的支付方式
需求
PHP 5.6 or higher
安装
安装
在命令行中,导航到 Omnipay 的安装目录
输入以下命令
composer require league/omnipay:^3 paynl/omnipay-paynl
插件已安装
设置
- 创建一个新的 PHP 文件
- 使用以下代码
# require autoloader
require_once('vendor/autoload.php');
use Omnipay\Omnipay;
# Setup payment gateway
$gateway = Omnipay::create('Paynl');
$gateway->setApiToken('abcdefgdjwaiodjwaodjaowidwad');
$gateway->setTokenCode('AT-0000-0000');
$gateway->setServiceId('SL-0000-0000');
- 输入 TokenCode、API 令牌和 serviceID(这些可以在 PAY. 管理面板 --> https://admin.pay.nl/programs/programs 中找到)
- 保存文件
- 在希望使用插件的地方引入该文件。
转到 PAY. 管理面板的 管理 / 服务 选项卡以启用额外的支付方式。
更新说明
在命令行中,导航到 Omnipay 的安装目录
输入以下命令
composer update league/omnipay:^3 paynl/omnipay-paynl
插件已更新
使用方法
PAY. 项目
# Use PAY. Item class
use Omnipay\Paynl\Common\Item;
# Add items to transaction
$arrItems = array();
$item = new Item();
$item->setProductId('SKU01')
->setProductType('ARTICLE')
->setVatPercentage(21)
->setDescription('Description')
->setName('PAY. article')
->setPrice('10')
->setQuantity(4);
$arrItems[] = $item;
$item = new Item();
$item->setProductId('SHIP01')
->setProductType('SHIPPING')
->setVatPercentage(21)
->setDescription('Description')
->setName('PAY. shipping')
->setPrice('5')
->setQuantity(1);
$arrItems[] = $item;
$item = new Item();
$item->setProductId('SKU02')
->setProductType('DISCOUNT')
->setVatPercentage(21)
->setDescription('Description')
->setName('PAY. promotion')
->setPrice('1')
->setQuantity(1);
$arrItems[] = $item;
开始交易
# Send purchase request
$response = $gateway->purchase(
[
'amount' => '46.00',
'currency' => 'EUR',
'transactionReference' => 'referenceID1',
'clientIp' => '192.168.192.12',
'returnUrl' => 'http://www.yourdomain.com/return_from_pay.php',
'items' => $arrItems,
'card' => array(
'firstName' => 'Example',
'lastName' => 'User',
'gender' => 'M',
'birthday' => '01-02-1992',
'phone' => '1111111111111111',
'email' => 'john@example.com',
'country' => 'NL',
'shippingAddress1' => 'Shippingstreet 1B',
'shippingAddress2' => '',
'shippingCity' => 'Shipingtown',
'shippingPostcode' => '1234AB',
'shippingState' => '',
'country' => 'NL',
'billingFirstName' => 'Billingexample',
'billingLastName' => 'Billinguser',
'billingAddress1' => 'Billingstreet 1B',
'billingAddress2' => '',
'billingCity' => 'Billingtown',
'billingPostcode' => '1234AB',
'billingState' => '',
'country' => 'NL'
)
]
)->send();
# Process response
if ($response->isSuccessful()) {
# Payment was successful
var_dump($response);
} elseif ($response->isRedirect()) {
# Redirect to offsite payment gateway
$response->redirect();
} else {
# Payment failed
echo $response->getMessage();
}
退款交易
$response = $gateway->refund([
'transactionReference' => "PAY. transactionId",
'amount' => '46.00',
'currency' => 'USD',
'transactionId' => 765897
])->send();
if ($response->isSuccessful()) {
# Refund was successful
print_r($response);
} else {
# Refund failed
echo $response->getMessage();
}
捕获交易
$response = $gateway->capture([
'transactionReference' => "PAY. transactionId",
'items' => $arrItems
])->send();
if ($response->isSuccessful()) {
# Capture was successful
print_r($response);
} else {
# Capture failed
echo $response->getMessage();
}
支持
联系我们: support@pay.nl