-
Notifications
You must be signed in to change notification settings - Fork 0
/
8102940d.4682260c.js
1 lines (1 loc) · 9.41 KB
/
8102940d.4682260c.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[76],{176:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return o})),n.d(t,"metadata",(function(){return s})),n.d(t,"rightToc",(function(){return u})),n.d(t,"default",(function(){return p}));var a=n(2),r=n(6),c=(n(0),n(250)),i=n(257),l=n(258),o={id:"flutter",title:"Flutter",hide_title:!0,sidebar_label:"Flutter"},s={id:"Instalacao/flutter",isDocsHomePage:!1,title:"Flutter",description:"Flutter",source:"@site/docs\\Instalacao\\flutter.md",permalink:"/documentation/docs/Instalacao/flutter",sidebar_label:"Flutter",sidebar:"someSidebar",previous:{title:"Delphi",permalink:"/documentation/docs/Instalacao/delphi"},next:{title:"Typescript",permalink:"/documentation/docs/Instalacao/typescript"}},u=[{value:"Installation:",id:"installation",children:[]},{value:"Tested with",id:"tested-with",children:[]},{value:"Basic use",id:"basic-use",children:[]},{value:"Examples",id:"examples",children:[]},{value:"Converting the .p12 certificate",id:"converting-the-p12-certificate",children:[]}],b={rightToc:u};function p(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h1",{className:"titulo"},"Flutter"),Object(c.b)("div",{className:"subtitulo"},Object(c.b)("p",null,"Our API is ",Object(c.b)("a",{href:"https://en.wikipedia.org/wiki/Representational_state_transfer"},"RESTful"),"\nand responds in ",Object(c.b)("a",{href:"https://www.json.org/json-en.html"},"JSON"),". Gerencianet uses ",Object(c.b)("a",{href:"https://oauth.net/"},"OAuth")," to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically."),Object(c.b)("p",null,"Below, check out the procedures for installing the Gerencianet SDK in ",Object(c.b)("a",{href:"https://github.com/gerencianet/gn-api-sdk-dart",target:"_blank",title:"Link Externo"},"Dart"),":"),Object(c.b)("br",null),Object(c.b)("h2",{id:"installation"},"Installation:"),Object(c.b)("p",null,"To use this plugin, add Gerencianet as a dependency in your file ",Object(c.b)("a",{href:"https://pub.dev/packages/gerencianet",target:"_blank"},"pubspec.yaml"),"."),Object(c.b)("br",null),Object(c.b)("h2",{id:"tested-with"},"Tested with"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},"Dart ",Object(c.b)("inlineCode",{parentName:"li"},"2.12.3"))),Object(c.b)("br",null),Object(c.b)("h2",{id:"basic-use"},"Basic use"),Object(c.b)("p",null,"Initialize the plugin preferably in initState in your widget."),Object(c.b)("p",null,"Set your credentials, certificate and whether you want to use sandbox or not:"),Object(c.b)(i.a,{defaultValue:"c",values:[{label:"Dart",value:"c"},{label:"Flutter",value:"flutter"}],mdxType:"Tabs"},Object(c.b)(l.a,{value:"c",mdxType:"TabItem"},Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"...\nimport 'package:gerencianet/gerencianet.dart';\n\nclass _PaymentPageState extends State<PaymentPage> {\n var config = {\n 'client_id': 'YOUR_CLIENT_ID',\n 'client_secret': 'YOU_CLIENT_SECRET',\n 'sandbox': false,\n 'pix_cert': '',\n 'pix_private_key': ''\n };\n Gerencianet gerencianet;\n\n @override\n void initState() {\n this.gerencianet = Gerencianet(config);\n }\n\n}\n...\n"))),Object(c.b)(l.a,{value:"flutter",mdxType:"TabItem"},Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"dynamic CREDENTIALS = {\n 'client_id': '', # Enter your client id\n 'client_secret': '', # Enter your client secret\n 'sandbox': false, # Enable or disable sandbox mode\n 'pix_cert': 'assets/certs/cert.crt.pem', # Enter the certificate directory \n 'pix_private_key': 'assets/certs/cert.key.pem' # Enter the certificate key directory \n};\n")))),Object(c.b)("br",null),Object(c.b)("h2",{id:"examples"},"Examples"),Object(c.b)("hr",null),Object(c.b)("p",null,"Example of how to create a charge:"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-java"}),"void createCharge(){\n Gerencianet gn = Gerencianet(config);\n dynamic body = {\n 'items': [\n {'name': \"Product 1\", 'value': 1100, 'amount': 2}\n ],\n };\n return await gn.call('createCharge', body: body);\n}\n")),Object(c.b)("p",null,"All examples available in our SDK you find ",Object(c.b)("a",{href:"https://github.com/gerencianet/gn-api-sdk-dart/tree/main/example",target:"_blank"},"here"),"."),Object(c.b)("p",null,"Also see our Flutter app examples ",Object(c.b)("a",{href:"https://github.com/gerencianet/gn-api-sdk-flutter-examples",target:"_blank"},"here"),"."),Object(c.b)("p",null,"Then run the command:"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{}),"flutter pub get\n")),Object(c.b)("br",null),Object(c.b)("h2",{id:"converting-the-p12-certificate"},"Converting the .p12 certificate"),Object(c.b)("hr",null),Object(c.b)("p",null,"To use Pix API endpoints as our SDK in Flutter/Dart it is necessary that the certificate generated in your Gerencianet account be converted to .pem , this conversion can be done using the following OpenSSL commands:"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{}),"openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys //certificate\nopenssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes //private key\n"))))}p.isMDXComponent=!0},250:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return f}));var a=n(0),r=n.n(a);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},c=Object.keys(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),u=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},b=function(e){var t=u(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},d=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),b=u(n),d=a,f=b["".concat(i,".").concat(d)]||b[d]||p[d]||c;return n?r.a.createElement(f,l(l({ref:t},s),{},{components:n})):r.a.createElement(f,l({ref:t},s))}));function f(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=d;var l={};for(var o in t)hasOwnProperty.call(t,o)&&(l[o]=t[o]);l.originalType=e,l.mdxType="string"==typeof e?e:a,i[1]=l;for(var s=2;s<c;s++)i[s]=n[s];return r.a.createElement.apply(null,i)}return r.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},254:function(e,t,n){"use strict";function a(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=a(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}t.a=function(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=a(e))&&(r&&(r+=" "),r+=t);return r}},255:function(e,t,n){"use strict";var a=n(0);const r=Object(a.createContext)({tabGroupChoices:{},setTabGroupChoices:()=>{},isAnnouncementBarClosed:!1,closeAnnouncementBar:()=>{}});t.a=r},256:function(e,t,n){"use strict";var a=n(0),r=n(255);t.a=function(){return Object(a.useContext)(r.a)}},257:function(e,t,n){"use strict";var a=n(0),r=n.n(a),c=n(256),i=n(254),l=n(92),o=n.n(l);const s=37,u=39;t.a=function(e){const{block:t,children:n,defaultValue:l,values:b,groupId:p}=e,{tabGroupChoices:d,setTabGroupChoices:f}=Object(c.a)(),[m,h]=Object(a.useState)(l);if(null!=p){const e=d[p];null!=e&&e!==m&&b.some(t=>t.value===e)&&h(e)}const O=e=>{h(e),null!=p&&f(p,e)},j=[];return r.a.createElement("div",null,r.a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:Object(i.a)("tabs",{"tabs--block":t})},b.map(({value:e,label:t})=>r.a.createElement("li",{role:"tab",tabIndex:"0","aria-selected":m===e,className:Object(i.a)("tabs__item",o.a.tabItem,{"tabs__item--active":m===e}),key:e,ref:e=>j.push(e),onKeyDown:e=>((e,t,n)=>{switch(n.keyCode){case u:((e,t)=>{const n=e.indexOf(t)+1;e[n]?e[n].focus():e[0].focus()})(e,t);break;case s:((e,t)=>{const n=e.indexOf(t)-1;e[n]?e[n].focus():e[e.length-1].focus()})(e,t)}})(j,e.target,e),onFocus:()=>O(e),onClick:()=>O(e)},t))),r.a.createElement("div",{role:"tabpanel",className:"margin-vert--md"},a.Children.toArray(n).filter(e=>e.props.value===m)[0]))}},258:function(e,t,n){"use strict";var a=n(0),r=n.n(a);t.a=function(e){return r.a.createElement("div",null,e.children)}}}]);