PagarmeTransferService.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Services\Pagarme;
  3. use App\Data\Pagarme\Request\PagarmeTransferRequestData;
  4. use App\Services\Pagarme\Concerns\SendsPagarmeRequests;
  5. class PagarmeTransferService
  6. {
  7. use SendsPagarmeRequests;
  8. public function createTransfer(int $amountInCents, string $recipientId, string $idempotencyKey): array
  9. {
  10. return $this->pagarmeRequest(
  11. method: 'POST',
  12. path: '/transfers',
  13. payload: new PagarmeTransferRequestData(
  14. amount: $amountInCents,
  15. recipientId: $recipientId,
  16. ),
  17. idempotencyKey: $idempotencyKey,
  18. errorMessage: 'Erro ao criar transferencia (saque) no Pagar.me.',
  19. );
  20. }
  21. public function getTransfer(string $transferId): array
  22. {
  23. return $this->pagarmeRequest(
  24. method: 'GET',
  25. path: "/transfers/{$transferId}",
  26. payload: [],
  27. idempotencyKey: "get-transfer-{$transferId}",
  28. errorMessage: 'Erro ao consultar transferencia no Pagar.me.',
  29. );
  30. }
  31. }