Zoop SDK 用于 Laravel 框架版本 5.3+

v1.1.0 2021-09-29 15:09 UTC

This package is not auto-updated.

Last update: 2024-09-20 17:07:07 UTC


README

Zoop-laravel 是一个适用于 Laravel 5.3+ 的包,它使用 ZOOP 支付 API。

统计信息
Latest Stable Version Total Downloads Latest Unstable Version License

要求

  • Laravel 5.3+
  • PHP 5.6+
  • PHP 扩展 curl
  • PHP 扩展 json
  • PHP 扩展 mbstring

安装

1 - Composer require

使用 composer 安装包并自动更新 composer.json,运行以下命令:

composer require adhenrique/zoop

2 - 更新 Laravel 配置

更新您的应用程序配置,在 config/app.php'providers' 部分中注册该包,添加以下行:

'providers' => [
    //...
    Zoop\ZoopServiceProvider::class,
    //...
],

3 - 发布 ZOOP Laravel 配置

使用以下命令从 zoop/src/resources/config/ 的 config.example.php 发布配置设置:

php artisan vendor:publish --provider "Zoop\ZoopServiceProvider" --tag="config"

这将创建 config/zoopconfig.php 配置文件。现在,更改以下行:

'defaults'  => [
    //...
    'publishable_key'   => 'YOUR_PUBLISHABLE_KEY',
    'marketplace_id'    => 'YOUR_MARKETPLACE_ID',
    //...
]

...享受吧 :D。

使用方法

1 - 信用卡 Tokenizer

在你的控制器中

namespace App\Http\Controllers;
 
use Zoop\src\Facades\ZoopTokens;
 
class HomeController extends Controller{
    $ccToken = ZoopTokens::tokenizeCard([
        'holder_name' => 'Makeda Swasey',
        'expiration_month' => "12",
        'expiration_year' => "2015",
        'security_code' => "373",
        'card_number' => "4532395075641483",
    ]);
    
    dd($ccToken);
}

2 - 创建新的个人卖家

在你的控制器中

namespace App\Http\Controllers;
 
use Zoop\src\Facades\ZoopSellers;
 
class HomeController extends Controller{
    $individualSeller = ZoopSellers::create([
        'first_name' => 'Rodrigo',
        'last_name' => "Miranda",
        'email' => "rodrigo@pagzoop.com",
        'phone_number' => "+12195465432",
        'ssn_last4_digits' => "7551",
        'birthdate' => "1983-09-11",
        'website' => "http://pagzoop.com",
        'facebook' => "https://#/rodrigo",
        'twitter' => "http://twitter.com/hypercreative",
    ]);
    
    dd($individualSeller);
}

3 - 创建新的买家

在你的控制器中

namespace App\Http\Controllers;
 
use Zoop\src\Facades\ZoopBuyers;
 
class HomeController extends Controller{
    $buyer = ZoopBuyers::create([
        'first_name' => 'Fabiano',
        'last_name' => 'Cruz',
        'description' => 'Comprador de teste',
        'email' => 'fabiano@example.com',
    ]);
    
    dd($buyer);
}

4 - 非面对面交易

在你的控制器中

namespace App\Http\Controllers;
 
use Zoop\src\Facades\ZoopChargeCNP;
 
class HomeController extends Controller{
    $cnp = ZoopChargesCNP::create([
        'currency' => 'BRL',
        'amount' => '100',
        'payment_type' => 'credit',
        'description' => 'Venda de teste, somente!',
        'statement_descriptor' => 'Descrição de testes',
        'on_behalf_of' => 'bb2a51f1c22a4c30b6bf6819be87ac52',
        'installment_plan' => [
            'mode' => 'interest_free',
            'number_installments' => '1'
        ],
        'customer' => 'bb2a51f1c22a4c30b6bf6819be87ac52', //buyer id
    ]);
    
    dd($cnp);
}

ZOOP API 参考

https://docs.zoop.co/v1/reference