Create a payment
1 min
{ "name" "/consent/{consentid}/payments", "method" "post", "url" "https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments", "description" "create a payment", "tab" "examples", "examples" { "languages" \[ { "id" "a6frijtuzjnpmlp 0ubnr", "language" "curl", "code" "curl location globoff 'https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments' \\\\\n header 'accept application/json' \\\\\n header 'content type application/json' \\\\\n data '{\\"clientrequestid\\" \\"string\\",\\"date\\" \\"string\\",\\"amount\\" 0,\\"creditoraccount\\" {\\"holder\\" {}},\\"autoretrystrategy\\" {\\"skipweekend\\"\ false,\\"days\\" \[1,2,3]}}'", "customlabel" "" }, { "id" "mlkxxnctwlxbvwbjzf0az", "language" "nodejs", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments',\n 'headers' {\n 'accept' 'application/json',\n 'content type' 'application/json'\n },\n body json stringify({\n \\"clientrequestid\\" \\"string\\",\n \\"date\\" \\"string\\",\n \\"amount\\" 0,\n \\"creditoraccount\\" {\n \\"holder\\" {}\n }\n })\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "customlabel" "" }, { "id" "ykq9nmexe3bc ny mfk07", "language" "javascript", "code" "var myheaders = new headers();\nmyheaders append(\\"accept\\", \\"application/json\\");\nmyheaders append(\\"content type\\", \\"application/json\\");\n\nvar raw = json stringify({\n \\"clientrequestid\\" \\"string\\",\n \\"date\\" \\"string\\",\n \\"amount\\" 0,\n \\"creditoraccount\\" {\n \\"holder\\" {}\n }\n});\n\nvar requestoptions = {\n method 'post',\n headers myheaders,\n body raw,\n redirect 'follow'\n};\n\nfetch(\\"https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments\\", requestoptions)\n then(response => response text())\n then(result => console log(result))\n catch(error => console log('error', error));", "customlabel" "" }, { "id" "d1yuptxxe5p afnbaak3f", "language" "python", "code" "import requests\nimport json\n\nurl = \\"https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments\\"\n\npayload = json dumps({\n \\"clientrequestid\\" \\"string\\",\n \\"date\\" \\"string\\",\n \\"amount\\" 0,\n \\"creditoraccount\\" {\n \\"holder\\" {}\n }\n})\nheaders = {\n 'accept' 'application/json',\n 'content type' 'application/json'\n}\n\nresponse = requests request(\\"post\\", url, headers=headers, data=payload)\n\nprint(response text)\n", "customlabel" "" }, { "id" "ggorjh99nm2bcvdwfuutw", "language" "ruby", "code" "require \\"uri\\"\nrequire \\"json\\"\nrequire \\"net/http\"\n\nurl = uri(\\"https //api sandbox klavi ai/payment/customer/v1/automatic/consents/{consentid}/payments\\")\n\nhttps = net http new(url host, url port)\nhttps use ssl = true\n\nrequest = net http post new(url)\nrequest\[\\"accept\\"] = \\"application/json\\"\nrequest\[\\"content type\\"] = \\"application/json\\"\nrequest body = json dump({\n \\"clientrequestid\\" \\"string\\",\n \\"date\\" \\"string\\",\n \\"amount\\" 0,\n \\"creditoraccount\\" {\n \\"holder\\" {}\n }\n})\n\nresponse = https request(request)\nputs response read body\n", "customlabel" "" } ], "selectedlanguageid" "a6frijtuzjnpmlp 0ubnr" }, "results" { "languages" \[ { "id" "4jclbzenxcr9vzblne352", "language" "201", "code" "{\n \\"id\\" \\"fcb72e3a b346 4f71 b044 971dc23232c9\\", \n \\"clientrequestid\\" \\"fcb72e3a b346 4f71 b044 dsndsnmnkdsmk\\", \n \\"amount\\" \\"1333 04\\", \n \\"currency\\" \\"brl\\", \n \\"status\\" \\"payment pending\\", \n \\"statusreason\\" {\n \\"code\\" \\"nao informado\\", \n \\"message\\" \\"erro não informado na iniciadora ou detentora de conta \\" \n } \n}", "customlabel" "" } ], "selectedlanguageid" "4jclbzenxcr9vzblne352" }, "request" { "pathparameters" \[ { "name" "consentid", "kind" "required", "type" "string", "description" "pattern ^urn \[a za z0 9]\[a za z0 9\\\\ ]{0,31} \[a za z0 9()+,\\\\ =@;$ ! '%\\\\/?#]+$\nmaxlength 256\nconsent id", "" "pattern ^urn \[a za z0 9]\[a za z0 9\\\\ ]{0,31} \[a za z0 9()+,\\\\ =@;$ ! '%\\\\/?#]+$\nmaxlength 256\nconsent id" } ], "queryparameters" \[], "headerparameters" \[ { "name" "authorization", "kind" "required", "type" "string", "description" "jwt bearer token", "" "jwt bearer token" } ], "bodydataparameters" \[ { "name" "clientrequestid", "kind" "required", "type" "string", "description" "your internal orderid only can be used for once \nyou can use it to associate a payment and you can use uuid generation algorithm to generate it", "" "your internal orderid only can be used for once \nyou can use it to associate a payment and you can use uuid generation algorithm to generate it" }, { "name" "date", "kind" "required", "type" "string", "description" "maxlength 10\npattern ^(\\\d{4}) (1\[0 2]|0?\[1 9]) (3\[01]|\[12]\[0 9]|0?\[1 9])$\nexample 2021 01 01\ndate of payment creation", "" "maxlength 10\npattern ^(\\\d{4}) (1\[0 2]|0?\[1 9]) (3\[01]|\[12]\[0 9]|0?\[1 9])$\nexample 2021 01 01\ndate of payment creation" }, { "name" "amount", "kind" "required", "type" "string", "description" "minlength 4\nmaxlength 19\npattern ^((\\\d{1,16}\\\\ \\\d{2}))$\nexample 100000 12\ntransaction value with 2 decimal places", "" "minlength 4\nmaxlength 19\npattern ^((\\\d{1,16}\\\\ \\\d{2}))$\nexample 100000 12\ntransaction value with 2 decimal places" }, { "name" "currency", "kind" "required", "type" "string", "description" "maxlength 3\npattern ^(\[a z]{3})$\nexample brl\nnational currency code according to iso 4217, i e , 'brl' all reported monetary values are represented with the current currency of brazil", "" "maxlength 3\npattern ^(\[a z]{3})$\nexample brl\nnational currency code according to iso 4217, i e , 'brl' all reported monetary values are represented with the current currency of brazil" }, { "name" "creditoraccount", "kind" "optional", "type" "object", "description" "object containing the data of the recipient (creditor) ", "" "optional", "children" \[ { "name" "ispb", "kind" "required", "type" "string", "description" "minlength 8\nmaxlength 8\npattern ^\[0 9]{8}$\nexample 12345678\nit must be filled in with the ispb (brazilian payment system identifier) of the spi participant (instant payment system) with numbers only " }, { "name" "issuer", "kind" "optional", "type" "string", "description" "minlength 1\nmaxlength 4\npattern ^\[0 9]{1,4}$\nexample 1774\ncode of the agency issuing the account without digit \n \[restriction] mandatory for the following account types cacc (conta deposito a vista) and svgs (conta poupanca) " }, { "name" "number", "kind" "required", "type" "string", "description" "minlength 1\nmaxlength 20\npattern ^\[0 9]{1,20}$\nexample 1234567890\nit must be filled in with the paying user's transactional account number, with verification digit (if any),\nif there is an alphanumeric value, it should be converted to 0 " }, { "name" "accounttype", "kind" "required", "type" "string", "description" "types of accounts used for payment \nexample cacc\nenum \[ cacc, svgs, tran]\n cacc current current account\n svgs savings saving account\n tran transactingaccount prepaid payment account" }, { "name" "holder", "kind" "optional", "type" "object", "description" "holer object", "children" \[ { "name" "identifier", "kind" "optional", "type" "string", "description" "the number of the user identification document\nif identifiertype value is cpf \nmaxlength 11\nexample 11111111111\npattern ^\\\d{11}$\n\nif identifiertype value is cnpj \nmaxlength 14\nexample 11111111111111\npattern ^\\\d{14}$" }, { "name" "name", "kind" "optional", "type" "string", "description" "username" }, { "name" "identifiertype", "kind" "optional", "type" "string", "description" "type of the user identification document cnpj or cpf\nif value is cpf \nmaxlength 3\nexample cpf\npattern ^\[a z]{3}$\n\nif value is cnpj\nmaxlength 4\nexample cnpj\npattern ^\[a z]{4}$" } ] } ], "schema" \[ { "name" "ispb", "kind" "required", "type" "string", "description" "minlength 8\nmaxlength 8\npattern ^\[0 9]{8}$\nexample 12345678\nit must be filled in with the ispb (brazilian payment system identifier) of the spi participant (instant payment system) with numbers only " }, { "name" "issuer", "kind" "optional", "type" "string", "description" "minlength 1\nmaxlength 4\npattern ^\[0 9]{1,4}$\nexample 1774\ncode of the agency issuing the account without digit \n \[restriction] mandatory for the following account types cacc (conta deposito a vista) and svgs (conta poupanca) " }, { "name" "number", "kind" "required", "type" "string", "description" "minlength 1\nmaxlength 20\npattern ^\[0 9]{1,20}$\nexample 1234567890\nit must be filled in with the paying user's transactional account number, with verification digit (if any),\nif there is an alphanumeric value, it should be converted to 0 " }, { "name" "accounttype", "kind" "required", "type" "string", "description" "types of accounts used for payment \nexample cacc\nenum \[ cacc, svgs, tran]\n cacc current current account\n svgs savings saving account\n tran transactingaccount prepaid payment account" }, { "name" "holder", "kind" "optional", "type" "object", "description" "holer object", "children" \[ { "name" "identifier", "kind" "optional", "type" "string", "description" "the number of the user identification document\nif identifiertype value is cpf \nmaxlength 11\nexample 11111111111\npattern ^\\\d{11}$\n\nif identifiertype value is cnpj \nmaxlength 14\nexample 11111111111111\npattern ^\\\d{14}$" }, { "name" "name", "kind" "optional", "type" "string", "description" "username" }, { "name" "identifiertype", "kind" "optional", "type" "string", "description" "type of the user identification document cnpj or cpf\nif value is cpf \nmaxlength 3\nexample cpf\npattern ^\[a z]{3}$\n\nif value is cnpj\nmaxlength 4\nexample cnpj\npattern ^\[a z]{4}$" } ] } ] }, { "name" "remittanceinformation", "kind" "optional", "type" "string", "description" "maxlength 140\npattern \[\\\w\\\w\\\s] \nexample pagamento da nota xpto035 002 \nit must be filled in whenever the paying user enters some additional information in a payment, to be sent to the recipient ", "" "maxlength 140\npattern \[\\\w\\\w\\\s] \nexample pagamento da nota xpto035 002 \nit must be filled in whenever the paying user enters some additional information in a payment, to be sent to the recipient " }, { "name" "ibgetowncode", "kind" "optional", "type" "string", "description" "minlength 7\nmaxlength 7\npattern ^\\\d{7}$\nexample 5300108\nthe ibgetowncode field in the pix array has the same behavior as the codmun field described in item 1 6 6 of the pix manual if the municipality information is not sent, the recipient's psp will assume that there are no state and municipal holidays in the period in question;", "" "minlength 7\nmaxlength 7\npattern ^\\\d{7}$\nexample 5300108\nthe ibgetowncode field in the pix array has the same behavior as the codmun field described in item 1 6 6 of the pix manual if the municipality information is not sent, the recipient's psp will assume that there are no state and municipal holidays in the period in question;" }, { "name" "externalinfo", "kind" "optional", "type" "object", "description" "metadata, user customizable\n", "" "metadata, user customizable\n", "children" \[ { "name" "key", "kind" "optional", "type" "string", "description" "" } ], "schema" \[ { "name" "key", "kind" "optional", "type" "string", "description" "" } ] }, { "name" "autoretrystrategy", "kind" "optional", "type" "object", "description" "auto retry strategy \nif provided by the partner, we will retry failed payments within the current billing cycle according to the specified strategy ", "" "auto retry strategy \nif provided by the partner, we will retry failed payments within the current billing cycle according to the specified strategy ", "children" \[ { "name" "days", "kind" "required", "type" "array", "description" "list of retry settlement days (integer array) \neach value represents the number of days after the original payment settlement date \nconstraints \nif interval = weekly \nretry settlement must occur within 5 days after the original settlement date (inclusive)\nif interval ≠ weekly \nretry settlement must occur within 7 days after the original settlement date (inclusive)\nin all cases \na maximum of 3 retry settlements is allowed" }, { "name" "skipweekend", "kind" "required", "type" "boolean", "description" "whether to skip weekends (boolean) \n true if a retry settlement day falls on a weekend, it will be shifted to the next non weekend day \n false executed on the scheduled retry settlement day, even if it falls on a weekend " } ], "schema" \[ { "name" "days", "kind" "required", "type" "array", "description" "list of retry settlement days (integer array) \neach value represents the number of days after the original payment settlement date \nconstraints \nif interval = weekly \nretry settlement must occur within 5 days after the original settlement date (inclusive)\nif interval ≠ weekly \nretry settlement must occur within 7 days after the original settlement date (inclusive)\nin all cases \na maximum of 3 retry settlements is allowed" }, { "name" "skipweekend", "kind" "required", "type" "boolean", "description" "whether to skip weekends (boolean) \n true if a retry settlement day falls on a weekend, it will be shifted to the next non weekend day \n false executed on the scheduled retry settlement day, even if it falls on a weekend " } ] } ], "formdataparameters" \[] }, "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" }, "hastryitout" false, "response" \[ { "name" "id", "kind" "optional", "type" "string", "description" "pattern ^urn \[a za z0 9]\[a za z0 9\\\\ ]{0,31} \[a za z0 9()+,\\\\ =@;$ ! '%\\\\/?#]+$\nmaxlength 256\npayment id" }, { "name" "clientrequestid", "kind" "optional", "type" "string", "description" "your internal orderid only can be used for once \nyou can use it to associate a payment and you can use uuid generation algorithm to generate it", "children" \[] }, { "name" "amount", "kind" "optional", "type" "number", "description" "minlength 4\nmaxlength 19\npattern ^((\\\d{1,16}\\\\ \\\d{2}))$\nexample 100000 12\ntransaction value with 2 decimal places", "children" \[] }, { "name" "currency", "kind" "optional", "type" "string", "description" "maxlength 3\npattern ^(\[a z]{3})$\nexample brl\nnational currency code according to iso 4217, i e , 'brl' all reported monetary values are represented with the current currency of brazil", "children" \[] }, { "name" "status", "kind" "optional", "type" "string", "description" "example payment pending\nenum \n\[payment pending,payment ready for settlement,payment scheduled,payment settlement processing, payment completed,payment rejected]", "children" \[] }, { "name" "statusreason", "kind" "optional", "type" "object", "description" "status reason object", "children" \[ { "name" "code", "kind" "optional", "type" "string", "description" "example consent awaiting authorization\nenum \n\[not informed,infrastructure failure,authorization expired time, user rejected, origin destination accounts equal, account does not allow payment, divergent authentication, not informed, revoked user, revoked merchant ]" }, { "name" "message", "kind" "optional", "type" "string", "description" "pattern \[wws] \nlength 2048\nexample user refused consent\nstatus message" } ] } ], "autogeneratedanchorslug" "consentconsentidpayments", "legacyhash" "msr8xplxmf geylbtvgog" } auto retry strategy the auto retry strategy is introduced to simplify client integration and reduce the need for manual retry handling when autoretrystrategy is provided in the api request klavi will automatically perform retries based on the configured strategy within the current billing cycle any retry api calls initiated by the partner will be rejected example using auto retry strategy 1\ retry settlement on first, second and third days of the available window, including if it’s weekends settlement date 05/march (thursday) retry settlement dates 06/march (friday), 07/march (saturday), 08/march (sunday) autoretrystrategy { "skipweekend" false, "days" \[1,2,3] } 2\ retry settlement on first, second and third days of the available window, excluding if it’s weekends settlement date 05/march (thursday) retry settlement dates 06/march (friday), 09/march (monday), 10/march (tuesday) autoretrystrategy { "skipweekend" true, "days" \[1,2,3] }