Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Its not allowed to use split_rules" #401

Open
thainan76 opened this issue May 22, 2022 · 0 comments
Open

Error "Its not allowed to use split_rules" #401

thainan76 opened this issue May 22, 2022 · 0 comments

Comments

@thainan76
Copy link

thainan76 commented May 22, 2022

Olá, tudo bem?

Estou usando cURL do PHP para gerar um boleto com divisões (split_rules) aos recebedores, porém quando passo o parâmetros, vem um retorno da API de "Its not allowed to use split_rules".

Já tentei como "splitRules", porém retorna o split_rules como null e não cria as divisões.
Tentei utilizar o endpoit "/capture" colocando id da transição, mas diz que é não é possível pois o boleto está com o status de pagamento como "waiting_payment".

URL: https://api.pagar.me/1/transactions
Versão 4 da API.
Link da versão: https://docs.pagar.me/v4/reference

Resultado:

{
   "errors":[
      {
         "type":"invalid_parameter",
         "parameter_name":"split_rules",
         "message":"Its not allowed to use split_rules"
      }
   ],
   "url":"/transactions",
   "method":"post"
}

Scripit:

$dados = '{
			"api_key": "'.$token.'",
			"amount": '.$total.',
			"postback_url": "https://terapiadodia.com.br/notifymoipterapia/user/moip/notificacao",
			"payment_method": "boleto",
			"async": false,
			"customer": {
				"external_id": "'.$cliente->id_cliente.'",
				"name": "'.$cliente->nome.'",
				"type": "individual",
				"country": "br",
				"email": "'.$cliente->email.'",
				"documents": [
					{
						"type": "cpf",
						"number": "'.$cliente->cpf.'"
					}
				],
				"phone_numbers": ["'.$cartao_telefone.'"],
				"birthday": "'.$cartao_nascimento.'"
			},
			"billing": {
			"name": "'.$cliente->nome.'",
			"address": {
				"country": "br",
				"state": "'.$cliente->uf.'",
				"city": "'.$cliente->cidade.'",
				"neighborhood": "'.$cliente->bairro.'",
				"street": "'.$cliente->endereco.'",
				"street_number": "'.$cliente->numero.'",
				"zipcode": "'.$cliente->cep.'"
			}
			},
			"shipping": {
			"name": "'.$cliente->nome.'",
			"fee": 1000,
			"delivery_date": "'.$data_atual.'",
			"expedited": true,
			"address": {
				"country": "br",
				"state": "'.$cliente->uf.'",
				"city": "'.$cliente->cidade.'",
				"neighborhood": "'.$cliente->bairro.'",
				"street": "'.$cliente->endereco.'",
				"street_number": "'.$cliente->numero.'",
				"zipcode": "'.$cliente->cep.'"
			}
			},
			"items": [
			{
				"id": "'.$orcamentos->id_orcamento.'",
				"title": "Pagamento de sessão",
				"unit_price": '.$total.',
				"quantity": 1,
				"tangible": true
			}
			],
			"split_rules":[
				{
					"recipient_id": "'.$gestorID.'",
					"amount": '.$total_marketplace.',
					"charge_processing_fee": false
				},
				{
					"recipient_id": "'.$profissional->recipient_id.'",
					"amount": '.$total_prestador.',
					"charge_processing_fee": true
				}

			]
		}';

		// echo $dados; exit;

		$curl = curl_init();

		curl_setopt_array($curl, array(
			CURLOPT_URL => 'https://api.pagar.me/1/transactions',
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_ENCODING => '',
			CURLOPT_MAXREDIRS => 10,
			CURLOPT_TIMEOUT => 0,
			CURLOPT_FOLLOWLOCATION => true,
			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
			CURLOPT_CUSTOMREQUEST => 'POST',
			CURLOPT_POSTFIELDS => $dados,
			CURLOPT_HTTPHEADER => array(
				'Content-Type: application/json'
			),
		));

		$response = curl_exec($curl);

		// echo $response; exit;

		curl_close($curl);

		$respostaPedido = @json_decode($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant