Pix Cobrança Dinâmico Imediata Saque Sem Valor
This commit is contained in:
parent
df99b098e3
commit
96769b84c5
3 changed files with 85 additions and 0 deletions
45
src/Pix.php
45
src/Pix.php
|
@ -79,4 +79,49 @@ class Pix extends Kore
|
||||||
$payload
|
$payload
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function pixCobrancaDinamicoImediatoSaqueSemValor($payload)
|
||||||
|
{
|
||||||
|
pixCobrancaImediataSaqueSemValorRules($payload);
|
||||||
|
$korePayload = [
|
||||||
|
'calendario' => [
|
||||||
|
'expiracao' => $payload['expiracao'] ?? 86400,
|
||||||
|
],
|
||||||
|
'valor' => [
|
||||||
|
'original' => 0,
|
||||||
|
'retirada' => [
|
||||||
|
'saque' => [
|
||||||
|
'valor' => $payload['valor'] ?? 0,
|
||||||
|
'modalidadeAlteracao' => 0,
|
||||||
|
'prestadorDoServicoDeSaque' => $payload['ispb'],
|
||||||
|
'modalidadeAgente' => $payload['modalidadeAgente']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'chave' => $payload['chave'],
|
||||||
|
'txid' => $payload['txid'],
|
||||||
|
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($payload['devedor'])){
|
||||||
|
if (strlen($payload['devedor']['documento']) > 11){
|
||||||
|
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
|
||||||
|
}else{
|
||||||
|
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
|
||||||
|
}
|
||||||
|
$korePayload['devedor']['nome'] = $payload['devedor'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return curlRequest(
|
||||||
|
'https://httpbin.org/post',
|
||||||
|
'POST',
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'x-kore-drone-uid: drone:' . $this->drone,
|
||||||
|
'x-kore-drone-sign: ' . $this->signBody($korePayload)
|
||||||
|
],
|
||||||
|
$payload
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,3 +43,27 @@ function pixCobrancaImediataSemValorRules(array $data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function pixCobrancaImediataSaqueSemValorRules(array $data)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'expiracao' => 'integer',
|
||||||
|
'devedor' => 'sometimes|array',
|
||||||
|
'devedor.documento' => 'sometimes|string|min:11|max:18',
|
||||||
|
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
|
||||||
|
'valor' => 'sometimes|integer',
|
||||||
|
'chave' => 'required|string',
|
||||||
|
'txid' => 'required|string|max:100',
|
||||||
|
'solicitacaoPagador' => 'string|max:140',
|
||||||
|
'ispb' => 'required|string',
|
||||||
|
'modalidadeAgente' => 'required|string|in:agtec,agtot,agpss'
|
||||||
|
];
|
||||||
|
|
||||||
|
$validate = validate($data, $rules);
|
||||||
|
if (!$validate['valid']) {
|
||||||
|
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,22 @@ function validate_array($field, $value, $param = null, $data = [])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validate_in($field, $value, $param, $data = [])
|
||||||
|
{
|
||||||
|
if ($param === null) {
|
||||||
|
return "The rule 'in' requires a list of accepted values.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$accepted = explode(',', $param);
|
||||||
|
|
||||||
|
if (!in_array((string) $value, $accepted, true)) {
|
||||||
|
return "The field '$field' must be one of: " . implode(', ', $accepted) . ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function validate_integer($field, $value, $param = null, $data = [])
|
function validate_integer($field, $value, $param = null, $data = [])
|
||||||
{
|
{
|
||||||
if (!is_int($value)) {
|
if (!is_int($value)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue