{"id":3532,"date":"2021-03-10T18:06:45","date_gmt":"2021-03-10T18:06:45","guid":{"rendered":"https:\/\/documents.openpay.mx\/?p=3532"},"modified":"2021-03-10T19:31:10","modified_gmt":"2021-03-10T19:31:10","slug":"curl","status":"publish","type":"post","link":"https:\/\/documents-mx-dev.opdevhm.com\/en\/docs\/curl.html","title":{"rendered":"API Reference | cURL"},"content":{"rendered":"
The Openpay API is designed on REST<\/a>, therefore you\u2019ll find that URLs are oriented to resources and that HTTP response codes are used to indicate errors in the API.<\/p> All the API responses are in JSON<\/a>format, including the errors.<\/p> In the case to use the existents Openpay API clients (Java<\/a>, Php<\/a>, C#<\/a>, Python<\/a>, Ruby<\/a>, NodeJS<\/a>), the responses are specifically of type defined in the clients and their respective languajes.<\/p> Available resourcers<\/p><\/blockquote> a) By Merchant<\/p><\/blockquote> b) By Customer<\/p><\/blockquote> The Openpay REST API has a test environment (sandbox) and a production environment. For integrating your system with Openpay, use the credentials that were generated when you signed up. Once you are ready to move to production environment and your request is approved, new credentials will be generated for accessing the production environment.<\/p> The following URIs are the basis of the endpoints for the supported environments:<\/p> A complete endpoint consists of the base URI of the environment, the identifier of the Merchant and the resource.<\/p> For example, if we want to create a new customer, the endpoint would be:<\/p> In order to create a complete request is necessary to send the right HTTP headers and the information in JSON format.<\/p> Authentication example<\/p><\/blockquote> Production<\/p><\/blockquote> To make requests to the Openpay API, is necessary to send the API Key on all your calls to our servers. You can get the key from the dashboard<\/a>.<\/p> There are 2 types of API keys:<\/p> For API authentication you must use the basic access authentication<\/a>, where the API key is the username. The password is not required and it should be left blank for purposes of simplicity<\/p> Openpay returns JSON objects in the service responses.<\/p> Object example<\/p><\/blockquote>API Endpoints<\/h2>
\/v1\/{MERCHANT_ID}\/...\n\n\/fees\n\/fees\/{FEE_ID}\n\/charges\n\/charges\/{TRANSACTION_ID}\n\/payouts\n\/payouts\/{TRANSACTION_ID}\n\/cards\n\/cards\/{CARD_ID}\n\/customers\n\/customers\/{CUSTOMER_ID}\n\/plans\n\/plans\/{PLAN_ID}\n\u200b\/tokens\n\/tokens\/{TOKEN_ID}\n<\/code><\/pre>
\/v1\/{MERCHANT_ID}\/customers\/{CUSTOMER_ID}\/...\n\n\/cards\n\/cards\/{CARD_ID}\n\/bankaccounts\n\/bankaccounts\/{BANKACCOUNT_ID}\n\/charges\n\/charges\/{TRANSACTION_ID}\n\/payouts\n\/payouts\/{TRANSACTION_ID}\n\/transfers\n\/transfers\/{TRANSACTION_ID}\n\/subscriptions\n\/subscriptions\/{SUBSCRIPTION_ID}\n<\/code><\/pre>
Production:<\/code><\/li>
https:\/\/api.openpay.mx<\/code><\/li><\/ul>
POST https:\/\/sandbox-api.openpay.mx\/v1\/mzdtln0bmtms6o3kck8f\/customers<\/code><\/p>
Authentication<\/h2>
curl https:\/\/sandbox-api.openpay.mx\/v1\/mzdtln0bmtms6o3kck8f\/charges \\\n -u sk_e568c42a6c384b7ab02cd47d2e407cab:\n\nEl par\u00e1metro -u se ocupa para realizar la autenticaci\u00f3n HTTP Basic (al agregar dos puntos despu\u00e9s de la llave privada se previene el uso de contrase\u00f1a)\n<\/code><\/pre>
Solo es necesario usar la URI base https:\/\/api.openpay.mx\n<\/code><\/pre>
Errors<\/h2>
Error Object<\/h2>
{\n \"category\" : \"request\",\n \"description\" : \"The customer with id 'm4hqp35pswl02mmc567' does not exist\",\n \"http_code\" : 404,\n \"error_code\" : 1005,\n \"request_id\" : \"1981cdb8-19cb-4bad-8256-e95d58bc035c\",\n \"fraud_rules\": [\n \"Billing <> BIN Country for VISA\/MC\"\n ]\n}\n<\/code><\/pre>