{"_id":"5760304ab82256240055c658","category":{"_id":"57602fe5b82256240055c657","version":"575aeffae12cf20e002f306f","__v":0,"project":"575aeffae12cf20e002f306c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-14T16:25:09.214Z","from_sync":false,"order":14,"slug":"opções-avançadas","title":"Outros Recursos da API"},"user":"57601a13af3e090e00108059","__v":27,"parentDoc":null,"project":"575aeffae12cf20e002f306c","version":{"_id":"575aeffae12cf20e002f306f","project":"575aeffae12cf20e002f306c","__v":30,"createdAt":"2016-06-10T16:51:06.080Z","releaseDate":"2016-06-10T16:51:06.080Z","categories":["575aeffae12cf20e002f3070","575af039a083950e004487f7","575af5c7ba4ed70e000ca288","57602fe5b82256240055c657","57602ff6c811102000cef302","576030909b1a9a220067ca40","57604518b82256240055c722","5761a63d207db7170022fc14","5761b9a2b65324200072d79e","576832939f0bf4190014ffdf","576832c09f0bf4190014ffe1","576832cba151c10e004316f0","576832d5bb15f40e00a288ec","576832e107b1f30e0039c645","577680bf3cee3a0e00a000bc","577ff3b1ff48990e000c6806","5783f78c5cbce30e0074e2b7","5783f86292edb92200e6101c","5783f86dbfbba719003f0d8b","5783f8755cbce30e0074e2b8","5783f8b65cbce30e0074e2b9","5783f8bf5cbce30e0074e2ba","5783f8d8ce802f0e0087d574","578529f887c9280e0090394b","57852aeb87c9280e0090394d","57866e72b2f4060e00fa39ca","57ab6d5c39c2fd1900191879","57f39451ab0ee12000bef915","582499a0d90fa027009b259e","58c29df1258e5a1900b60478"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"2016","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-14T16:26:50.130Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":6,"body":"O cliente associado à transação pode ser uma **Pessoa Jurídica**. Nesse caso, devem ser informados a Razão Social e o CNPJ da empresa.\n\nPara **Pessoa Jurídica** não serão obrigatórios o envio de nome e CPF, apenas os demais dados do cliente. Porém, se quiser enviar nome e CPF, eles serão úteis para identificar sobre a pessoa física que está concretizando o pagamento em nome da empresa. Caso contrário, você pode omitir o atributo <code>cpf</code> no *array* <code>customer</code> e prosseguir fornecendo o <code>cnpj</code>.\n\nO restante desta página apresenta os procedimentos detalhados, mas você precisa instalar uma de nossas bibliotecas em seu servidor para executar os códigos de exemplo. [Certifique-se que a SDK da Gerencianet foi instalada](https://dev.gerencianet.com.br/docs#section-bibliotecas).\n\nO exemplo abaixo mostra como isto pode ser feito, utilizando as SDK's disponíveis:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n \\nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\\n \\nuse Gerencianet\\\\Exception\\\\GerencianetException;\\nuse Gerencianet\\\\Gerencianet;\\n \\n$clientId = 'your_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\\n$clientSecret = 'your_client_secret'; // insira seu Client_Secret, conforme o ambiente (Des ou Prod)\\n \\n$options = [\\n  'client_id' => $clientId,\\n  'client_secret' => $clientSecret,\\n  'sandbox' => true // altere conforme o ambiente (true = desenvolvimento e false = producao)\\n];\\n \\n// $charge_id refere-se ao ID da transação gerada anteriormente\\n$params = [\\n  'id' => $charge_id\\n];\\n \\n$juridical_data = [\\n  'corporate_name' => 'Company Name', // nome da razão social\\n  'cnpj' => '99794567000144' // CNPJ da empresa, com 14 caracteres\\n];\\n \\n$customer = [\\n  'name' => 'Gorbadoc Oldbuck', // nome do cliente\\n  'cpf' => '94271564656', // cpf do cliente\\n  'phone_number' => '5144916523', // telefone do cliente\\n  'juridical_person' => $juridical_data\\n];\\n \\n$banking_billet = [\\n  'expire_at' => '2017-12-20',\\n  'customer' => $customer\\n];\\n \\n$payment = [\\n  'banking_billet' => $banking_billet // forma de pagamento (banking_billet = boleto)\\n];\\n \\n$body = [\\n  'payment' => $payment\\n];\\n \\ntry {\\n    $api = new Gerencianet($options);\\n    $charge = $api->payCharge($params, $body);\\n \\n    print_r($charge);\\n} catch (GerencianetException $e) {\\n    print_r($e->code);\\n    print_r($e->error);\\n    print_r($e->errorDescription);\\n} catch (Exception $e) {\\n    print_r($e->getMessage());\\n}\\n\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"\\n'use strict';\\n \\nvar moment = require('moment');\\nvar Gerencianet = require('gn-api-sdk-node');\\n \\nvar clientId = 'your_client_id';\\nvar clientSecret = 'your_client_secret';\\n \\nvar options = {\\n  client_id: clientId,\\n  client_secret: clientSecret,\\n  sandbox: true\\n}\\n \\nvar tomorrow = moment()\\n  .add(1, 'days')\\n  .format('YYYY-MM-DD');\\n \\nvar params = {\\n  id: 1000\\n}\\n \\nvar body = {\\n  payment: {\\n    banking_billet: {\\n      expire_at: tomorrow,\\n      customer: {\\n        name: 'Gorbadoc Oldbuck',\\n        cpf: '94271564656',\\n        phone_number: '5144916523',\\n        juridical_person: {\\n          corporate_name: 'Company Name',\\n          cnpj: '99794567000144'\\n        }\\n      }\\n    }\\n  }\\n}\\n \\nvar gerencianet = new Gerencianet(options);\\n \\ngerencianet\\n  .payCharge(params, body)\\n  .then(console.log)\\n  .catch(console.log)\\n  .done();\\n\",\n      \"language\": \"javascript\",\n      \"name\": \"NodeJS\"\n    },\n    {\n      \"code\": \"\\nrequire \\\"gerencianet\\\"\\n \\noptions = {\\n  client_id: \\\"client_id\\\",\\n  client_secret: \\\"client_secret\\\",\\n  sandbox: true\\n}\\n \\nparams = {\\n  id: 1000\\n}\\n \\nbody = {\\n  payment: {\\n    banking_billet: {\\n      expire_at: tomorrow,\\n      customer: {\\n        name: 'Gorbadoc Oldbuck',\\n        cpf: '94271564656',\\n        phone_number: '5144916523',\\n        juridical_person: {\\n          corporate_name: 'Company Name',\\n          cnpj: '99794567000144'\\n        }\\n      }\\n    }\\n  }\\n}\\n \\ngerencianet = Gerencianet.new(options)\\ngerencianet.pay_charge(params: params, body: body)\\n\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"\\nfrom gerencianet import Gerencianet\\n \\noptions = {\\n    'client_id': 'client_id',\\n    'client_secret': 'client_secret',\\n    'sandbox': True\\n}\\n \\ngn = Gerencianet(options)\\n \\nparams = {\\n  'id': 1000\\n}\\n \\nbody = {\\n    'payment': {\\n    'banking_billet': {\\n        'expire_at': '2020-12-12',\\n        'customer': {\\n            'name': 'Gorbadoc Oldbuck',\\n            'cpf': '94271564656',\\n            'phone_number': '5144916523',\\n            'juridical_person': {\\n                'corporate_name': 'Company Name',\\n                'cnpj': '99794567000144'\\n            }\\n        }\\n    }\\n  }\\n}\\n \\ngn.pay_charge(params=params, body=body)\\n\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"\\ndynamic endpoints = new Endpoints(\\\"client_id\\\", \\\"client_secret\\\", true);\\n \\nvar params = new {\\n\\tid = 1000\\n};\\n \\n            var body = new {\\n                payment = new {\\n                    banking_billet = new {\\n                        expire_at = \\\"2017-12-12\\\",\\n                        customer = new {\\n                            name = \\\"Gorbadoc Oldbuck\\\",\\n                            email = \\\"oldbuck:::at:::gerencianet.com.br\\\",\\n                            cpf = \\\"94271564656\\\",\\n                            birth = \\\"1977-01-15\\\",\\n                            phone_number = \\\"5144916523\\\",\\n                            juridical_person = new {\\n                                corporate_name = \\\"Company Name\\\",\\n                                cnpj = \\\"99794567000144\\\"\\n                            }\\n                        }\\n                    }\\n                }\\n            };\\n \\nvar response = endpoints.PayCharge(params, body);\\n\",\n      \"language\": \"asp\",\n      \"name\": \".NET\"\n    },\n    {\n      \"code\": \"// Para detalhes, acesse o documento específico em nosso Github:\\n// https://github.com/gerencianet/gn-api-sdk-java\",\n      \"language\": \"java\"\n    },\n    {\n      \"code\": \"interface\\nfunction PayChargeWithBilletAsPJ(Id: String): String;\\n\\nimplementation\\nuses uGerenciaClient, uGerenciaNetClientUtilities;\\n{... your code ... }\\n\\nfunction PayChargeWithBilletAsPJ(Id: String): String;\\nvar \\n    Body : String;\\n    PaymentParams: String;    \\nconst \\n    BodyText = \\n'{'+\\n      '\\\"payment\\\": {'+\\n        '\\\"banking_billet\\\": {'+\\n          '\\\"customer\\\": {'+\\n            '\\\"email\\\": \\\"email_do_cliente@servidor.com.br\\\",'+\\n            '\\\"phone_number\\\": \\\"5144916523\\\",'+\\n            '\\\"birth\\\": \\\"1977-07-17\\\",'+\\n            '\\\"address\\\": {'+\\n              '\\\"street\\\": \\\"Avenida Juscelino Kubitschek\\\",'+\\n              '\\\"number\\\": 909,'+\\n              '\\\"neighborhood\\\": \\\"Bauxita\\\",'+\\n              '\\\"complement\\\": \\\"\\\",'+\\n              '\\\"city\\\": \\\"Ouro Preto\\\",'+\\n              '\\\"state\\\": \\\"MG\\\",'+\\n              '\\\"zipcode\\\": \\\"35400000\\\"'+\\n            '},'+\\n            '\\\"name\\\": \\\"Gorbadoc Oldbuck\\\",'+\\n            '\\\"cpf\\\": \\\"94271564656\\\",'+\\n            '\\\"juridical_person\\\": {'+\\n              '\\\"corporate_name\\\": \\\"Nome da Empresa\\\",'+\\n              '\\\"cnpj\\\": \\\"99794567000144\\\"'+\\n            '}'+\\n          '},'+\\n          '\\\"configurations\\\": {' +\\n            '\\\"fine\\\": 200,' +\\n            '\\\"interest\\\": 33' +\\n          '},'+\\n          '\\\"message\\\": \\\"Este é um espaço de até 80 caracteres para informar algo a seu cliente\\\",'+\\n          '\\\"expire_at\\\": \\\"2019-02-21\\\"'+\\n        '}'+\\n      '}'+\\n    '}';\\n\\nbegin\\n  EnableService( 'GerenciaNet.dll' ); \\n  ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \\n  GerenciaNetAuthorize();\\n\\n  PaymentParams := CreateRequestParams( [ 'id='+Id ] ).Text; // Passa o id da transação\\n  Body := BodyText;\\n\\n  Result := ExecuteGerenciaNetRequest( 'payCharge',PaymentParams,'',Body );\\nend;\",\n      \"language\": \"json\",\n      \"name\": \"Delphi\"\n    }\n  ]\n}\n[/block]\n<br>\n\n## a) Estrutura hierárquica dos atributos do Schema que podem ser utilizados:\n\n<pre>\"juridical_person\"\n    \"corporate_name\"\n    \"cnpj\"</pre>\n\n<br>\n\n## b) Atributos de envio (dados de pessoa jurídica):\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Atributo\",\n    \"h-1\": \"Descrição\",\n    \"h-2\": \"Obrigatório\",\n    \"h-3\": \"Tipo\",\n    \"0-0\": \"<code>corporate_name</code>\",\n    \"0-1\": \"Nome da razão social.\",\n    \"0-2\": \"Sim\",\n    \"0-3\": \"String\",\n    \"1-0\": \"<code>cnpj</code>\",\n    \"1-1\": \"CNPJ da empresa, com 14 caracteres.\",\n    \"1-3\": \"String\",\n    \"1-2\": \"Sim\"\n  },\n  \"cols\": 4,\n  \"rows\": 2\n}\n[/block]","excerpt":"Você está em: *\"Outros Recursos da API > Pagar com Pessoa Jurídica\"*","slug":"pagar-com-pessoa-juridica","type":"basic","title":"Pagar com Pessoa Jurídica"}

Pagar com Pessoa Jurídica

Você está em: *"Outros Recursos da API > Pagar com Pessoa Jurídica"*

O cliente associado à transação pode ser uma **Pessoa Jurídica**. Nesse caso, devem ser informados a Razão Social e o CNPJ da empresa. Para **Pessoa Jurídica** não serão obrigatórios o envio de nome e CPF, apenas os demais dados do cliente. Porém, se quiser enviar nome e CPF, eles serão úteis para identificar sobre a pessoa física que está concretizando o pagamento em nome da empresa. Caso contrário, você pode omitir o atributo <code>cpf</code> no *array* <code>customer</code> e prosseguir fornecendo o <code>cnpj</code>. O restante desta página apresenta os procedimentos detalhados, mas você precisa instalar uma de nossas bibliotecas em seu servidor para executar os códigos de exemplo. [Certifique-se que a SDK da Gerencianet foi instalada](https://dev.gerencianet.com.br/docs#section-bibliotecas). O exemplo abaixo mostra como isto pode ser feito, utilizando as SDK's disponíveis: [block:code] { "codes": [ { "code": "<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'your_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\n$clientSecret = 'your_client_secret'; // insira seu Client_Secret, conforme o ambiente (Des ou Prod)\n \n$options = [\n 'client_id' => $clientId,\n 'client_secret' => $clientSecret,\n 'sandbox' => true // altere conforme o ambiente (true = desenvolvimento e false = producao)\n];\n \n// $charge_id refere-se ao ID da transação gerada anteriormente\n$params = [\n 'id' => $charge_id\n];\n \n$juridical_data = [\n 'corporate_name' => 'Company Name', // nome da razão social\n 'cnpj' => '99794567000144' // CNPJ da empresa, com 14 caracteres\n];\n \n$customer = [\n 'name' => 'Gorbadoc Oldbuck', // nome do cliente\n 'cpf' => '94271564656', // cpf do cliente\n 'phone_number' => '5144916523', // telefone do cliente\n 'juridical_person' => $juridical_data\n];\n \n$banking_billet = [\n 'expire_at' => '2017-12-20',\n 'customer' => $customer\n];\n \n$payment = [\n 'banking_billet' => $banking_billet // forma de pagamento (banking_billet = boleto)\n];\n \n$body = [\n 'payment' => $payment\n];\n \ntry {\n $api = new Gerencianet($options);\n $charge = $api->payCharge($params, $body);\n \n print_r($charge);\n} catch (GerencianetException $e) {\n print_r($e->code);\n print_r($e->error);\n print_r($e->errorDescription);\n} catch (Exception $e) {\n print_r($e->getMessage());\n}\n", "language": "php" }, { "code": "\n'use strict';\n \nvar moment = require('moment');\nvar Gerencianet = require('gn-api-sdk-node');\n \nvar clientId = 'your_client_id';\nvar clientSecret = 'your_client_secret';\n \nvar options = {\n client_id: clientId,\n client_secret: clientSecret,\n sandbox: true\n}\n \nvar tomorrow = moment()\n .add(1, 'days')\n .format('YYYY-MM-DD');\n \nvar params = {\n id: 1000\n}\n \nvar body = {\n payment: {\n banking_billet: {\n expire_at: tomorrow,\n customer: {\n name: 'Gorbadoc Oldbuck',\n cpf: '94271564656',\n phone_number: '5144916523',\n juridical_person: {\n corporate_name: 'Company Name',\n cnpj: '99794567000144'\n }\n }\n }\n }\n}\n \nvar gerencianet = new Gerencianet(options);\n \ngerencianet\n .payCharge(params, body)\n .then(console.log)\n .catch(console.log)\n .done();\n", "language": "javascript", "name": "NodeJS" }, { "code": "\nrequire \"gerencianet\"\n \noptions = {\n client_id: \"client_id\",\n client_secret: \"client_secret\",\n sandbox: true\n}\n \nparams = {\n id: 1000\n}\n \nbody = {\n payment: {\n banking_billet: {\n expire_at: tomorrow,\n customer: {\n name: 'Gorbadoc Oldbuck',\n cpf: '94271564656',\n phone_number: '5144916523',\n juridical_person: {\n corporate_name: 'Company Name',\n cnpj: '99794567000144'\n }\n }\n }\n }\n}\n \ngerencianet = Gerencianet.new(options)\ngerencianet.pay_charge(params: params, body: body)\n", "language": "ruby" }, { "code": "\nfrom gerencianet import Gerencianet\n \noptions = {\n 'client_id': 'client_id',\n 'client_secret': 'client_secret',\n 'sandbox': True\n}\n \ngn = Gerencianet(options)\n \nparams = {\n 'id': 1000\n}\n \nbody = {\n 'payment': {\n 'banking_billet': {\n 'expire_at': '2020-12-12',\n 'customer': {\n 'name': 'Gorbadoc Oldbuck',\n 'cpf': '94271564656',\n 'phone_number': '5144916523',\n 'juridical_person': {\n 'corporate_name': 'Company Name',\n 'cnpj': '99794567000144'\n }\n }\n }\n }\n}\n \ngn.pay_charge(params=params, body=body)\n", "language": "python" }, { "code": "\ndynamic endpoints = new Endpoints(\"client_id\", \"client_secret\", true);\n \nvar params = new {\n\tid = 1000\n};\n \n var body = new {\n payment = new {\n banking_billet = new {\n expire_at = \"2017-12-12\",\n customer = new {\n name = \"Gorbadoc Oldbuck\",\n email = \"oldbuck@gerencianet.com.br\",\n cpf = \"94271564656\",\n birth = \"1977-01-15\",\n phone_number = \"5144916523\",\n juridical_person = new {\n corporate_name = \"Company Name\",\n cnpj = \"99794567000144\"\n }\n }\n }\n }\n };\n \nvar response = endpoints.PayCharge(params, body);\n", "language": "asp", "name": ".NET" }, { "code": "// Para detalhes, acesse o documento específico em nosso Github:\n// https://github.com/gerencianet/gn-api-sdk-java", "language": "java" }, { "code": "interface\nfunction PayChargeWithBilletAsPJ(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction PayChargeWithBilletAsPJ(Id: String): String;\nvar \n Body : String;\n PaymentParams: String; \nconst \n BodyText = \n'{'+\n '\"payment\": {'+\n '\"banking_billet\": {'+\n '\"customer\": {'+\n '\"email\": \"email_do_cliente@servidor.com.br\",'+\n '\"phone_number\": \"5144916523\",'+\n '\"birth\": \"1977-07-17\",'+\n '\"address\": {'+\n '\"street\": \"Avenida Juscelino Kubitschek\",'+\n '\"number\": 909,'+\n '\"neighborhood\": \"Bauxita\",'+\n '\"complement\": \"\",'+\n '\"city\": \"Ouro Preto\",'+\n '\"state\": \"MG\",'+\n '\"zipcode\": \"35400000\"'+\n '},'+\n '\"name\": \"Gorbadoc Oldbuck\",'+\n '\"cpf\": \"94271564656\",'+\n '\"juridical_person\": {'+\n '\"corporate_name\": \"Nome da Empresa\",'+\n '\"cnpj\": \"99794567000144\"'+\n '}'+\n '},'+\n '\"configurations\": {' +\n '\"fine\": 200,' +\n '\"interest\": 33' +\n '},'+\n '\"message\": \"Este é um espaço de até 80 caracteres para informar algo a seu cliente\",'+\n '\"expire_at\": \"2019-02-21\"'+\n '}'+\n '}'+\n '}';\n\nbegin\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n\n PaymentParams := CreateRequestParams( [ 'id='+Id ] ).Text; // Passa o id da transação\n Body := BodyText;\n\n Result := ExecuteGerenciaNetRequest( 'payCharge',PaymentParams,'',Body );\nend;", "language": "json", "name": "Delphi" } ] } [/block] <br> ## a) Estrutura hierárquica dos atributos do Schema que podem ser utilizados: <pre>"juridical_person" "corporate_name" "cnpj"</pre> <br> ## b) Atributos de envio (dados de pessoa jurídica): [block:parameters] { "data": { "h-0": "Atributo", "h-1": "Descrição", "h-2": "Obrigatório", "h-3": "Tipo", "0-0": "<code>corporate_name</code>", "0-1": "Nome da razão social.", "0-2": "Sim", "0-3": "String", "1-0": "<code>cnpj</code>", "1-1": "CNPJ da empresa, com 14 caracteres.", "1-3": "String", "1-2": "Sim" }, "cols": 4, "rows": 2 } [/block]