Răsfoiți Sursa

feat: add integracao de recipient em provider

Gustavo Mantovani 1 lună în urmă
părinte
comite
cf8fca7350

+ 40 - 1
app/Http/Requests/ProviderRequest.php

@@ -4,7 +4,6 @@ namespace App\Http\Requests;
 
 use Illuminate\Foundation\Http\FormRequest;
 use Illuminate\Validation\Rule;
-use App\Enums\UserTypeEnum;
 use App\Enums\ApprovalStatusEnum;
 
 class ProviderRequest extends FormRequest
@@ -67,6 +66,27 @@ class ProviderRequest extends FormRequest
             'daily_price_4h' => 'sometimes|nullable|numeric',
             'daily_price_2h' => 'sometimes|nullable|numeric',
             'profile_media_id' => 'sometimes|nullable|exists:media,id',
+            'recipient_name' => 'sometimes|string|max:255',
+            'recipient_email' => 'sometimes|email|max:255',
+            'recipient_description' => 'sometimes|nullable|string',
+            'recipient_document' => 'sometimes|string|max:20',
+            'recipient_type' => ['sometimes', Rule::in(['individual', 'company'])],
+            'recipient_code' => 'sometimes|string|max:255',
+            'recipient_payment_mode' => ['sometimes', Rule::in(['bank_transfer'])],
+            'recipient_default_bank_account' => 'sometimes|array',
+            'recipient_default_bank_account.holder_name' => 'sometimes|string|max:255',
+            'recipient_default_bank_account.holder_type' => ['sometimes', Rule::in(['individual', 'company'])],
+            'recipient_default_bank_account.holder_document' => 'sometimes|string|max:20',
+            'recipient_default_bank_account.bank' => 'sometimes|string|max:20',
+            'recipient_default_bank_account.branch_number' => 'sometimes|string|max:20',
+            'recipient_default_bank_account.branch_check_digit' => 'sometimes|nullable|string|max:10',
+            'recipient_default_bank_account.account_number' => 'sometimes|string|max:20',
+            'recipient_default_bank_account.account_check_digit' => 'sometimes|string|max:10',
+            'recipient_default_bank_account.type' => ['sometimes', Rule::in(['checking', 'savings'])],
+            'recipient_default_bank_account.metadata' => 'sometimes|array',
+            'recipient_default_bank_account.metadata.*' => 'sometimes|string',
+            'recipient_default_bank_account.pix_key' => 'sometimes|nullable|string|max:255',
+            'recipient_metadata' => 'sometimes|array',
         ];
 
         if ($this->isMethod('post')) {
@@ -81,6 +101,25 @@ class ProviderRequest extends FormRequest
                 },
                 Rule::unique('providers', 'document')->whereNull('deleted_at'),
             ];
