chistel/bluesnap_php

Bluesnap api 的 PHP 库

1.0.0 2020-09-08 23:00 UTC

This package is auto-updated.

Last update: 2024-09-09 18:30:04 UTC


README

此库是从原始作者 tdanielcox 的库中衍生出来的

目前,库支持以下功能

  • 卡交易
  • 存储购物者
  • 供应商
  • 订阅
  • 计划(订阅)
  • 退款
  • 报告

安装

使用 composer 安装此包

composer require chistel/bluesnap_php

用法

在类的构造函数中初始化库

public function __construct()
{
    $environment = 'sandbox'; // or 'production'
    \Chistel\Bluesnap\Bluesnap::init($environment, 'YOUR_API_KEY', 'YOUR_API_PASSWORD');
}

创建新交易

public function createTransaction()
{
    $response = \Chistel\Bluesnap\CardTransaction::create([
        'creditCard' => [
            'cardNumber' => '4263982640269299',
            'expirationMonth' => '02',
            'expirationYear' => '2018',
            'securityCode' => '837'
        ],
        'amount' => 10.00,
        'currency' => 'USD',
        'recurringTransaction' => 'ECOMMERCE',
        'cardTransactionType' => 'AUTH_CAPTURE',
    ]);

    if ($response->failed())
    {
        $error = $response->data;
        
        // handle error
    }

    return $response->data;
}

查看 示例 了解库的更多用法细节

许可证

此包根据 MIT 许可证 许可