cardinity/client-bundle

此软件包已被废弃且不再维护。未建议替代软件包。

Symfony2 信用卡支付捆绑包的 Cardinity

v1.0.2 2017-06-22 09:08 UTC

This package is not auto-updated.

Last update: 2023-09-19 12:34:06 UTC


README

Build Status Scrutinizer Code Quality SensioLabsInsight

弃用通知

此仓库已弃用。

安装

通过 Composer 安装

$ php composer.phar require cardinity/client-bundle

配置

要使用此捆绑包,您必须在 app/config/config.yml 文件的 cardinity_client 部分中定义两个参数

# app/config/config.yml
cardinity_client:
    consumer_key: key
    consumer_secret: secret

其中

  • consumer_key: 您可以在 Cardinity 成员区域找到您的 Consumer Key 和 Consumer Secret。
  • consumer_secret: 您可以在 Cardinity 成员区域找到您的 Consumer Key 和 Consumer Secret。

注册捆绑包

您必须将 CardinityClientBundle 添加到您的 AppKernel.php

# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ... other bundles
            new Cardinity\ClientBundle\CardinityClientBundle()
        );

        return $bundles;
    }
}

启用带有 3-D secure DEMO 的信用卡处理

app/config/routing.yml 中包含以下行

cardinity_client:
    resource: "@CardinityClientBundle/Resources/config/routing.yml"
    prefix: /cardinity

如果您使用的是 PHP 内置的 web 服务器

    app/console server:run

尝试用地址 https://:8000/cardinity 打开浏览器。

用法

服务

此捆绑包包含以下服务,可简化您项目中 Cardinity 的实现

/** @type Cardinity\Client */
$client = $this->container->get('cardinity_client.service.client');

可用方法

验证并执行 Cardinity 查询

/** @type Cardinity\Method\ResultObjectInterface
$result = $client->call($query);

可用查询

支付

Cardinity\Payment\Create($body)
Cardinity\Payment\Finalize($paymentId, $authorizeData)
Cardinity\Payment\Get($paymentId)
Cardinity\Payment\GetAll($limit)

结算

Cardinity\Settlement\Create($paymentId, $amount, $description = null)
Cardinity\Settlement\Get($paymentId, $settlementId)
Cardinity\Settlement\GetAll($paymentId)

撤销

Cardinity\Void\Create($paymentId, $description = null)
Cardinity\Void\Get($paymentId, $voidId)
Cardinity\Void\GetAll($paymentId)

退款

Cardinity\Refund\Create($paymentId, $amount, $description = null)
Cardinity\Refund\Get($paymentId, $refundId)
Cardinity\Refund\GetAll($paymentId)

用法

use Cardinity\Method\Payment;

/** @type Cardinity\Client */
$client = $this->container->get('cardinity_client.service.client');
try {
    /** @type Payment\Payment */
    $payment = $client->call(new Payment\Create([
        'amount' => 50.00,
        'currency' => 'EUR',
        'settle' => false,
        'description' => 'some description',
        'order_id' => '12345678',
        'country' => 'LT',
        'payment_method' => Cardinity\Payment\Create::CARD,
        'payment_instrument' => [
            'pan' => '4111111111111111',
            'exp_year' => 2018,
            'exp_month' => 12,
            'cvc' => '456',
            'holder' => 'Mike Dough'
        ]
    ]));

    /** @type Payment\Payment */
    $finalizedPayment = $client->call(new Payment\Finalize(
        $payment->getId(),
        $payment->getAuthorizationInformation()->getData()
    ));
} catch (Cardinity\Exception\Declined $e) {
    // Payment has been declined
} catch (Cardinity\Exception\Runtime $e) {
    // Other type of error happened
}

更多用法示例可在 Cardinity PHP 客户端仓库 中找到。

官方 API 文档可在 此处 找到。