{"__v":47,"_id":"576030379b1a9a220067ca3c","category":{"__v":0,"_id":"57602fe5b82256240055c657","project":"575aeffae12cf20e002f306c","version":"575aeffae12cf20e002f306f","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"},"parentDoc":null,"project":"575aeffae12cf20e002f306c","user":"57601a13af3e090e00108059","version":{"__v":30,"_id":"575aeffae12cf20e002f306f","project":"575aeffae12cf20e002f306c","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:31.843Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"O envio de um endereço de cobrança do cliente é sempre obrigatório para pagamento via cartão de crédito, já o endereço de entrega é opcional.\n\nQualquer endereço possui a seguinte estrutura:\n\n### Atributos de Envio\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"street\",\n    \"0-1\": \"Nome da rua\",\n    \"0-2\": \"Sim\",\n    \"h-0\": \"Atributos\",\n    \"h-1\": \"Descrição\",\n    \"h-2\": \"Obrigatório\",\n    \"1-0\": \"number\",\n    \"2-0\": \"neighborhood\",\n    \"3-0\": \"complement\",\n    \"4-0\": \"city\",\n    \"6-0\": \"zipcode\",\n    \"5-0\": \"state\",\n    \"1-1\": \"Número\",\n    \"2-1\": \"Bairro\",\n    \"3-1\": \"Complemento\",\n    \"4-1\": \"Cidade\",\n    \"5-1\": \"Estado (2 caracteres)\",\n    \"6-1\": \"CEP, sem pontos ou hífen\",\n    \"1-2\": \"Sim\",\n    \"2-2\": \"Sim\",\n    \"3-2\": \"Não\",\n    \"4-2\": \"Sim\",\n    \"5-2\": \"Sim\",\n    \"6-2\": \"Sim\",\n    \"h-3\": \"Tipo\",\n    \"0-3\": \"String\",\n    \"1-3\": \"String/Integer\",\n    \"2-3\": \"String\",\n    \"3-3\": \"String/null\",\n    \"4-3\": \"String\",\n    \"5-3\": \"String\",\n    \"6-3\": \"String\"\n  },\n  \"cols\": 4,\n  \"rows\": 7\n}\n[/block]\n\n\n## 1. Setando endereço de cobrança (exemplo de utilização):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n \\nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado ao Composer\\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$paymentToken = 'payment_token'; // payment_token obtido na 1ª etapa (através do Javascript único por conta Gerencianet)\\n \\n// $charge_id refere-se ao ID da transação gerada anteriormente\\n$params = [\\n  'id' => $charge_id\\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];\\n \\n$billingAddress = [\\n  'street' => 'Street 3',\\n  'number' => 10,\\n  'neighborhood' => 'Bauxita',\\n  'zipcode' => '35400000',\\n  'city' => 'Ouro Preto',\\n  'state' => 'MG',\\n];\\n \\n$creditCard = [\\n  'installments' => 1, // número de parcelas em que o pagamento deve ser dividido\\n  'billing_address' => $billingAddress,\\n  'payment_token' => $paymentToken,\\n  'customer' => $customer\\n];\\n \\n$body = [\\n  'payment' => $payment\\n];\\n \\n$payment = [\\n  'credit_card' => $creditCard\\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\"\n    },\n    {\n      \"code\": \"'use strict';\\n \\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 params = {\\n  id: 1000\\n}\\n \\nvar body = {\\n  payment: {\\n    credit_card: {\\n      installments: 1,\\n      payment_token: '6426f3abd8688639c6772963669bbb8e0eb3c319',\\n      billing_address: {\\n        street: 'Street 3',\\n        number: 10,\\n        neighborhood: 'Bauxita',\\n        zipcode: '35400000',\\n        city: 'Ouro Preto',\\n        state: 'MG'\\n      },\\n      customer: {\\n        name: 'Gorbadoc Oldbuck',\\n        email: 'oldbuck:::at:::gerencianet.com.br',\\n        cpf: '94271564656',\\n        birth: '1977-01-15',\\n        phone_number: '5144916523'\\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\",\n      \"name\": \"NodeJS\"\n    },\n    {\n      \"code\": \"require \\\"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    credit_card: {\\n      installments: 1,\\n      payment_token: \\\"5739b06925244dd1ab8e0afa62389d5fb4ea2945\\\",\\n      billing_address: {\\n        street: \\\"Av. JK\\\",\\n        number: 909,\\n        neighborhood: \\\"Bauxita\\\",\\n        zipcode: \\\"35400000\\\",\\n        city: \\\"Ouro Preto\\\",\\n        state: \\\"MG\\\"\\n      },\\n      customer: {\\n        name: \\\"Gorbadoc Oldbuck\\\",\\n        email: \\\"oldbuck@gerencianet.com.br\\\",\\n        cpf: \\\"94271564656\\\",\\n        birth: \\\"1977-01-15\\\",\\n        phone_number: \\\"5144916523\\\"\\n      }\\n    }\\n  }\\n}\\n \\ngerencianet = Gerencianet.new(options)\\nputs gerencianet.pay_charge(params: params, body: body)\",\n      \"language\": \"ruby\",\n      \"name\": \"Ruby\"\n    },\n    {\n      \"code\": \"from 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        'credit_card': {\\n            'installments': 1,\\n            'payment_token': \\\"6426f3abd8688639c6772963669bbb8e0eb3c319\\\",\\n            'billing_address': {\\n                'street': \\\"Av. JK\\\",\\n                'number': 909,\\n                'neighborhood': \\\"Bauxita\\\",\\n                'zipcode': \\\"35400000\\\",\\n                'city': \\\"Ouro Preto\\\",\\n                'state': \\\"MG\\\"\\n            },\\n            'customer': {\\n                'name': \\\"Gorbadoc Oldbuck\\\",\\n                'email': \\\"oldbuck@gerencianet.com.br\\\",\\n                'cpf': \\\"94271564656\\\",\\n                'birth': \\\"1977-01-15\\\",\\n                'phone_number': \\\"5144916523\\\"\\n            }\\n        }\\n    }\\n}\\n \\ngn.pay_charge(params=params, body=payment)\\n\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"dynamic endpoints = new Endpoints(\\\"client_id\\\", \\\"client_secret\\\", true);\\n \\nvar param = new {\\n    id = 1000\\n};\\n \\nvar body = new {\\n    payment = new {\\n        credit_card = new {\\n            installments = 1,\\n            payment_token = \\\"\\\", // see credit card flow to see how to get this\\n            billing_address = new {\\n                street = \\\"Av. JK\\\",\\n                number = 909,\\n                neighborhood = \\\"Bauxita\\\",\\n                zipcode = \\\"35400000\\\",\\n                city = \\\"Ouro Preto\\\",\\n                state = \\\"MG\\\"\\n            },\\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            }\\n        }\\n    }\\n};\\n \\nvar response = endpoints.PayCharge(param, 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 PayChargeWithCard(Id, Token: String): String;\\n\\nimplementation\\nuses uGerenciaClient, uGerenciaNetClientUtilities;\\n{... your code ... }\\n\\nfunction PayChargeWithCard(Id, Token: String): String;\\nvar\\n    Body: String;\\n    PaymentParams: String;\\n\\nbegin\\n  Body :=\\n  '{'+\\n    '\\\"payment\\\": {'+\\n      '\\\"credit_card\\\": {'+\\n        '\\\"customer\\\": {'+\\n          '\\\"name\\\": \\\"Gorbadoc Oldbuck\\\",'+\\n          '\\\"cpf\\\": \\\"04267484171\\\",'+\\n          '\\\"phone_number\\\": \\\"5144916523\\\",'+\\n          '\\\"email\\\": \\\"oldbuck@gerencianet.com.br\\\",'+\\n          '\\\"birth\\\": \\\"1977-01-15\\\"'+\\n        '},'+\\n        '\\\"installments\\\": 1,'+\\n        '\\\"payment_token\\\": \\\"'+Token+'\\\",'+\\n        '\\\"billing_address\\\": {'+\\n          '\\\"street\\\": \\\"Av. JK\\\",'+\\n          '\\\"number\\\": \\\"909\\\",'+\\n          '\\\"neighborhood\\\": \\\"Bauxita\\\",'+\\n          '\\\"zipcode\\\": \\\"35400000\\\",'+\\n          '\\\"city\\\": \\\"Ouro Preto\\\",'+\\n          '\\\"state\\\": \\\"MG\\\"'+\\n        '}'+\\n      '}'+\\n    '}'+\\n  '}';\\n\\n  EnableService( 'GerenciaNet.dll' ); \\n  ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \\n  GerenciaNetAuthorize();\\n  \\n  PaymentParams := CreateRequestParams( [ 'id='+Id ] ).Text;\\n  Result := ExecuteGerenciaNetRequest( 'payCharge',PaymentParams,'',Body );\\nend;\",\n      \"language\": \"json\",\n      \"name\": \"Delphi\"\n    }\n  ]\n}\n[/block]\n<br />\n## 2. Setando endereço de entrega (exemplo de utilização):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n \\nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado ao Composer\\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$customerAddress = [\\n  'street' => 'Av. JK',\\n  'number' => 909,\\n  'neighborhood' => 'Bauxita',\\n  'zipcode' => '35400000',\\n  'city' => 'Ouro Preto',\\n  'state' => 'MG',\\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  'address' => $customerAddress\\n];\\n \\n$banking_billet = [\\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\",\n      \"name\": \"PHP\"\n    },\n    {\n      \"code\": \"'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 params = {\\n  id: 1000\\n}\\n \\nvar tomorrow = moment()\\n  .add(1, 'days')\\n  .format('YYYY-MM-DD');\\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        address: {\\n          street: 'Av. JK',\\n          number: 909,\\n          neighborhood: 'Bauxita',\\n          zipcode: '35400000',\\n          city: 'Ouro Preto',\\n          state: 'MG'\\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        address: {\\n          street: \\\"Av. JK\\\",\\n          number: 909,\\n          neighborhood: \\\"Bauxita\\\",\\n          zipcode: \\\"35400000\\\",\\n          city: \\\"Ouro Preto\\\",\\n          state: \\\"MG\\\"\\n        }\\n      }\\n    }\\n  }\\n}\\n \\ngerencianet = Gerencianet.new(options)\\nputs gerencianet.pay_charge(params: params, body: body)\\n\",\n      \"language\": \"ruby\",\n      \"name\": \"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': tomorrow,\\n        'customer': {\\n            'name': \\\"Gorbadoc Oldbuck\\\",\\n            'cpf': \\\"94271564656\\\",\\n            'phone_number': \\\"5144916523\\\",\\n            'billing_address': {\\n                'street': \\\"Av. JK\\\",\\n                'number': 909,\\n                'neighborhood': \\\"Bauxita\\\",\\n                'zipcode': \\\"35400000\\\",\\n                'city': \\\"Ouro Preto\\\",\\n                'state': \\\"MG\\\"\\n            }\\n        }\\n    }\\n  }\\n}\\n \\ngn.pay_charge(params=params, body=payment)\\n\",\n      \"language\": \"python\",\n      \"name\": \"Python\"\n    },\n    {\n      \"code\": \"\\ndynamic endpoints = new Endpoints(\\\"client_id\\\", \\\"client_secret\\\", true);\\n \\nvar params = {\\n    id = 1000\\n};\\n \\nvar body = new {\\n    payment = new {\\n        banking_billet = new {\\n            expire_at = \\\"2016-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                address = new {\\n                    street = \\\"Av. JK\\\",\\n                    number = 909,\\n                    neighborhood = \\\"Bauxita\\\",\\n                    zipcode = \\\"35400000\\\",\\n                    city = \\\"Ouro Preto\\\",\\n                    state = \\\"MG\\\"\\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 PayChargeWithBillet(Id: String): String;\\n\\nimplementation\\nuses uGerenciaClient, uGerenciaNetClientUtilities;\\n{... your code ... }\\n\\nfunction PayChargeWithBillet(Id: String): String;\\nvar \\n    Body : String;\\n    PaymentParams: String;\\n    \\nconst \\n    BodyText = \\n    '{'+\\n      '\\\"payment\\\": {'+\\n        '\\\"banking_billet\\\": {'+\\n          '\\\"customer\\\": {'+\\n            '\\\"email\\\": \\\"teste@gmail.com\\\",'+\\n            '\\\"phone_number\\\": \\\"5144916523\\\",'+\\n            '\\\"birth\\\": \\\"1977-07-17\\\",'+\\n            '\\\"address\\\": {'+\\n              '\\\"street\\\": \\\"Av. JK\\\",'+\\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\\\": \\\"04267484171\\\"'+\\n          '},'+\\n          '\\\"message\\\": \\\"Test\\\",'+\\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]","excerpt":"Você está em: *\"Outros Recursos da API > Definir Endereços\"*","slug":"definir-enderecos","type":"basic","title":"Definir Endereços"}

Definir Endereços

Você está em: *"Outros Recursos da API > Definir Endereços"*

O envio de um endereço de cobrança do cliente é sempre obrigatório para pagamento via cartão de crédito, já o endereço de entrega é opcional. Qualquer endereço possui a seguinte estrutura: ### Atributos de Envio [block:parameters] { "data": { "0-0": "street", "0-1": "Nome da rua", "0-2": "Sim", "h-0": "Atributos", "h-1": "Descrição", "h-2": "Obrigatório", "1-0": "number", "2-0": "neighborhood", "3-0": "complement", "4-0": "city", "6-0": "zipcode", "5-0": "state", "1-1": "Número", "2-1": "Bairro", "3-1": "Complemento", "4-1": "Cidade", "5-1": "Estado (2 caracteres)", "6-1": "CEP, sem pontos ou hífen", "1-2": "Sim", "2-2": "Sim", "3-2": "Não", "4-2": "Sim", "5-2": "Sim", "6-2": "Sim", "h-3": "Tipo", "0-3": "String", "1-3": "String/Integer", "2-3": "String", "3-3": "String/null", "4-3": "String", "5-3": "String", "6-3": "String" }, "cols": 4, "rows": 7 } [/block] ## 1. Setando endereço de cobrança (exemplo de utilização): [block:code] { "codes": [ { "code": "<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado ao Composer\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$paymentToken = 'payment_token'; // payment_token obtido na 1ª etapa (através do Javascript único por conta Gerencianet)\n \n// $charge_id refere-se ao ID da transação gerada anteriormente\n$params = [\n 'id' => $charge_id\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];\n \n$billingAddress = [\n 'street' => 'Street 3',\n 'number' => 10,\n 'neighborhood' => 'Bauxita',\n 'zipcode' => '35400000',\n 'city' => 'Ouro Preto',\n 'state' => 'MG',\n];\n \n$creditCard = [\n 'installments' => 1, // número de parcelas em que o pagamento deve ser dividido\n 'billing_address' => $billingAddress,\n 'payment_token' => $paymentToken,\n 'customer' => $customer\n];\n \n$body = [\n 'payment' => $payment\n];\n \n$payment = [\n 'credit_card' => $creditCard\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}", "language": "php" }, { "code": "'use strict';\n \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 params = {\n id: 1000\n}\n \nvar body = {\n payment: {\n credit_card: {\n installments: 1,\n payment_token: '6426f3abd8688639c6772963669bbb8e0eb3c319',\n billing_address: {\n street: 'Street 3',\n number: 10,\n neighborhood: 'Bauxita',\n zipcode: '35400000',\n city: 'Ouro Preto',\n state: 'MG'\n },\n customer: {\n name: 'Gorbadoc Oldbuck',\n email: 'oldbuck@gerencianet.com.br',\n cpf: '94271564656',\n birth: '1977-01-15',\n phone_number: '5144916523'\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();", "language": "javascript", "name": "NodeJS" }, { "code": "require \"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 credit_card: {\n installments: 1,\n payment_token: \"5739b06925244dd1ab8e0afa62389d5fb4ea2945\",\n billing_address: {\n street: \"Av. JK\",\n number: 909,\n neighborhood: \"Bauxita\",\n zipcode: \"35400000\",\n city: \"Ouro Preto\",\n state: \"MG\"\n },\n customer: {\n name: \"Gorbadoc Oldbuck\",\n email: \"oldbuck@gerencianet.com.br\",\n cpf: \"94271564656\",\n birth: \"1977-01-15\",\n phone_number: \"5144916523\"\n }\n }\n }\n}\n \ngerencianet = Gerencianet.new(options)\nputs gerencianet.pay_charge(params: params, body: body)", "language": "ruby", "name": "Ruby" }, { "code": "from 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 'credit_card': {\n 'installments': 1,\n 'payment_token': \"6426f3abd8688639c6772963669bbb8e0eb3c319\",\n 'billing_address': {\n 'street': \"Av. JK\",\n 'number': 909,\n 'neighborhood': \"Bauxita\",\n 'zipcode': \"35400000\",\n 'city': \"Ouro Preto\",\n 'state': \"MG\"\n },\n 'customer': {\n 'name': \"Gorbadoc Oldbuck\",\n 'email': \"oldbuck@gerencianet.com.br\",\n 'cpf': \"94271564656\",\n 'birth': \"1977-01-15\",\n 'phone_number': \"5144916523\"\n }\n }\n }\n}\n \ngn.pay_charge(params=params, body=payment)\n", "language": "python" }, { "code": "dynamic endpoints = new Endpoints(\"client_id\", \"client_secret\", true);\n \nvar param = new {\n id = 1000\n};\n \nvar body = new {\n payment = new {\n credit_card = new {\n installments = 1,\n payment_token = \"\", // see credit card flow to see how to get this\n billing_address = new {\n street = \"Av. JK\",\n number = 909,\n neighborhood = \"Bauxita\",\n zipcode = \"35400000\",\n city = \"Ouro Preto\",\n state = \"MG\"\n },\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 }\n }\n }\n};\n \nvar response = endpoints.PayCharge(param, 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 PayChargeWithCard(Id, Token: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction PayChargeWithCard(Id, Token: String): String;\nvar\n Body: String;\n PaymentParams: String;\n\nbegin\n Body :=\n '{'+\n '\"payment\": {'+\n '\"credit_card\": {'+\n '\"customer\": {'+\n '\"name\": \"Gorbadoc Oldbuck\",'+\n '\"cpf\": \"04267484171\",'+\n '\"phone_number\": \"5144916523\",'+\n '\"email\": \"oldbuck@gerencianet.com.br\",'+\n '\"birth\": \"1977-01-15\"'+\n '},'+\n '\"installments\": 1,'+\n '\"payment_token\": \"'+Token+'\",'+\n '\"billing_address\": {'+\n '\"street\": \"Av. JK\",'+\n '\"number\": \"909\",'+\n '\"neighborhood\": \"Bauxita\",'+\n '\"zipcode\": \"35400000\",'+\n '\"city\": \"Ouro Preto\",'+\n '\"state\": \"MG\"'+\n '}'+\n '}'+\n '}'+\n '}';\n\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n \n PaymentParams := CreateRequestParams( [ 'id='+Id ] ).Text;\n Result := ExecuteGerenciaNetRequest( 'payCharge',PaymentParams,'',Body );\nend;", "language": "json", "name": "Delphi" } ] } [/block] <br /> ## 2. Setando endereço de entrega (exemplo de utilização): [block:code] { "codes": [ { "code": "<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado ao Composer\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$customerAddress = [\n 'street' => 'Av. JK',\n 'number' => 909,\n 'neighborhood' => 'Bauxita',\n 'zipcode' => '35400000',\n 'city' => 'Ouro Preto',\n 'state' => 'MG',\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 'address' => $customerAddress\n];\n \n$banking_billet = [\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}", "language": "php", "name": "PHP" }, { "code": "'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 params = {\n id: 1000\n}\n \nvar tomorrow = moment()\n .add(1, 'days')\n .format('YYYY-MM-DD');\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 address: {\n street: 'Av. JK',\n number: 909,\n neighborhood: 'Bauxita',\n zipcode: '35400000',\n city: 'Ouro Preto',\n state: 'MG'\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 address: {\n street: \"Av. JK\",\n number: 909,\n neighborhood: \"Bauxita\",\n zipcode: \"35400000\",\n city: \"Ouro Preto\",\n state: \"MG\"\n }\n }\n }\n }\n}\n \ngerencianet = Gerencianet.new(options)\nputs gerencianet.pay_charge(params: params, body: body)\n", "language": "ruby", "name": "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': tomorrow,\n 'customer': {\n 'name': \"Gorbadoc Oldbuck\",\n 'cpf': \"94271564656\",\n 'phone_number': \"5144916523\",\n 'billing_address': {\n 'street': \"Av. JK\",\n 'number': 909,\n 'neighborhood': \"Bauxita\",\n 'zipcode': \"35400000\",\n 'city': \"Ouro Preto\",\n 'state': \"MG\"\n }\n }\n }\n }\n}\n \ngn.pay_charge(params=params, body=payment)\n", "language": "python", "name": "Python" }, { "code": "\ndynamic endpoints = new Endpoints(\"client_id\", \"client_secret\", true);\n \nvar params = {\n id = 1000\n};\n \nvar body = new {\n payment = new {\n banking_billet = new {\n expire_at = \"2016-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 address = new {\n street = \"Av. JK\",\n number = 909,\n neighborhood = \"Bauxita\",\n zipcode = \"35400000\",\n city = \"Ouro Preto\",\n state = \"MG\"\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 PayChargeWithBillet(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction PayChargeWithBillet(Id: String): String;\nvar \n Body : String;\n PaymentParams: String;\n \nconst \n BodyText = \n '{'+\n '\"payment\": {'+\n '\"banking_billet\": {'+\n '\"customer\": {'+\n '\"email\": \"teste@gmail.com\",'+\n '\"phone_number\": \"5144916523\",'+\n '\"birth\": \"1977-07-17\",'+\n '\"address\": {'+\n '\"street\": \"Av. JK\",'+\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\": \"04267484171\"'+\n '},'+\n '\"message\": \"Test\",'+\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]