Skip to content

Commit

Permalink
Merge pull request #425 from pagarme/feat/pcag-772-add-kyc-link-route-v3
Browse files Browse the repository at this point in the history
feat: add generate kyc link route v3
  • Loading branch information
andreals authored May 2, 2024
2 parents aad3b46 + 4bcdab6 commit 495bcbf
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Integração em PHP para a [Pagar.me API](https://docs.pagar.me/)
- [Saldo de um recebedor](#Saldo-de-um-recebedor)
- [Operações de saldo de um recebedor](#Operações-de-saldo-de-um-recebedor)
- [Operação de saldo específica de um recebedor](#Operação-de-saldo-específica-de-um-recebedor)
- [Gerando um link kyc](#Gerando-link-kyc)
- [Clientes](#Clientes)
- [Criando um cliente](#Criando-um-cliente)
- [Retornando clientes](#Retornando-clientes)
Expand Down Expand Up @@ -1040,6 +1041,13 @@ $balanceOperationId = 2043993;
$operation = $pagarMe->recipient()->balanceOperation($recipient, $balanceOperationId);
```

### Gerando Link Kyc
```php
<?php
$recipientId = "re_cj3g1cml000e75f6ehjnpsl9y";
$link = $pagarMe->recipient()->generateKycLink($recipientId);
```

## Clientes

Clientes representam os usuários de sua loja, ou negócio. Este objeto contém informações sobre eles, como nome, e-mail e telefone, além de outros campos.
Expand Down
19 changes: 19 additions & 0 deletions lib/Recipient/RecipientHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,23 @@ public function balanceOperations(

return $operations;
}

/**
* @param string $recipientId
* @return array
*/
public function generateKycLink($recipientId)
{
$request = new RecipientGenerateKycLink($recipientId);

$response = $this->client->send($request);

$links = [];

foreach ($response as $link) {
$links[] = $link;
}

return $links;
}
}
49 changes: 49 additions & 0 deletions lib/Recipient/Request/RecipientGenerateKycLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace PagarMe\Sdk\Recipient\Request;

use PagarMe\Sdk\RequestInterface;
use PagarMe\Sdk\Recipient\Recipient;

class RecipientGenerateKycLink implements RequestInterface
{
/**
* @var int
*/
private $recipientId;

/**
* @param int $recipientId
*/
public function __construct($recipientId)
{
$this->recipientId = $recipientId;
}

/**
* @return array
*/
public function getPayload()
{
return [];
}

/**
* @return string
*/
public function getPath()
{
return sprintf(
'recipients/%s/kyc_link',
$this->recipientId
);
}

/**
* @return string
*/
public function getMethod()
{
return self::HTTP_POST;
}
}
45 changes: 45 additions & 0 deletions tests/unit/Recipient/Request/RecipientGenerateKycLinkTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace PagarMe\SdkTests\Recipient;

use PagarMe\Sdk\Recipient\Request\RecipientGenerateKycLink;
use PagarMe\Sdk\RequestInterface;

class RecipientGenerateKycLinkTest extends \PHPUnit_Framework_TestCase
{
const ID = 're_x1y2z3';
const PATH = 'recipients/re_x1y2z3/kyc_link';

/**
* @test
*/
public function mustPathBeCorrect()
{
$recipientGenerateKycLink = new RecipientGenerateKycLink(self::ID);

$this->assertEquals(self::PATH, $recipientGenerateKycLink->getPath());
}

/**
* @test
*/
public function mustMethodBeCorrect()
{
$recipientGenerateKycLink = new RecipientGenerateKycLink(self::ID);

$this->assertEquals(RequestInterface::HTTP_POST, $recipientGenerateKycLink->getMethod());
}

/**
* @test
*/
public function mustPayloadBeCorrect()
{
$recipientGenerateKycLink = new RecipientGenerateKycLink(self::ID);

$this->assertEquals(
[],
$recipientGenerateKycLink->getPayload()
);
}
}

0 comments on commit 495bcbf

Please sign in to comment.