+            $rules['recipient_name'] = 'required|string|max:255';
+            $rules['recipient_email'] = 'required|email|max:255';
+            $rules['recipient_description'] = 'required|string';
+            $rules['recipient_document'] = 'required|string|max:20';
+            $rules['recipient_type'] = ['required', Rule::in(['individual', 'company'])];
+            $rules['recipient_code'] = 'required|string|max:255';
+            $rules['recipient_payment_mode'] = ['required', Rule::in(['bank_transfer'])];
+            $rules['recipient_default_bank_account'] = 'required|array';
+            $rules['recipient_default_bank_account.holder_name'] = 'required|string|max:255';
+            $rules['recipient_default_bank_account.holder_type'] = ['required', Rule::in(['individual', 'company'])];
+            $rules['recipient_default_bank_account.holder_document'] = 'required|string|max:20';
+            $rules['recipient_default_bank_account.bank'] = 'required|string|max:20';
+            $rules['recipient_default_bank_account.branch_number'] = 'required|string|max:20';
+            $rules['recipient_default_bank_account.branch_check_digit'] = 'sometimes|nullable|string|max:10';
+            $rules['recipient_default_bank_account.account_number'] = 'required|string|max:20';
+            $rules['recipient_default_bank_account.account_check_digit'] = 'required|string|max:10';
+            $rules['recipient_default_bank_account.type'] = ['required', Rule::in(['checking', 'savings'])];
+            $rules['recipient_default_bank_account.metadata'] = 'required|array';
+            $rules['recipient_metadata'] = 'required|array';
             $rules['user_id'] = [
                 'required',
                 'exists:users,id',

+ 20 - 0
app/Http/Requests/RegisterProviderRequest.php

@@ -18,6 +18,26 @@ class RegisterProviderRequest extends FormRequest
       'document' => ['required', 'string', 'max:20'],
       'rg' => 'required|string|max:20',
       'birth_date' => 'required|date|before:today',
+      'recipient_name' => 'required|string|max:255',
+      'recipient_email' => 'required|email|max:255',
+      'recipient_description' => 'required|string',
+      'recipient_document' => 'required|string|max:20',
+      'recipient_type' => ['required', Rule::in(['individual', 'company'])],
+      'recipient_code' => 'required|string|max:255',
+      'recipient_payment_mode' => ['required', Rule::in(['bank_transfer'])],
+      'recipient_default_bank_account' => 'required|array',
+      'recipient_default_bank_account.holder_name' => 'required|string|max:255',
+      'recipient_default_bank_account.holder_type' => ['required', Rule::in(['individual', 'company'])],
+      'recipient_default_bank_account.holder_document' => 'required|string|max:20',
+      'recipient_default_bank_account.bank' => 'required|string|max:20',
+      'recipient_default_bank_account.branch_number' => 'required|string|max:20',
+      'recipient_default_bank_account.branch_check_digit' => 'sometimes|nullable|string|max:10',
+      'recipient_default_bank_account.account_number' => 'required|string|max:20',
+      'recipient_default_bank_account.account_check_digit' => 'required|string|max:10',
+      'recipient_default_bank_account.type' => ['required', Rule::in(['checking', 'savings'])],
+      'recipient_default_bank_account.metadata' => 'required|array',
+      'recipient_default_bank_account.pix_key' => 'sometimes|nullable|string|max:255',
+      'recipient_metadata' => 'required|array',
 
       'zip_code' => 'required|string|max:20',
       'address' => 'required|string|max:255',

+ 1 - 0
app/Http/Resources/ProviderResource.php

@@ -29,6 +29,7 @@ class ProviderResource extends JsonResource
             'daily_price_4h' => $this->daily_price_4h,
             'daily_price_2h' => $this->daily_price_2h,
             'profile_media_id' => $this->profile_media_id,
+            'recipient_id' => $this->recipient_id,
             'profile_media' => $this->profileMedia,
             'created_at' => Carbon::parse($this->created_at)->format('d/m/Y H:i'),
             'updated_at' => Carbon::parse($this->updated_at)->format('d/m/Y H:i'),

+ 46 - 11
app/Models/Provider.php

@@ -15,26 +15,57 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @property string $document
  * @property string|null $rg
  * @property int $user_id
- * @property float|null $average_rating
+ * @property numeric|null $average_rating
  * @property int $total_services
- * @property string|null $birth_date
+ * @property \Illuminate\Support\Carbon|null $birth_date
  * @property bool $selfie_verified
  * @property bool $document_verified
- * @property string $approval_status
- * @property float|null $daily_price_8h
- * @property float|null $daily_price_6h
- * @property float|null $daily_price_4h
- * @property float|null $daily_price_2h
+ * @property numeric|null $daily_price_8h
+ * @property numeric|null $daily_price_6h
+ * @property numeric|null $daily_price_4h
+ * @property numeric|null $daily_price_2h
  * @property int|null $profile_media_id
  * @property \Illuminate\Support\Carbon|null $created_at
  * @property \Illuminate\Support\Carbon|null $updated_at
  * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property-read \App\Models\User $user
+ * @property string|null $selfie_media_base64
+ * @property string|null $document_front_media_base64
+ * @property string|null $document_back_media_base64
+ * @property ApprovalStatusEnum $approval_status
+ * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Address> $addresses
+ * @property-read int|null $addresses_count
+ * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientProviderBlock> $blockedByClients
+ * @property-read int|null $blocked_by_clients_count
+ * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProviderClientBlock> $blockedClients
+ * @property-read int|null $blocked_clients_count
+ * @property-read \App\Models\Address|null $primaryAddress
  * @property-read \App\Models\Media|null $profileMedia
+ * @property-read \App\Models\User $user
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider query()
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereApprovalStatus($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereAverageRating($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereBirthDate($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDailyPrice2h($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDailyPrice4h($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDailyPrice6h($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDailyPrice8h($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDeletedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocument($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentBackMediaBase64($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentFrontMediaBase64($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereDocumentVerified($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereProfileMediaId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereRg($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereSelfieMediaBase64($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereSelfieVerified($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereTotalServices($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider whereUserId($value)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider withTrashed(bool $withTrashed = true)
  * @method static \Illuminate\Database\Eloquent\Builder<static>|Provider withoutTrashed()
  * @mixin \Eloquent
@@ -52,9 +83,9 @@ class Provider extends Model
    *
    * @return array<string, string>
    */
-  protected function casts(): array
-  {
-    return [
+    protected function casts(): array
+    {
+        return [
       "birth_date" => "date",
       "selfie_verified"   => "boolean",
       "document_verified" => "boolean",
@@ -65,6 +96,10 @@ class Provider extends Model
       "daily_price_4h" => "decimal:2",
       "daily_price_2h" => "decimal:2",
       "total_services" => "integer",
+      "recipient_default_bank_account" => "array",
+      "recipient_transfer_settings" => "array",
+      "recipient_automatic_anticipation_settings" => "array",
+      "recipient_metadata" => "array",
     ];
   }
 

+ 136 - 0
app/Services/Pagarme/PagarmeRecipientService.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace App\Services\Pagarme;
+
+use App\Models\Provider;
+use PagarmeApiSDKLib\Authentication\BasicAuthCredentialsBuilder;
+use PagarmeApiSDKLib\Models\Builders\CreateBankAccountRequestBuilder;
+use PagarmeApiSDKLib\Models\Builders\CreateRecipientRequestBuilder;
+use PagarmeApiSDKLib\Models\Builders\CreateTransferSettingsRequestBuilder;
+use PagarmeApiSDKLib\Models\Builders\UpdateAutomaticAnticipationSettingsRequestBuilder;
+use PagarmeApiSDKLib\PagarmeApiSDKClient;
+use PagarmeApiSDKLib\PagarmeApiSDKClientBuilder;
+
+class PagarmeRecipientService
+{
+    private ?PagarmeApiSDKClient $client = null;
+
+    public function createRecipientForProvider(Provider $provider, array $data): string
+    {
+        if (!empty($provider->recipient_id)) {
+            return $provider->recipient_id;
+        }
+
+        $client = $this->client();
+        $bankAccountData = $data['recipient_default_bank_account'];
+        $metadata = $data['recipient_metadata'] ?? [];
+        $paymentMode = $data['recipient_payment_mode'];
+
+        $bankAccount = CreateBankAccountRequestBuilder::init(
+            $bankAccountData['holder_name'],
+            $bankAccountData['holder_type'],
+            $bankAccountData['holder_document'],
+            $bankAccountData['bank'],
+            $bankAccountData['branch_number'],
+            $bankAccountData['account_number'],
+            $bankAccountData['account_check_digit'],
+            $bankAccountData['type'],
+            $bankAccountData['metadata'] ?? []
+        )
+            ->branchCheckDigit($bankAccountData['branch_check_digit'] ?? null)
+            ->pixKey($bankAccountData['pix_key'] ?? null)
+            ->build();
+
+        $recipientRequest = CreateRecipientRequestBuilder::init(
+            $bankAccount,
+            $metadata,
+            $data['recipient_code'],
+            $paymentMode
+        )
+            ->name($data['recipient_name'])
+            ->email($data['recipient_email'])
+            ->description($data['recipient_description'])
+            ->document($data['recipient_document'])
+            ->type($data['recipient_type']);
+
+        $recipientTransferSettings = CreateTransferSettingsRequestBuilder::init(false, 'daily', 0)->build();
+
+        $recipientRequest->transferSettings($recipientTransferSettings);
+
+        $recipient = $client->getRecipientsController()->createRecipient(
+            $recipientRequest->build(),
+            $this->idempotencyKey($provider->id)
+        );
+
+        $recipientId = $recipient->getId();
+        if (!$recipientId) {
+            throw new \RuntimeException('Pagar.me recipient creation returned an empty id.');
+        }
+
+        $provider->forceFill([
+            'recipient_id' => $recipientId,
+            'recipient_name' => $data['recipient_name'],
+            'recipient_email' => $data['recipient_email'],
+            'recipient_description' => $data['recipient_description'],
+            'recipient_document' => $data['recipient_document'],
+            'recipient_type' => $data['recipient_type'],
+            'recipient_code' => $data['recipient_code'],
+            'recipient_payment_mode' => $paymentMode,
+            'recipient_default_bank_account' => $bankAccountData,
+            'recipient_transfer_settings' => [
+                'transfer_enabled' => false,
+                'transfer_interval' => 'daily',
+                'transfer_day' => 0,
+            ],
+            'recipient_automatic_anticipation_settings' => [
+                'enabled' => false,
+            ],
+            'recipient_metadata' => $metadata,
+        ])->save();
+
+        $this->applyAutomaticAnticipationSettings($provider->id, $recipientId);
+
+        return $recipientId;
+    }
+
+    private function applyAutomaticAnticipationSettings(int $providerId, string $recipientId): void
+    {
+        $request = UpdateAutomaticAnticipationSettingsRequestBuilder::init()
+            ->enabled(false)
+            ->build();
+
+        $this->client()->getRecipientsController()->updateAutomaticAnticipationSettings(
+            $recipientId,
+            $request,
+            $this->idempotencyKey($providerId, 'auto-anticipation')
+        );
+    }
+
+    private function client(): PagarmeApiSDKClient
+    {
+        if ($this->client) {
+            return $this->client;
+        }
+
+        $secretKey = config('services.pagarme.secret_key');
+        if (empty($secretKey)) {
+            throw new \RuntimeException('PAGARME_SECRET_KEY is not configured.');
+        }
+
+        $serviceRefererName = (string) config('services.pagarme.service_referer_name', config('app.name'));
+
+        $this->client = PagarmeApiSDKClientBuilder::init()
+            ->basicAuthCredentials(
+                BasicAuthCredentialsBuilder::init($secretKey, '')
+            )
+            ->serviceRefererName($serviceRefererName)
+            ->build();
+
+        return $this->client;
+    }
+
+    private function idempotencyKey(int $providerId, string $suffix = 'recipient'): string
+    {
+        return "provider-{$providerId}-{$suffix}";
+    }
+}

+ 12 - 1
app/Services/ProviderService.php

@@ -11,6 +11,7 @@ use App\Models\ProviderServicesType;
 use App\Models\ProviderWorkingDay;
 use App\Models\State;
 use App\Models\User;
+use App\Services\Pagarme\PagarmeRecipientService;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Pagination\LengthAwarePaginator;
 use Illuminate\Support\Facades\DB;
@@ -20,6 +21,7 @@ class ProviderService
 {
   public function __construct(
     private readonly AuthService $authService,
+    private readonly PagarmeRecipientService $pagarmeRecipientService,
   ) {}
 
   public function getAll(): Collection
@@ -39,7 +41,15 @@ class ProviderService
 
   public function create(array $data): Provider
   {
-    return Provider::create($data);
+    return DB::transaction(function () use ($data) {
+      $provider = Provider::create($data);
+
+      if (!empty($data['recipient_code'])) {
+        $this->pagarmeRecipientService->createRecipientForProvider($provider, $data);
+      }
+
+      return $provider->fresh(['user', 'profileMedia']);
+    });
   }
 
   public function update(int $id, array $data): ?Provider
@@ -148,6 +158,7 @@ class ProviderService
       $provider->save();
       $provider->refresh();
 
+      $this->pagarmeRecipientService->createRecipientForProvider($provider, $data);
       $this->createProviderAddress($provider->id, $data);
       $this->createProviderServicesTypes($provider->id, $data);
       $this->createProviderWorkingDays($provider->id, $data);

+ 2 - 1
composer.json

@@ -12,7 +12,8 @@
         "kalnoy/nestedset": "^6.0",
         "laravel/framework": "^12.0",
         "laravel/sanctum": "^4.0",
-        "laravel/tinker": "^2.9"
+        "laravel/tinker": "^2.9",
+        "pagarme/pagarme-php-sdk": "^6.8"
     },
     "require-dev": {
         "barryvdh/laravel-ide-helper": "^3.6",

+ 333 - 4
composer.lock

@@ -4,8 +4,225 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "40404f977a56fc05d7f7679557905a6b",
+    "content-hash": "0b19352c401e0079ba79bdf74477b3fb",
     "packages": [
+        {
+            "name": "apimatic/core",
+            "version": "0.3.17",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/apimatic/core-lib-php.git",
+                "reference": "a48a583f686ee3786432b976c795a2817ec095b3"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/apimatic/core-lib-php/zipball/a48a583f686ee3786432b976c795a2817ec095b3",
+                "reference": "a48a583f686ee3786432b976c795a2817ec095b3",
+                "shasum": ""
+            },
+            "require": {
+                "apimatic/core-interfaces": "~0.1.5",
+                "apimatic/jsonmapper": "^3.1.1",
+                "ext-curl": "*",
+                "ext-dom": "*",
+                "ext-json": "*",
+                "ext-libxml": "*",
+                "php": "^7.2 || ^8.0",
+                "php-jsonpointer/php-jsonpointer": "^3.0.2",
+                "psr/log": "^1.1.4 || ^2.0.0 || ^3.0.0",
+                "symfony/http-foundation": "^5.4 || ^6.0 || ^7.0 || ^8.0"
+            },
+            "require-dev": {
+                "phan/phan": "5.4.5",
+                "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+                "squizlabs/php_codesniffer": "^3.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Core\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "Core logic and the utilities for the Apimatic's PHP SDK",
+            "homepage": "https://github.com/apimatic/core-lib-php",
+            "keywords": [
+                "apimatic",
+                "core",
+                "corelib",
+                "php"
+            ],
+            "support": {
+                "issues": "https://github.com/apimatic/core-lib-php/issues",
+                "source": "https://github.com/apimatic/core-lib-php/tree/0.3.17"
+            },
+            "time": "2026-01-27T05:14:10+00:00"
+        },
+        {
+            "name": "apimatic/core-interfaces",
+            "version": "0.1.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/apimatic/core-interfaces-php.git",
+                "reference": "b4f1bffc8be79584836f70af33c65e097eec155c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/apimatic/core-interfaces-php/zipball/b4f1bffc8be79584836f70af33c65e097eec155c",
+                "reference": "b4f1bffc8be79584836f70af33c65e097eec155c",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "CoreInterfaces\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "description": "Definition of the behavior of apimatic/core, apimatic/unirest-php and Apimatic's PHP SDK",
+            "homepage": "https://github.com/apimatic/core-interfaces-php",
+            "keywords": [
+                "apimatic",
+                "core",
+                "corelib",
+                "interface",
+                "php",
+                "unirest"
+            ],
+            "support": {
+                "issues": "https://github.com/apimatic/core-interfaces-php/issues",
+                "source": "https://github.com/apimatic/core-interfaces-php/tree/0.1.5"
+            },
+            "time": "2024-05-09T06:32:07+00:00"
+        },
+        {
+            "name": "apimatic/jsonmapper",
+            "version": "3.1.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/apimatic/jsonmapper.git",
+                "reference": "61e45f6021e4a4e07497be596b4787c3c6b39bea"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/apimatic/jsonmapper/zipball/61e45f6021e4a4e07497be596b4787c3c6b39bea",
+                "reference": "61e45f6021e4a4e07497be596b4787c3c6b39bea",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "php": "^5.6 || ^7.0 || ^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
+                "squizlabs/php_codesniffer": "^3.0.0"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "apimatic\\jsonmapper\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "OSL-3.0"
+            ],
+            "authors": [
+                {
+                    "name": "Christian Weiske",
+                    "email": "christian.weiske@netresearch.de",
+                    "homepage": "http://www.netresearch.de/",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Mehdi Jaffery",
+                    "email": "mehdi.jaffery@apimatic.io",
+                    "homepage": "http://apimatic.io/",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Map nested JSON structures onto PHP classes",
+            "support": {
+                "email": "mehdi.jaffery@apimatic.io",
+                "issues": "https://github.com/apimatic/jsonmapper/issues",
+                "source": "https://github.com/apimatic/jsonmapper/tree/3.1.7"
+            },
+            "time": "2025-11-06T14:43:04+00:00"
+        },
+        {
+            "name": "apimatic/unirest-php",
+            "version": "4.0.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/apimatic/unirest-php.git",
+                "reference": "bdfd5f27c105772682c88ed671683f1bd93f4a3c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/apimatic/unirest-php/zipball/bdfd5f27c105772682c88ed671683f1bd93f4a3c",
+                "reference": "bdfd5f27c105772682c88ed671683f1bd93f4a3c",
+                "shasum": ""
+            },
+            "require": {
+                "apimatic/core-interfaces": "^0.1.0",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "php": "^7.2 || ^8.0"
+            },
+            "require-dev": {
+                "phan/phan": "5.4.2",
+                "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
+                "squizlabs/php_codesniffer": "^3.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Unirest\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mashape",
+                    "email": "opensource@mashape.com",
+                    "homepage": "https://www.mashape.com",
+                    "role": "Developer"
+                },
+                {
+                    "name": "APIMATIC",
+                    "email": "opensource@apimatic.io",
+                    "homepage": "https://www.apimatic.io",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Unirest PHP",
+            "homepage": "https://github.com/apimatic/unirest-php",
+            "keywords": [
+                "client",
+                "curl",
+                "http",
+                "https",
+                "rest"
+            ],
+            "support": {
+                "email": "opensource@apimatic.io",
+                "issues": "https://github.com/apimatic/unirest-php/issues",
+                "source": "https://github.com/apimatic/unirest-php/tree/4.0.7"
+            },
+            "time": "2025-06-17T09:09:48+00:00"
+        },
         {
             "name": "brick/math",
             "version": "0.13.1",
@@ -2634,6 +2851,118 @@
             ],
             "time": "2025-05-08T08:14:37+00:00"
         },
+        {
+            "name": "pagarme/pagarme-php-sdk",
+            "version": "6.8.17",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pagarme/pagarme-php-sdk.git",
+                "reference": "b58c1105bc2afe803bcc083b236538d723d85997"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pagarme/pagarme-php-sdk/zipball/b58c1105bc2afe803bcc083b236538d723d85997",
+                "reference": "b58c1105bc2afe803bcc083b236538d723d85997",
+                "shasum": ""
+            },
+            "require": {
+                "apimatic/core": "~0.3.13",
+                "apimatic/core-interfaces": "~0.1.5",
+                "apimatic/unirest-php": "^4.0.6",
+                "ext-curl": "*",
+                "ext-json": "*",
+                "php": "^7.2 || ^8.0"
+            },
+            "require-dev": {
+                "phan/phan": "5.4.5",
+                "squizlabs/php_codesniffer": "^3.5"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "PagarmeApiSDKLib\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Pagar.me Pagamentos S/A",
+                    "email": "suporte@pagar.me",
+                    "homepage": "https://github.com/pagarme/"
+                }
+            ],
+            "description": "Pagarme API",
+            "homepage": "https://github.com/pagarme/",
+            "keywords": [
+                "PagarmeApiSDK",
+                "api",
+                "sdk"
+            ],
+            "support": {
+                "issues": "https://github.com/pagarme/pagarme-php-sdk/issues",
+                "source": "https://github.com/pagarme/pagarme-php-sdk/tree/6.8.17"
+            },
+            "time": "2025-05-13T13:22:34+00:00"
+        },
+        {
+            "name": "php-jsonpointer/php-jsonpointer",
+            "version": "v3.0.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/raphaelstolt/php-jsonpointer.git",
+                "reference": "4428f86c6f23846e9faa5a420c4ef14e485b3afb"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/raphaelstolt/php-jsonpointer/zipball/4428f86c6f23846e9faa5a420c4ef14e485b3afb",
+                "reference": "4428f86c6f23846e9faa5a420c4ef14e485b3afb",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.4"
+            },
+            "require-dev": {
+                "friendsofphp/php-cs-fixer": "^1.11",
+                "phpunit/phpunit": "4.6.*"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-0": {
+                    "Rs\\Json": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Raphael Stolt",
+                    "email": "raphael.stolt@gmail.com",
+                    "homepage": "http://raphaelstolt.blogspot.com/"
+                }
+            ],
+            "description": "Implementation of JSON Pointer (http://tools.ietf.org/html/rfc6901)",
+            "homepage": "https://github.com/raphaelstolt/php-jsonpointer",
+            "keywords": [
+                "json",
+                "json pointer",
+                "json traversal"
+            ],
+            "support": {
+                "issues": "https://github.com/raphaelstolt/php-jsonpointer/issues",
+                "source": "https://github.com/raphaelstolt/php-jsonpointer/tree/master"
+            },
+            "time": "2016-08-29T08:51:01+00:00"
+        },
         {
             "name": "phpoption/phpoption",
             "version": "1.9.3",
@@ -8436,12 +8765,12 @@
     ],
     "aliases": [],
     "minimum-stability": "stable",
-    "stability-flags": [],
+    "stability-flags": {},
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
         "php": "^8.3"
     },
-    "platform-dev": [],
-    "plugin-api-version": "2.3.0"
+    "platform-dev": {},
+    "plugin-api-version": "2.6.0"
 }

+ 5 - 0
config/services.php

@@ -35,4 +35,9 @@ return [
         ],
     ],
 
+    'pagarme' => [
+        'secret_key' => env('PAGARME_SECRET_KEY'),
+        'service_referer_name' => env('PAGARME_SERVICE_REFERER_NAME', env('APP_NAME', 'Laravel')),
+    ],
+
 ];

+ 48 - 0
database/migrations/2026_05_15_000002_add_pagarme_recipient_fields_to_providers_table.php

@@ -0,0 +1,48 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->string('recipient_id')->nullable()->unique()->after('profile_media_id');
+            $table->string('recipient_name')->nullable()->after('recipient_id');
+            $table->string('recipient_email')->nullable()->after('recipient_name');
+            $table->text('recipient_description')->nullable()->after('recipient_email');
+            $table->string('recipient_document')->nullable()->after('recipient_description');
+            $table->string('recipient_type')->nullable()->after('recipient_document');
+            $table->string('recipient_code')->nullable()->after('recipient_type');
+            $table->string('recipient_payment_mode')->nullable()->after('recipient_code');
+
+            $table->json('recipient_default_bank_account')->nullable()->after('recipient_payment_mode');
+            $table->json('recipient_transfer_settings')->nullable()->after('recipient_default_bank_account');
+            $table->json('recipient_automatic_anticipation_settings')->nullable()->after('recipient_transfer_settings');
+            $table->json('recipient_metadata')->nullable()->after('recipient_automatic_anticipation_settings');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->dropUnique('providers_recipient_id_unique');
+            $table->dropColumn([
+                'recipient_id',
+                'recipient_name',
+                'recipient_email',
+                'recipient_description',
+                'recipient_document',
+                'recipient_type',
+                'recipient_code',
+                'recipient_payment_mode',
+                'recipient_default_bank_account',
+                'recipient_transfer_settings',
+                'recipient_automatic_anticipation_settings',
+                'recipient_metadata',
+            ]);
+        });
+    }
+};