gentor/omnipay-paysera

Omnipay支付处理库的Paysera网关

v0.1.0 2019-03-13 14:16 UTC

This package is auto-updated.

Last update: 2024-09-04 14:42:24 UTC


README

为Omnipay PHP支付处理库提供的Paysera网关驱动程序

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

Omnipay 是一个与框架无关、支持多个网关的PHP 5.3+支付处理库。本包实现了对Paysera的支持。

安装

Omnipay通过Composer安装。要安装,请使用Composer要求league/omnipaygentor/omnipay-paysera

composer require league/omnipay gentor/omnipay-paysera

有关通用使用说明,请参阅Omnipay的主要仓库。

需求

  • PHP 7.0+
  • Omnipay v3+
  • ext-openssl

基本用法

本包提供以下网关

  • Paysera

有关通用使用说明,请参阅Omnipay的主要仓库。

代码示例

use Omnipay\Omnipay;

// Setup payment gateway
$gateway = Omnipay::create('Paysera');
$gateway->setProjectId('123456');
$gateway->setPassword('abcde12345');
$gateway->setDeveloperId(123456);

// Optionally to determine which order has been paid
$orderId = 1;

// Example card (actually customer) data
$card = [
    'email' => 'john.doe@example.com',
    'billingFirstName' => 'John',
    'billingLastName' => 'Doe',
    'billingPhone' => '+372 12345678',
    'billingCompany' => 'Good Workers Ltd.',
    'billingAddress1' => 'Viru valjak 24',
    'billingCity' => 'Tallinn',
    'billingPostcode' => '123456',
    'billingCountry' => 'EE',
];

// Send purchase request
$response = $gateway->purchase(
    [
        'language' => 'ENG',
        'transactionId' => $orderId,
        'paymentMethod' => 'hanzaee',
        'amount' => '10.00',
        'currency' => 'EUR',
        'returnUrl' => "https://example.com/paysera/return/{$orderId}",
        'cancelUrl' => "https://example.com/paysera/cancel/{$orderId}",
        'notifyUrl' => "https://example.com/paysera/notify/{$orderId}",
        'card' => $card,
    ]
)->send();

if ($response->isRedirect()) {
    return $response->redirect();
}

您还应该实现notifyUrl的方法。在成功扣费后,Paysera会向此URL发送请求。

use Omnipay\Omnipay;

// Setup payment gateway
$gateway = Omnipay::create('Paysera');
$gateway->setProjectId('123456');
$gateway->setPassword('abcde12345');

// Accept the notification
$response = $gateway->acceptNotification()
    ->send();
    
if ($response->isSuccessful()) {
    // Mark the order as paid

    return true;
}

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

贡献

有关详细信息,请参阅CONTRIBUTING

鸣谢

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件