-
Notifications
You must be signed in to change notification settings - Fork 0
/
481fa7b0.aa46f5dc.js
1 lines (1 loc) · 58.6 KB
/
481fa7b0.aa46f5dc.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[46],{147:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return s})),t.d(n,"metadata",(function(){return l})),t.d(n,"Highlight",(function(){return b})),t.d(n,"rightToc",(function(){return d})),t.d(n,"default",(function(){return p}));var a=t(2),r=t(6),i=(t(0),t(250)),c=t(257),o=t(258),s={id:"EndpointsLink",title:"Outros endpoints",hide_title:!0,sidebar_label:"Other endpoints"},l={id:"LinkdePagamento/EndpointsLink",isDocsHomePage:!1,title:"Outros endpoints",description:"Other endpoints",source:"@site/docs\\LinkdePagamento\\OutrosEndpoints.md",permalink:"/documentation/docs/LinkdePagamento/EndpointsLink",sidebar_label:"Other endpoints",sidebar:"someSidebar",previous:{title:"Criando link de pagamento",permalink:"/documentation/docs/LinkdePagamento/CriandoLink"},next:{title:"Introdu\xe7\xe3o",permalink:"/documentation/docs/Marketplace/Introducao"}},b=function(e){var n=e.children;e.color;return Object(i.b)("span",{style:{borderRadius:"2px",color:"#009615",padding:"0.2rem"}},n)},d=[{value:"1. Change certain parameters/attributes of an existing payment link",id:"1-change-certain-parametersattributes-of-an-existing-payment-link",children:[{value:"a) Hierarchical structure of Schema attributes that can be used:",id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used",children:[]},{value:"b) Attributes that can be used to change certain parameters/attributes of an existing payment link:",id:"b-attributes-that-can-be-used-to-change-certain-parametersattributes-of-an-existing-payment-link",children:[]}]},{value:"2. Cancel certain transaction",id:"2-cancel-certain-transaction",children:[]},{value:"3. Change notification URL (notification_url) and/or transaction custom_id",id:"3-change-notification-url-notification_url-andor-transaction-custom_id",children:[{value:"a) Hierarchical structure of Schema attributes that can be used:",id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used-1",children:[]},{value:"b) Attributes that can be used to update notification URL and/or custom_id:",id:"b-attributes-that-can-be-used-to-update-notification-url-andor-custom_id",children:[]}]},{value:"4. Add information to transaction history",id:"4-add-information-to-transaction-history",children:[{value:"a) Hierarchical structure of Schema attributes that can be used:",id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used-2",children:[]},{value:"b) Attribute that can be used to add messages to the transaction history:",id:"b-attribute-that-can-be-used-to-add-messages-to-the-transaction-history",children:[]}]},{value:"5. Return transaction information",id:"5-return-transaction-information",children:[]}],u={Highlight:b,rightToc:d};function p(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h1",{className:"titulo"},"Other endpoints"),Object(i.b)("div",{className:"subtitulo"},Object(i.b)("p",null,"There are other endpoints (services) available in the API that can be used in payment links:"),Object(i.b)("ol",null,Object(i.b)("li",{parentName:"ol"},Object(i.b)("p",{parentName:"li"},Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"#1-alterar-determinados-par%C3%A2metrosatributos-de-um-link-de-pagamento-existente"}),"Change certain parameters/attributes of an existing payment link"))),Object(i.b)("li",{parentName:"ol"},Object(i.b)("p",{parentName:"li"},Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"#2-cancelar-determinada-transa%C3%A7%C3%A3o"}),"Cancel certain transaction"))),Object(i.b)("li",{parentName:"ol"},Object(i.b)("p",{parentName:"li"},Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"#3-alterar-url-de-notifica%C3%A7%C3%A3o-notification_url-eou-custom_id-de-transa%C3%A7%C3%A3o"}),"Change notification URL (notification_url) and/or transaction custom_id"))),Object(i.b)("li",{parentName:"ol"},Object(i.b)("p",{parentName:"li"},Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"#4-acrescentar-informa%C3%A7%C3%B5es-ao-hist%C3%B3rico-da-transa%C3%A7%C3%A3o"}),"Add information to transaction history"))),Object(i.b)("li",{parentName:"ol"},Object(i.b)("p",{parentName:"li"},Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"#5-retornar-informa%C3%A7%C3%B5es-sobre-transa%C3%A7%C3%A3o"}),"Return transaction information")))),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"Before proceeding, make sure that the Gerencianet SDK has been installed")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"The rest of this page has the detailed procedures, but you need to ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../Introducao.md"}),"install one of our libraries")," on your server to run the sample codes."))),Object(i.b)("br",null),Object(i.b)("h2",{id:"1-change-certain-parametersattributes-of-an-existing-payment-link"},"1. Change certain parameters/attributes of an existing payment link"),Object(i.b)("p",null,"Allows you to update (change) certain parameters and attributes of a payment link created through ",Object(i.b)("code",null,"PUT /v1/charge/:id/link"),", as long as payment confirmation has not occurred."),Object(i.b)("p",null,"Some information that can be updated/changed in a payment link:"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"Update (change) allowed payment method;"),Object(i.b)("li",{parentName:"ul"},"Insertion of discounts (including conditional);"),Object(i.b)("li",{parentName:"ul"},"Changing the information message to the customer;"),Object(i.b)("li",{parentName:"ul"},"Due date of the payment link;"),Object(i.b)("li",{parentName:"ul"},"Request change (or not) of the buyer's delivery address.")),Object(i.b)("p",null,"If you want, you can explore and learn more about this feature ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../AmbienteTestes/PlaygroundTransacoes"}),"using our Playground"),"."),Object(i.b)("p",null,"The example below shows how this can be done, using the SDK's available:"),Object(i.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(i.b)(o.a,{value:"php",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),"<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; \n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'informe_seu_client_id'; \n$clientSecret = 'informe_seu_client_secret'; \n \n$options = [\n 'client_id' => $clientId,\n 'client_secret' => $clientSecret,\n 'sandbox' => true \n];\n \n\n$params = [\n 'id' => $charge_id\n];\n\n$body = [\n 'billet_discount' => 0,\n 'card_discount' => 0,\n 'message' => '',\n 'expire_at' => '2022-12-20',\n 'request_delivery_address' => false,\n 'payment_method' => 'all'\n];\n\ntry {\n $api = new Gerencianet($options);\n $response = $api->updateChargeLink($params, $body);\n print_r($response);\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"))),Object(i.b)(o.a,{value:"python",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"# encoding: utf-8\n\nfrom gerencianet import Gerencianet\nfrom credentials import CREDENTIALS\n\ngn = Gerencianet(CREDENTIALS)\n\nparams = {\n 'id': 0\n}\n\nbody = {\n 'billet_discount': 0,\n 'card_discount': 0,\n 'message': '',\n 'expire_at': '2022-12-12',\n 'request_delivery_address': false,\n 'payment_method': 'all'\n}\n\nresponse = gn.update_charge_link(params=params, body=body)\nprint(response)\n"))),Object(i.b)(o.a,{value:"js",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"'use strict';\n\nvar moment = require('moment');\nvar Gerencianet = require('gn-api-sdk-node');\nvar credentials = require('./credentials');\n\nvar options = {\n client_id: credentials.client_id,\n client_secret: credentials.client_secret,\n sandbox: true\n};\n\nvar expireAt = moment()\n .add(3, 'days')\n .format('YYYY-MM-DD');\n\nvar params = {\n id: 0\n};\n\nvar body = {\n billet_discount: 0,\n card_discount: 0,\n message: '',\n expire_at: expireAt,\n request_delivery_address: false,\n payment_method: 'all'\n};\n\nvar gerencianet = new Gerencianet(options);\n\ngerencianet\n .updateChargeLink(params, body)\n .then(console.log)\n .catch(console.log)\n .done();\n"))),Object(i.b)(o.a,{value:"c",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'using System;\n\nnamespace Gerencianet.SDK.Examples\n{\n class UpdateChargeLink\n {\n public static void Execute()\n {\n dynamic endpoints = new Endpoints(Credentials.Default.ClientId, Credentials.Default.ClientSecret, Credentials.Default.Sandbox);\n\n var param = new\n {\n id = 1000\n };\n\n var body = new\n {\n billet_discount = 0,\n card_discount = 0,\n message = "",\n expire_at = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd"),\n request_delivery_address = false,\n payment_method = "all"\n };\n\n try\n {\n var response = endpoints.UpdateChargeLink(param, body);\n Console.WriteLine(response);\n }\n catch (GnException e)\n {\n Console.WriteLine(e.ErrorType);\n Console.WriteLine(e.Message);\n }\n }\n }\n}\n'))),Object(i.b)(o.a,{value:"java",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),"Em atualiza\xe7\xe3o\n"))),Object(i.b)(o.a,{value:"go",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'package main\n\nimport (\n "fmt"\n "github.com/gerencianet/gn-api-sdk-go/gerencianet"\n "github.com/gerencianet/gn-api-sdk-go/_examples/configs"\n)\n\nfunc main(){\n \n credentials := configs.Credentials\n gn := gerencianet.NewGerencianet(credentials)\n\n body := map[string]interface{} {\n "billet_discount": 1,\n "card_discount": 1,\n "message": "teste",\n "expire_at": "2022-12-12",\n "request_delivery_address": false,\n "payment_method": "all",\n }\n\n res, err := gn.UpdateChargeLink(1, body) // no lugar do 1 coloque o charge_id certo\n\n if err != nil {\n fmt.Println(err)\n } else {\n fmt.Println(res)\n }\n}\n'))),Object(i.b)(o.a,{value:"ruby",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'require "gerencianet"\nrequire "date"\nrequire_relative "./credentials"\n\noptions = {\n client_id: CREDENTIALS::CLIENT_ID,\n client_secret: CREDENTIALS::CLIENT_SECRET,\n sandbox: true\n}\n\nexpireAt = Date.today + 3\n\nparams = {\n id: 1000\n}\n\nbody = {\n billet_discount: 0,\n card_discount: 0,\n message: "",\n expire_at: expireAt.strftime,\n request_delivery_address: false,\n payment_method: "all"\n}\n\ngerencianet = Gerencianet.new(options)\nputs gerencianet.update_charge_link(params: params, body: body)\n'))),Object(i.b)(o.a,{value:"delphi",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),"Em atualiza\xe7\xe3o\n")))),Object(i.b)("br",null),Object(i.b)("h3",{id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used"},"a) Hierarchical structure of Schema attributes that can be used:"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),'"id": "/ChargeLinkUpdate"\n "billet_discount": {\n "card_discount": {\n "conditional_discount": {\n "null"\n "id": "/ConditionalDiscount"\n "type": {\n "percentage"\n "currency"\n "value": {\n "until_date": {\n "message": {\n "expire_at": {\n "request_delivery_address": {\n "payment_method": {\n "banking_billet"\n "credit_card"\n "all"\n')),Object(i.b)("p",null,"For more details, ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../AmbienteTestes/PlaygroundTransacoes#put-v1chargeidlink"}),"click here")," and explore in our Playground."),Object(i.b)("br",null),Object(i.b)("h3",{id:"b-attributes-that-can-be-used-to-change-certain-parametersattributes-of-an-existing-payment-link"},"b) Attributes that can be used to change certain parameters/attributes of an existing payment link:"),Object(i.b)("table",null,Object(i.b)("tbody",null,Object(i.b)("tr",null,Object(i.b)("th",null,"Attribute"),Object(i.b)("th",{align:"center"},"Description"),Object(i.b)("th",{align:"center"},"Mandatory"),Object(i.b)("th",{align:"center"},"Type")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"billet_discount")),Object(i.b)("td",{align:"left"},"Defines a discount, in reais, if the payer chooses a boleto banc\xe1rio as the payment method (inform the entire amount, in reais).",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"5000 is equivalent to R$ 50,00")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"Integer")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"card_discount")),Object(i.b)("td",{align:"left"},"Defines a discount, in reais, if the payer chooses a credit card as the payment method (enter Integer value).",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"5000 is equivalent to R$ 50,00")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"Integer")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"conditional_discount")),Object(i.b)("td",{align:"left"},"Defines conditional discount that is valid until a specific date. If payment is not made by that date, the discount is invalidated.",Object(i.b)("br",null),Object(i.b)("br",null)," ",Object(i.b)("em",null,"Atributos de conditional_discount:"),Object(i.b)("br",null),Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"type*")," (String). Allowed values: ",Object(i.b)("br",null),Object(i.b)("code",null,"currency"),": the discount will be reported in cents. ",Object(i.b)("br",null),Object(i.b)("code",null,"percentage"),": the discount will be informed in percentage.",Object(i.b)("br",null),Object(i.b)("br",null)," ",Object(i.b)("code",null,"cnpj*")," ",Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Size: 14 characters. String."),Object(i.b)("br",null),Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"value*"),"// discount amount (Integer). If the discount type is ",Object(i.b)("code",null,"currency")," , the value of this tag must be informed by the integrator in cents (ie, 500 is equivalent to R$ 5.00). If the discount type is ",Object(i.b)("code",null,"percentage"),", the value must be multiplied by 100 (ie 1500 is equivalent to 15%). Examples: ",Object(i.b)("br",null),"1)",Object(i.b)("code",null,"currency"),"// must be informed in cents, that is, if the discount will be R$ 5.99, the integrator must inform",Object(i.b)("code",null,"599"),";",Object(i.b)("br",null)," 2)",Object(i.b)("code",null,"percentage")," // must be informed in cents, that is, if the discount is 15%, the integrator must inform ",Object(i.b)("code",null,"1500"),".",Object(i.b)("br",null),Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"until_date*"),", // Maximum date the discount will be granted. (String).",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Format: YYYY-MM-DD")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"Object")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"message")),Object(i.b)("td",{align:"left"},"Defines a message for the payer. The message appears on the payment screen, in the billing-related emails and on boleto, if this is the chosen payment method.",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Minimum of 3 and maximum of 80 characters.")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"String")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"expire_at")),Object(i.b)("td",{align:"left"},"Defines the due date of the payment screen and of the ticket itself, if this is the chosen payment method.",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Format: YYYY-MM-DD")),Object(i.b)("td",{align:"center"},"Yes"),Object(i.b)("td",{align:"center"},"String")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"request_delivery_address")),Object(i.b)("td",{align:"left"},"Defines whether the payment screen should ask the payer to enter a delivery address. There are two possible values: ",Object(i.b)("br",null),Object(i.b)("br",null)," ",Object(i.b)("ul",null,Object(i.b)("li",null,Object(i.b)("code",null,"true")),Object(i.b)("li",null,Object(i.b)("code",null,"false")))),Object(i.b)("td",{align:"center"},"Yes"),Object(i.b)("td",{align:"center"},"Boolean")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"payment_method")),Object(i.b)("td",{align:"left"},"Defines the payment methods that must be available on the screen for your customer to choose, which can be: ",Object(i.b)("br",null),Object(i.b)("br",null)," ",Object(i.b)("ul",null,Object(i.b)("li",null,Object(i.b)("code",null,"banking_billet")," (boleto banc\xe1rio)"),Object(i.b)("li",null,Object(i.b)("code",null,"credit_card")," (cart\xe3o de cr\xe9dito)"),Object(i.b)("li",null,Object(i.b)("code",null,"all")," (allow payment via boleto and credit card)"))),Object(i.b)("td",{align:"center"},"Yes"),Object(i.b)("td",{align:"center"},"Object")))),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"Fields with * represent mandatory values")),Object(i.b)("br",null),Object(i.b)("hr",null),Object(i.b)("h2",{id:"2-cancel-certain-transaction"},"2. Cancel certain transaction"),Object(i.b)("p",null,"A transaction can only be canceled if it has the status ",Object(i.b)("code",null,"new"),", ",Object(i.b)("code",null,"waiting"),", ",Object(i.b)("code",null,"unpaid")," or ",Object(i.b)("code",null,"link"),"."),Object(i.b)("p",null,"Once a transaction is cancelled, there is only one condition for this status to be changed again: if the customer prints the slip before the integrator cancels the transaction, he or she can make the payment normally at a bank branch. In this case, the integrator and the payer receive payment confirmation as usual and the charge status is changed from ",Object(i.b)("code",null,"canceled")," to ",Object(i.b)("code",null,"paid"),"."),Object(i.b)("p",null,"To cancel a transaction, you must send a ",Object(i.b)("code",null,"PUT")," request to the ",Object(i.b)("code",null,"/v1/charge/:id/cancel")," route, where ",Object(i.b)("code",null,":id")," is the ",Object(i.b)("code",null,"charge_id")," of the desired transaction."),Object(i.b)("p",null,"The example below shows how this can be done, using the SDK's available:"),Object(i.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(i.b)(o.a,{value:"php",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),"<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'informe_seu_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\n$clientSecret = 'informe_seu_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\xe7\xe3o (\"charge_id\")\n$params = [\n 'id' => $charge_id\n];\n \ntry {\n $api = new Gerencianet($options);\n $charge = $api->cancelCharge($params, []);\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"))),Object(i.b)(o.a,{value:"python",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"# encoding: utf-8\n\nfrom gerencianet import Gerencianet\nfrom credentials import CREDENTIALS\n\ngn = Gerencianet(CREDENTIALS)\n\nparams = {\n 'id': 1\n}\n\nresponse = gn.cancel_charge(params=params)\nprint(response)\n"))),Object(i.b)(o.a,{value:"js",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"'use strict';\n\nvar Gerencianet = require('gn-api-sdk-node');\nvar credentials = require('./credentials');\n\nvar options = {\n client_id: credentials.client_id,\n client_secret: credentials.client_secret,\n sandbox: true\n}\n\nvar params = {\n id: 0\n}\n\nvar gerencianet = new Gerencianet(options);\n\ngerencianet\n .cancelCharge(params)\n .then(console.log)\n .catch(console.log)\n .done();\n"))),Object(i.b)(o.a,{value:"c",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"using System;\n\nnamespace Gerencianet.SDK.Examples\n{\n class CancelCharge\n {\n public static void Execute()\n {\n dynamic endpoints = new Endpoints(Credentials.Default.ClientId, Credentials.Default.ClientSecret, Credentials.Default.Sandbox);\n\n var param = new\n {\n id = 0\n };\n\n try\n {\n var response = endpoints.CancelCharge(param);\n Console.WriteLine(response);\n }\n catch (GnException e)\n {\n Console.WriteLine(e.ErrorType);\n Console.WriteLine(e.Message);\n }\n }\n }\n}\n"))),Object(i.b)(o.a,{value:"java",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),'/* Para que a SDK Java funcione corretamente, \xe9 necess\xe1rio que a instancia\xe7\xe3o do m\xf3dulo seja feita atrav\xe9s da cria\xe7\xe3o de um objeto do tipo Gerencianet.\n\nSempre que quisermos chamar uma fun\xe7\xe3o da API, basta invocar o m\xe9todo call do objeto Gerencianet, passando como par\xe2metro o nome do m\xe9todo, os par\xe2metros da requisi\xe7\xe3o (sempre ser\xe1 um HashMap<String, String>), e o "body", que consiste nas propriedades a serem passadas como argumento na chamada de um fun\xe7\xe3o da SDK. O "body" pode ser declarado de duas formas: um JSONObject ou um Map<String, Object>.\n\nEsta estrutura \xe9 necess\xe1ria para representar o corpo da requisi\xe7\xe3o http que \xe9 enviada \xe0 um determinado endpoint. Se o "body" for um JSONObject, o retorno do m\xe9todo call ser\xe1 um JSONObject, se for um Map<String, Object>, o retorno do m\xe9todo call ser\xe1 um Map<String, Object>\n\nA seguir, disponibilizamos links de nosso Github mostrando duas formas diferentes de retorno: JSONObject\ne Map<String, Object>\n\n\nJSONObject\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/json/CancelCharge.java\n\n\nMap<String, Object>\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/map/CancelCharge.java\n\n*/\n'))),Object(i.b)(o.a,{value:"go",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'// No c\xf3digo de exemplo de uso da SDK de Go, definimos as credenciais de acesso \xe0 API (Client_Id e Client_Secret) e o ambiente a ser usado (sandbox como \'true\' ou \'false\') dentro de um arquivo espec\xedfico (configs.go), que est\xe1 localizado no diret\xf3rio "_examples/configs". Essas credenciais s\xe3o exportadas atrav\xe9s da vari\xe1vel \'Credentials\'.\n\npackage main\n\nimport (\n "fmt"\n "github.com/gerencianet/gn-api-sdk-go/gerencianet"\n "github.com/gerencianet/gn-api-sdk-go/_examples/configs"\n)\n\nfunc main(){\n \n credentials := configs.Credentials\n gn := gerencianet.NewGerencianet(credentials)\n\n res, err := gn.CancelCharge(1) // no lugar do 1 coloque o charge_id certo\n\n if err != nil {\n fmt.Println(err)\n } else {\n fmt.Println(res)\n }\n}\n'))),Object(i.b)(o.a,{value:"ruby",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'require "gerencianet"\nrequire_relative "./credentials"\n\noptions = {\n client_id: CREDENTIALS::CLIENT_ID,\n client_secret: CREDENTIALS::CLIENT_SECRET,\n sandbox: true\n}\n\nparams = {\n id: 2363\n}\n\ngerencianet = Gerencianet.new(options)\nputs gerencianet.cancel_charge(params: params)\n'))),Object(i.b)(o.a,{value:"delphi",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"interface\nfunction CancelCharge(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction CancelCharge(Id: String): String;\nvar\n CancelParams: String;\nbegin\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n\n CancelParams := CreateRequestParams( [ 'id='+Id ] ).Text;\n Result := ExecuteGerenciaNetRequest( 'cancelCharge',CancelParams, '', '' );\nend;\n")))),Object(i.b)("br",null),Object(i.b)("hr",null),Object(i.b)("h2",{id:"3-change-notification-url-notification_url-andor-transaction-custom_id"},"3. Change notification URL (notification_url) and/or transaction custom_id"),Object(i.b)("p",null,"You can set or change the information sent in the transaction's ",Object(i.b)("code",null,"metadata")," property at any time. This endpoint is ",Object(i.b)("strong",{parentName:"p"},"extremely important")," for updating your transaction-linked notification URL or modifying the ",Object(i.b)("code",null,"custom_id")," previously associated with your transactions."),Object(i.b)("p",null,"To change the ",Object(i.b)("code",null,"notification_url")," and/or ",Object(i.b)("code",null,"custom_id")," of a transaction, you must send a ",Object(i.b)("code",null,"PUT")," request to the ",Object(i.b)("code",null,"/v1/charge/ route :id/metadata"),", where ",Object(i.b)("code",null,":id")," is the ",Object(i.b)("code",null,"charge_id")," of the desired transaction."),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"Use cases for this endpoint:")),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},"Integrator changed the server IP that was associated in the transaction notification URL;")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},"Integrator has updated the notification URL for new transactions that are created (",Object(i.b)("code",null,"createCharge"),"), but needs to update also on previous transactions (",Object(i.b)("code",null,"updateChargeMetadata"),") that were generated and that are associated with the incorrect/outdated URL;")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},'SSL (https) was installed on the client\'s server and even if the client defines a 301 or 302 redirection rule, it will be necessary to define the new URL in transactions that have the "old" URL;')),Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},"Integrator generated charges and had not informed the notification URL when sending the transaction creation request;")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},"Modify or add information next to the ",Object(i.b)("code",null,"custom_id")," attribute associated with previously generated transactions;")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("p",{parentName:"li"},"Among other possible scenarios."))),Object(i.b)("p",null,"If you want, you can explore and learn more about this feature ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../AmbienteTestes/PlaygroundTransacoes#put-v1chargeidmetadata"}),"using our Playground"),"."),Object(i.b)("p",null,"The example below shows how this can be done, using the SDK's available:"),Object(i.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(i.b)(o.a,{value:"php",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),"<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'informe_seu_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\n$clientSecret = 'informe_seu_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\xe7\xe3o (\"charge_id\")\n$params = [\n 'id' => $charge_id\n];\n \n$body = [\n 'custom_id' => 'REF0001', // associar transa\xe7\xe3o Gerencianet com seu identificador pr\xf3prio\n 'notification_url' => 'http://seu_dominio.com/notification' // url de notifica\xe7\xe3o\n];\n \ntry {\n $api = new Gerencianet($options);\n $charge = $api->updateChargeMetadata($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"))),Object(i.b)(o.a,{value:"python",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"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 'notification_url': \"http://yourdomain.com\",\n 'custom_id': \"my_new_id\"\n}\n \ngn.update_charge_metadata(params=params, body=body)\n"))),Object(i.b)(o.a,{value:"js",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"'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 custom_id: 'REF0001'\n notification_url: 'http://your_domain.com/notification',\n}\n \nvar gerencianet = new Gerencianet(options);\n \ngerencianet\n .updateChargeMetadata(params, body)\n .then(console.log)\n .catch(console.log)\n .done();\n"))),Object(i.b)(o.a,{value:"c",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'dynamic endpoints = new Endpoints("client_id", "client_secret", true);\n \nvar param = new {\n id = 1000\n};\n \nvar body = new {\n notification_url = "http://yourdomain.com",\n custom_id = "my_new_id"\n};\n \nvar response = endpoints.UpdateChargeMetadata(param, body);\n'))),Object(i.b)(o.a,{value:"java",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),'/* Para que a SDK Java funcione corretamente, \xe9 necess\xe1rio que a instancia\xe7\xe3o do m\xf3dulo seja feita atrav\xe9s da cria\xe7\xe3o de um objeto do tipo Gerencianet.\n\nSempre que quisermos chamar uma fun\xe7\xe3o da API, basta invocar o m\xe9todo call do objeto Gerencianet, passando como par\xe2metro o nome do m\xe9todo, os par\xe2metros da requisi\xe7\xe3o (sempre ser\xe1 um HashMap<String, String>), e o "body", que consiste nas propriedades a serem passadas como argumento na chamada de um fun\xe7\xe3o da SDK. O "body" pode ser declarado de duas formas: um JSONObject ou um Map<String, Object>.\n\nEsta estrutura \xe9 necess\xe1ria para representar o corpo da requisi\xe7\xe3o http que \xe9 enviada \xe0 um determinado endpoint. Se o "body" for um JSONObject, o retorno do m\xe9todo call ser\xe1 um JSONObject, se for um Map<String, Object>, o retorno do m\xe9todo call ser\xe1 um Map<String, Object>\n\nA seguir, disponibilizamos links de nosso Github mostrando duas formas diferentes de retorno: JSONObject\ne Map<String, Object>\n\n\nJSONObject\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/json/UpdateMetadata.java\n\n\nMap<String, Object>\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/map/UpdateMetadata.java\n\n*/\n'))),Object(i.b)(o.a,{value:"go",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'// No c\xf3digo de exemplo de uso da SDK de Go, definimos as credenciais de acesso \xe0 API (Client_Id e Client_Secret) e o ambiente a ser usado (sandbox como \'true\' ou \'false\') dentro de um arquivo espec\xedfico (configs.go), que est\xe1 localizado no diret\xf3rio "_examples/configs". Essas credenciais s\xe3o exportadas atrav\xe9s da vari\xe1vel \'Credentials\'.\n\npackage main\n\nimport (\n "fmt"\n "github.com/gerencianet/gn-api-sdk-go/gerencianet"\n "github.com/gerencianet/gn-api-sdk-go/_examples/configs"\n)\n\nfunc main(){\n \n credentials := configs.Credentials\n gn := gerencianet.NewGerencianet(credentials)\n\n body := map[string]interface{} {\n "custom_id": "Product 0001",\n "notification_url": "http://domain.com/notification",\n }\n\n res, err := gn.UpdateChargeMetadata(1, body) // no lugar do 1 coloque o charge_id certo\n\n if err != nil {\n fmt.Println(err)\n } else {\n fmt.Println(res)\n }\n}\n'))),Object(i.b)(o.a,{value:"ruby",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'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 notification_url: "http://yourdomain.com",\n custom_id: "my_new_id"\n}\n \ngerencianet = Gerencianet.new(options)\ngerencianet.update_charge_metadata(params: params, body: body)\n'))),Object(i.b)(o.a,{value:"delphi",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"interface\nfunction UpdateChargeMetadata(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction UpdateChargeMetadata(Id: String): String;\nvar\n Body : String;\n Params : String;\nbegin\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n\n Params := CreateRequestParams( [ 'id='+Id ] ).Text;\n Body :=\n '{\"custom_id\": \"Product10\",'+\n '\"notification_url\": \"http://domain.com/notification\" }';\n Result := ExecuteGerenciaNetRequest( 'updateChargeMetadata', Params, '', Body );\nend;\n")))),Object(i.b)("br",null),Object(i.b)("h3",{id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used-1"},"a) Hierarchical structure of Schema attributes that can be used:"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),'"id": "/ChargeMetadataUpdate"\n "notification_url"\n "custom_id"\n')),Object(i.b)("p",null,"For more details, ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../AmbienteTestes/PlaygroundTransacoes#put-v1chargeidmetadata"}),"click here")," and explore in our Playground."),Object(i.b)("br",null),Object(i.b)("h3",{id:"b-attributes-that-can-be-used-to-update-notification-url-andor-custom_id"},"b) Attributes that can be used to update notification URL and/or custom_id:"),Object(i.b)("table",null,Object(i.b)("tbody",null,Object(i.b)("tr",null,Object(i.b)("th",null,"Attribute"),Object(i.b)("th",{align:"center"},"Description"),Object(i.b)("th",{align:"center"},"Mandatory"),Object(i.b)("th",{align:"center"},"Type")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"notification_url")),Object(i.b)("td",{align:"left"},"Address of your valid URL that will receive transaction status change notifications.",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Maximum of 255 characters")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"String/null")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"custom_id")),Object(i.b)("td",{align:"left"},"It allows associating a Gerencianet transaction with a specific ID of your system or application, allowing you to identify it if you have a specific ID and want to keep it.",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Maximum of 255 characters")),Object(i.b)("td",{align:"center"},"No"),Object(i.b)("td",{align:"center"},"String")))),Object(i.b)("br",null),Object(i.b)("hr",null),Object(i.b)("h2",{id:"4-add-information-to-transaction-history"},"4. Add information to transaction history"),Object(i.b)("p",null,"Otransaction history represents all actions that have occurred with this transaction up to the present time. Personalized messages do not influence the transaction itself, only its history."),Object(i.b)("p",null,"This can be viewed both in the transaction details through the interface and using the transaction details ",Object(i.b)("em",{parentName:"p"},"endpoint"),"."),Object(i.b)("p",null,"To do so, just send the identifier ",Object(i.b)("code",null,"charge_id")," and the message to be added to the transaction history."),Object(i.b)("p",null,"To add custom messages to a transaction's history, you must send a ",Object(i.b)("code",null,"POST")," request to the ",Object(i.b)("code",null,"/v1/charge/:id/history")," route, where ",Object(i.b)("code",null,":id")," is the ",Object(i.b)("code",null,"charge_id")," of the desired transaction."),Object(i.b)("p",null,"The example below shows how this can be done, using the SDK's available:"),Object(i.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(i.b)(o.a,{value:"php",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),"<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'informe_seu_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\n$clientSecret = 'informe_seu_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\xe7\xe3o (\"charge_id\")\n$params = [\n 'id' => $charge_id\n];\n \n$body = [\n 'description' => 'Custom history' // mensagem que ser\xe1 inserida ao hist\xf3rico do carn\xea\n];\n \ntry {\n $api = new Gerencianet($options);\n $response = $api->createChargeHistory($params, $body);\n \n print_r($response);\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"))),Object(i.b)(o.a,{value:"python",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"# encoding: utf-8\n\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 'description': 'Custom description'\n}\n \ngn.create_carnet_history(params=params, body=body)\n"))),Object(i.b)(o.a,{value:"js",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"'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 description: 'Custom history'\n}\n \nvar gerencianet = new Gerencianet(options);\n \ngerencianet\n .createChargeHistory(params, body)\n .then(console.log)\n .catch(console.log)\n .done();\n"))),Object(i.b)(o.a,{value:"c",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'dynamic endpoints = new Endpoints("client_id", "client_secret", true);\n \nvar params = new {\n id = 1000\n};\n \nvar body = new\n{\n description = "This charge was not fully paid"\n};\n \nvar response = endpoints.CreateChargeHistory(params, body);\n'))),Object(i.b)(o.a,{value:"java",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),'/* Para que a SDK Java funcione corretamente, \xe9 necess\xe1rio que a instancia\xe7\xe3o do m\xf3dulo seja feita atrav\xe9s da cria\xe7\xe3o de um objeto do tipo Gerencianet.\n\nSempre que quisermos chamar uma fun\xe7\xe3o da API, basta invocar o m\xe9todo call do objeto Gerencianet, passando como par\xe2metro o nome do m\xe9todo, os par\xe2metros da requisi\xe7\xe3o (sempre ser\xe1 um HashMap<String, String>), e o "body", que consiste nas propriedades a serem passadas como argumento na chamada de um fun\xe7\xe3o da SDK. O "body" pode ser declarado de duas formas: um JSONObject ou um Map<String, Object>.\n\nEsta estrutura \xe9 necess\xe1ria para representar o corpo da requisi\xe7\xe3o http que \xe9 enviada \xe0 um determinado endpoint. Se o "body" for um JSONObject, o retorno do m\xe9todo call ser\xe1 um JSONObject, se for um Map<String, Object>, o retorno do m\xe9todo call ser\xe1 um Map<String, Object>\n\nA seguir, disponibilizamos links de nosso Github mostrando duas formas diferentes de retorno: JSONObject\ne Map<String, Object>\n\n\nJSONObject\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/json/CreateChargeHistory.java\n\n\nMap<String, Object>\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/map/CreateChargeHistory.java\n\n*/\n'))),Object(i.b)(o.a,{value:"go",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'// No c\xf3digo de exemplo de uso da SDK de Go, definimos as credenciais de acesso \xe0 API (Client_Id e Client_Secret) e o ambiente a ser usado (sandbox como \'true\' ou \'false\') dentro de um arquivo espec\xedfico (configs.go), que est\xe1 localizado no diret\xf3rio "_examples/configs". Essas credenciais s\xe3o exportadas atrav\xe9s da vari\xe1vel \'Credentials\'.\n\npackage main\n\nimport (\n "fmt"\n "github.com/gerencianet/gn-api-sdk-go/gerencianet"\n "github.com/gerencianet/gn-api-sdk-go/_examples/configs"\n)\n\nfunc main(){\n \n credentials := configs.Credentials\n gn := gerencianet.NewGerencianet(credentials)\n\n body := map[string]interface{} {\n "description": "This charge was not fully paid",\n }\n\n res, err := gn.CreateChargeHistory(1, body) // no lugar do 1 coloque o charge_id certo\n\n if err != nil {\n fmt.Println(err)\n } else {\n fmt.Println(res)\n }\n}\n'))),Object(i.b)(o.a,{value:"ruby",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'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 description: \'Custom description\'\n}\n \ngerencianet = Gerencianet.new(options)\ngerencianet.create_charge_history(params: params, body: body)\n'))),Object(i.b)(o.a,{value:"delphi",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"interface\nfunction CreateChargeHistory(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction CreateChargeHistory(Id: String): String;\nvar\n Body : String;\n UpdateParams : String;\nbegin\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n\n UpdateParams := CreateRequestParams( [ 'id='+Id ] ).Text;\n Body := '{\"description\": \"This carnet is about a service\"}';\n Result := ExecuteGerenciaNetRequest( 'createChargeHistory',UpdateParams, '', Body );\nend;\n")))),Object(i.b)("br",null),Object(i.b)("h3",{id:"a-hierarchical-structure-of-schema-attributes-that-can-be-used-2"},"a) Hierarchical structure of Schema attributes that can be used:"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{}),'"id": "/ChargeHistory"\n "description"\n')),Object(i.b)("p",null,"For more details, ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"../AmbienteTestes/PlaygroundTransacoes#post-v1chargeidhistory"}),"click here")," and explore in our Playground."),Object(i.b)("br",null),Object(i.b)("h3",{id:"b-attribute-that-can-be-used-to-add-messages-to-the-transaction-history"},"b) Attribute that can be used to add messages to the transaction history:"),Object(i.b)("table",null,Object(i.b)("tbody",null,Object(i.b)("tr",null,Object(i.b)("th",null,"Attribute"),Object(i.b)("th",{align:"center"},"Description"),Object(i.b)("th",{align:"center"},"Mandatory"),Object(i.b)("th",{align:"center"},"Type")),Object(i.b)("tr",null,Object(i.b)("td",null,Object(i.b)("code",null,"description")),Object(i.b)("td",{align:"left"},"Allows you to add information to the transaction history.",Object(i.b)("br",null),Object(i.b)(b,{color:"#009615",mdxType:"Highlight"},"Minimum of 1 character and maximum of 255 characters.")),Object(i.b)("td",{align:"center"},"Yes"),Object(i.b)("td",{align:"center"},"String")))),Object(i.b)("br",null),Object(i.b)("hr",null),Object(i.b)("h2",{id:"5-return-transaction-information"},"5. Return transaction information"),Object(i.b)("p",null,"To return information from a transaction, you must send a ",Object(i.b)("code",null,"GET")," request to the ",Object(i.b)("code",null,"/v1/charge/:id")," route, where ",Object(i.b)("code",null,":id")," is the ",Object(i.b)("code",null,"charge_id")," of the desired transaction."),Object(i.b)("p",null,"The example below shows how this can be done, using the SDK's available:"),Object(i.b)(c.a,{defaultValue:"php",values:[{label:"PHP",value:"php"},{label:"Python",value:"python"},{label:"NodeJS",value:"js"},{label:".NET",value:"c"},{label:"Java",value:"java"},{label:"GO",value:"go"},{label:"Ruby",value:"ruby"},{label:"Delphi",value:"delphi"}],mdxType:"Tabs"},Object(i.b)(o.a,{value:"php",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-php"}),"<?php\n \nrequire __DIR__.'/../../vendor/autoload.php'; // caminho relacionado a SDK\n \nuse Gerencianet\\Exception\\GerencianetException;\nuse Gerencianet\\Gerencianet;\n \n$clientId = 'informe_seu_client_id'; // insira seu Client_Id, conforme o ambiente (Des ou Prod)\n$clientSecret = 'informe_seu_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$params = [\n 'id' => $charge_id // $charge_id refere-se ao ID da transa\xe7\xe3o (\"charge_id\")\n];\n\ntry {\n $api = new Gerencianet($options);\n $charge = $api->detailCharge($params, []);\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"))),Object(i.b)(o.a,{value:"python",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-py"}),"# encoding: utf-8\n\nfrom gerencianet import Gerencianet\nfrom credentials import CREDENTIALS\n\ngn = Gerencianet(CREDENTIALS)\n\nparams = {\n 'id': 1\n}\n\nresponse = gn.detail_charge(params=params)\nprint(response)\n"))),Object(i.b)(o.a,{value:"js",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"'use strict';\n\nvar Gerencianet = require('gn-api-sdk-node');\nvar credentials = require('./credentials');\n\nvar options = {\n client_id: credentials.client_id,\n client_secret: credentials.client_secret,\n sandbox: true\n}\n\nvar params = {\n id: 0\n}\n\nvar gerencianet = new Gerencianet(options);\n\ngerencianet\n .detailCharge(params)\n .then(console.log)\n .catch(console.log)\n .done();\n"))),Object(i.b)(o.a,{value:"c",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"using System;\n\nnamespace Gerencianet.SDK.Examples\n{\n class DetailCharge\n {\n public static void Execute()\n {\n dynamic endpoints = new Endpoints(Credentials.Default.ClientId, Credentials.Default.ClientSecret, Credentials.Default.Sandbox);\n\n var param = new\n {\n id = 1000\n };\n\n try\n {\n var response = endpoints.DetailCharge(param);\n Console.WriteLine(response);\n }\n catch (GnException e)\n {\n Console.WriteLine(e.ErrorType);\n Console.WriteLine(e.Message);\n }\n }\n }\n}\n"))),Object(i.b)(o.a,{value:"java",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),'/* Para que a SDK Java funcione corretamente, \xe9 necess\xe1rio que a instancia\xe7\xe3o do m\xf3dulo seja feita atrav\xe9s da cria\xe7\xe3o de um objeto do tipo Gerencianet.\n\nSempre que quisermos chamar uma fun\xe7\xe3o da API, basta invocar o m\xe9todo call do objeto Gerencianet, passando como par\xe2metro o nome do m\xe9todo, os par\xe2metros da requisi\xe7\xe3o (sempre ser\xe1 um HashMap<String, String>), e o "body", que consiste nas propriedades a serem passadas como argumento na chamada de um fun\xe7\xe3o da SDK. O "body" pode ser declarado de duas formas: um JSONObject ou um Map<String, Object>.\n\nEsta estrutura \xe9 necess\xe1ria para representar o corpo da requisi\xe7\xe3o http que \xe9 enviada \xe0 um determinado endpoint. Se o "body" for um JSONObject, o retorno do m\xe9todo call ser\xe1 um JSONObject, se for um Map<String, Object>, o retorno do m\xe9todo call ser\xe1 um Map<String, Object>\n\nA seguir, disponibilizamos links de nosso Github mostrando duas formas diferentes de retorno: JSONObject\ne Map<String, Object>\n\n\nJSONObject\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/json/DetailCharge.java\n\n\nMap<String, Object>\n\nhttps://github.com/gerencianet/gn-api-sdk-java-examples/blob/master/src/main/java/br/com/gerencianet/charge/map/DetailCharge.java\n\n*/\n'))),Object(i.b)(o.a,{value:"go",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-go"}),'// No c\xf3digo de exemplo de uso da SDK de Go, definimos as credenciais de acesso \xe0 API (Client_Id e Client_Secret) e o ambiente a ser usado (sandbox como \'true\' ou \'false\') dentro de um arquivo espec\xedfico (configs.go), que est\xe1 localizado no diret\xf3rio "_examples/configs". Essas credenciais s\xe3o exportadas atrav\xe9s da vari\xe1vel \'Credentials\'.\n\npackage main\n\nimport (\n "fmt"\n "github.com/gerencianet/gn-api-sdk-go/gerencianet"\n "github.com/gerencianet/gn-api-sdk-go/_examples/configs"\n)\n\nfunc main(){\n \n credentials := configs.Credentials\n gn := gerencianet.NewGerencianet(credentials)\n\n res, err := gn.DetailCharge(1) // no lugar do 1 coloque o charge_id certo\n\n if err != nil {\n fmt.Println(err)\n } else {\n fmt.Println(res)\n }\n}\n'))),Object(i.b)(o.a,{value:"ruby",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'require "gerencianet"\nrequire_relative "./credentials"\n\noptions = {\n client_id: CREDENTIALS::CLIENT_ID,\n client_secret: CREDENTIALS::CLIENT_SECRET,\n sandbox: true\n}\n\nparams = {\n id: 1000\n}\n\ngerencianet = Gerencianet.new(options)\nputs gerencianet.detail_charge(params: params)\n'))),Object(i.b)(o.a,{value:"delphi",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"interface\nfunction DetailCharge(Id: String): String;\n\nimplementation\nuses uGerenciaClient, uGerenciaNetClientUtilities;\n{... your code ... }\n\nfunction DetailCharge(Id: String): String;\nvar\n DetailParams: String;\nbegin\n EnableService( 'GerenciaNet.dll' ); \n ConfigureService( ToPAnsiChar( 'client_id' ),ToPAnsiChar( 'client_secret' ),'sandbox','config.json',''); \n GerenciaNetAuthorize();\n\n DetailParams := CreateRequestParams( [ 'id='+Id ] ).Text;\n Result := ExecuteGerenciaNetRequest( 'detailCharge',DetailParams, '', '' );\nend;\n"))))))}p.isMDXComponent=!0},250:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function s(e,n){if(null==e)return{};var t,a,r=function(e,n){if(null==e)return{};var t,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)t=i[a],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)t=i[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var l=r.a.createContext({}),b=function(e){var n=r.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},d=function(e){var n=b(e.components);return r.a.createElement(l.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},p=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),d=b(t),p=a,m=d["".concat(c,".").concat(p)]||d[p]||u[p]||i;return t?r.a.createElement(m,o(o({ref:n},l),{},{components:t})):r.a.createElement(m,o({ref:n},l))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,c=new Array(i);c[0]=p;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,c[1]=o;for(var l=2;l<i;l++)c[l]=t[l];return r.a.createElement.apply(null,c)}return r.a.createElement.apply(null,t)}p.displayName="MDXCreateElement"},254:function(e,n,t){"use strict";function a(e){var n,t,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(n=0;n<e.length;n++)e[n]&&(t=a(e[n]))&&(r&&(r+=" "),r+=t);else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}n.a=function(){for(var e,n,t=0,r="";t<arguments.length;)(e=arguments[t++])&&(n=a(e))&&(r&&(r+=" "),r+=n);return r}},255:function(e,n,t){"use strict";var a=t(0);const r=Object(a.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});n.a=r},256:function(e,n,t){"use strict";var a=t(0),r=t(255);n.a=function(){return Object(a.useContext)(r.a)}},257:function(e,n,t){"use strict";var a=t(0),r=t.n(a),i=t(256),c=t(254),o=t(92),s=t.n(o);const l=37,b=39;n.a=function(e){const{block:n,children:t,defaultValue:o,values:d,groupId:u}=e,{tabGroupChoices:p,setTabGroupChoices:m}=Object(i.a)(),[g,h]=Object(a.useState)(o);if(null!=u){const e=p[u];null!=e&&e!==g&&d.some(n=>n.value===e)&&h(e)}const j=e=>{h(e),null!=u&&m(u,e)},O=[];return r.a.createElement("div",null,r.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(c.a)("tabs",{"tabs--block":n})},d.map(({value:e,label:n})=>r.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":g===e,className:Object(c.a)("tabs__item",s.a.tabItem,{"tabs__item--active":g===e}),key:e,ref:e=>O.push(e),onKeyDown:e=>((e,n,t)=>{switch(t.keyCode){case b:((e,n)=>{const t=e.indexOf(n)+1;e[t]?e[t].focus():e[0].focus()})(e,n);break;case l:((e,n)=>{const t=e.indexOf(n)-1;e[t]?e[t].focus():e[e.length-1].focus()})(e,n)}})(O,e.target,e),onFocus:()=>j(e),onClick:()=>j(e)},n))),r.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(t).filter(e=>e.props.value===g)[0]))}},258:function(e,n,t){"use strict";var a=t(0),r=t.n(a);n.a=function(e){return r.a.createElement("div",null,e.children)}}}]);