thelhc/auth-net-client

此包的最新版本(v1.0.0)没有提供许可证信息。

Authorize.net API 客户端

v1.0.0 2017-02-24 02:27 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:56:23 UTC


README

Authorize.net API 客户端

安装

composer require thelhc/auth-net-client

基本用法

新建配置文件

$profile = new Profile([
    'merchant_customer_id' => rand(1000, 10000),
]);
$profile->create()

带有支付配置文件的新建配置文件

$profile = new Profile([
    'merchant_customer_id' => rand(1000, 10000),
]);
$paymentProfile = new PaymentProfile([
    'customerType' => 'business',
    'billTo' => [
        'firstName' => 'Aaron',
        'lastName' => 'Kaczmarek',
        'company' => 'WeaselJobs',
        'address' => '747 Main St',
        'city' => 'Westbrook',
        'state' => 'ME',
        'zip' => '04092',
        'phoneNumber' => '828-301-9460'
    ],
    'payment' => [
        'creditCard' => [
            'cardNumber' => '4007000000027',
            'expirationDate' => '2020-01',
        ]
    ]
]);
$profile->paymentProfiles()->add($paymentProfile);
$profile->create()

获取配置文件

$profile = Profile::find("1810689705");

更新配置文件

$profile = Profile::find("1810689705");
$attrs = [
    "email" => "aaronkazman@email.com",
    "description" => "aaron test #".rand(1000, 10000)
];
$profile->update($attrs);

删除配置文件

$profile = Profile::find("1810720109");
$profile->delete();

创建支付配置文件

$profile = Profile::find("1810689705");
$paymentProfile = new PaymentProfile([
    'customerType' => 'business',
    'billTo' => [
        'firstName' => 'Aaron',
        'lastName' => 'Kaczmarek',
        'company' => 'WeaselJobs #'.rand(1000, 10000),
        'address' => '747 Main St',
        'city' => 'Westbrook',
        'state' => 'ME',
        'zip' => '04092',
        'phoneNumber' => '828-301-9460'
    ],
    'payment' => [
        'creditCard' => [
            'cardNumber' => '4012888818888',
            'expirationDate' => '202'.rand(1, 9).'0'.rand(1, 9),
        ]
    ]
]);
$profile->paymentProfiles()->save($paymentProfile);

获取支付配置文件

$payment_profile = PaymentProfile::find("1810689705", "1805383335");

或从集合中获取

$profile = Profile::find("1810689705");
$payment_profile = $profile->paymentProfiles()->find("1805383335");

更新支付配置文件

$payment_profile = PaymentProfile::find("1810689705", "1805383335");
$attrs = [
    'billTo' => [
        'company' => 'WeaselJobs update #'.rand(1000, 10000),
    ]
];
$payment_profile->update($attrs);

删除支付配置文件

$payment_profile = PaymentProfile::find("1810720112", "1805415477");
$payment_profile->delete();

验证支付配置文件

$payment_profile = PaymentProfile::find("1810689705", "1805383335");
$payment_profile->validate();

获取支付配置文件列表

$params = [
    "searchType" => "cardsExpiringInMonth",
    "month" => "2020-01",
    "sorting" => [
        "orderBy" => "id",
        "orderDescending" => "false",
    ],
    "paging" => [
        "limit" => 1000,
        "offset" => 1
    ]
];
$payment_profiles = PaymentProfile::getList($params);

对支付配置文件进行收费

$payment_profile = PaymentProfile::find("1810689705", "1805383335");
$transaction = $payment_profile->charge("100.00", [
    "order" => [
        "invoiceNumber" => rand(1000, 10000),
        "description" => "Test payment profile charge"
    ]
]);