{"__v":1,"_id":"56fd7e6b5a08190e00084f9d","api":{"auth":"required","params":[],"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","url":""},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"API Authentication (HTTP Basic)\"\n}\n[/block]\nRecurly uses HTTP Basic Authentication—your [API key](https://app.recurly.com/go/developer/api_access) is securely encrypted by the SSL channel.\n\nIf you are testing the API calls via the command line with cURL, try:\n\n```\ncurl -H 'Accept: application/xml' \\\n     -H 'X-Api-Version: 2.1' \\\n     -H 'Content-Type: application/xml; charset=utf-8' \\\n     -u [API Key]: https://[subdomain].recurly.com/v2/accounts\n```\n\nIn most programming languages, the API key can be specified in the authentication section of request. If your language requires a username and password, enter the API key in the username and set the password to an empty string.\n\nREGENERATING AN API KEY\nYour API key can be regenerated by clicking on the Regenerate button on the [API credentials](https://app.recurly.com/go/developer/api_access) page.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Calculating your own authorization header\"\n}\n[/block]\nMost programming languages encode the authorization header automatically. With HTTP Basic Authentication, the `Authorization` header is a string containing a Base-64 encoded username and password. In the case of Recurly’s API, you need only specify the username as your API key. If your library requires a password, set it to an empty string.\n\n```\n\"Authorization\": \"Basic \" + base64_encode(API Key)\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Additional headers\"\n}\n[/block]\nACCEPT HEADER\nRecurly API v2 returns results as XML. Your requests should always include the header requesting the results as XML:\n\n```\nAccept: application/xml\n```\n\nCONTENT-TYPE HEADER\nWhen sending data to Recurly in a POST or PUT request, your request must specify the content type of your request:\n\n```\nContent-Type: application/xml; charset=utf-8\n```\n\nX-API-VERSION HEADER\nWhen sending data to Recurly, your request should specify the API version you're attempting to interact with:\n\n```\nX-Api-Version: 2.1\n```\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Acceptable API versions\",\n  \"body\": \"Recurly supports the following API versions: **2.0**, **[2.1](https://dev.recurly.com/v2.1/docs)**.\\n**Note**: we are currently in the process of updating our docs to showcase the differences in our API versions.\"\n}\n[/block]\nIf your XML request is invalid, the API will respond with a status code 400 Bad Request. This commonly occurs when ampersands are not correctly encoded in the text of your request. Please inspect the body of the response for more details regarding the error.\n\n##Private vs. Public\nA private key is used to authenticate APIs for access to private Recurly data.  A public key identifies your site to Recurly servers. Recurly provides each site with one public key. This key can be regenerated in the same manner as private keys.\n\n##Private API Keys\nRecurly supports the use of multiple Private API keys, which can be used to integrate third party services using unique, controlled credentials.\n\n###Limits & Pricing\nMerchants on the Core or grandfathered Recurly plans or merchants in sandbox mode will be granted 5 private API keys. Merchants on Recurly’s Professional plan will be granted 10 private API keys.\n\n###Default Key\nYour default private API key should be used to integrate Recurly with your backend systems. There will be at least one key active at all times.\n\n###Additional Keys\nAdditional private API keys should be used to connect your Recurly data to additional sources, like analytics software, accounting packages, or email tools. Recurly recommends clearly labeling the name of each key to identify the associated vendor.\n\n###Regenerating private API Keys\nWhen you generate a private API key, you have two options:\n1. Block the old key immediately. This is primarily recommended when the security of a key has been compromised.\n2. Allow the old key access for 12 hours. This is primarily used when updating systems and a smooth transition between keys is needed.\n*If a private API key is changed, an email alert will be sent to your Recurly Site Technical Contact.*\n\n###Read-Only Controls\nWhen creating a private key, you will have the option to set the key to “read-only”. This means the end-user of the API key may make GET requests but cannot use PUT or POST requests.","category":"56fd7e6b5a08190e00084f46","createdAt":"2015-06-10T22:06:37.745Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"getting-started","sync_unique":"","title":"Authentication","type":"basic","updates":["5595c7e9f44370190028891c","562aa244ed4bea0d00c11d8b","56bb4e10dabd992100b674f7","56f19a949791b22d0077ba0f"],"user":"5564a0073a61a72f0067cb22","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Authentication


[block:api-header] { "type": "basic", "title": "API Authentication (HTTP Basic)" } [/block] Recurly uses HTTP Basic Authentication—your [API key](https://app.recurly.com/go/developer/api_access) is securely encrypted by the SSL channel. If you are testing the API calls via the command line with cURL, try: ``` curl -H 'Accept: application/xml' \ -H 'X-Api-Version: 2.1' \ -H 'Content-Type: application/xml; charset=utf-8' \ -u [API Key]: https://[subdomain].recurly.com/v2/accounts ``` In most programming languages, the API key can be specified in the authentication section of request. If your language requires a username and password, enter the API key in the username and set the password to an empty string. REGENERATING AN API KEY Your API key can be regenerated by clicking on the Regenerate button on the [API credentials](https://app.recurly.com/go/developer/api_access) page. [block:api-header] { "type": "basic", "title": "Calculating your own authorization header" } [/block] Most programming languages encode the authorization header automatically. With HTTP Basic Authentication, the `Authorization` header is a string containing a Base-64 encoded username and password. In the case of Recurly’s API, you need only specify the username as your API key. If your library requires a password, set it to an empty string. ``` "Authorization": "Basic " + base64_encode(API Key) ``` [block:api-header] { "type": "basic", "title": "Additional headers" } [/block] ACCEPT HEADER Recurly API v2 returns results as XML. Your requests should always include the header requesting the results as XML: ``` Accept: application/xml ``` CONTENT-TYPE HEADER When sending data to Recurly in a POST or PUT request, your request must specify the content type of your request: ``` Content-Type: application/xml; charset=utf-8 ``` X-API-VERSION HEADER When sending data to Recurly, your request should specify the API version you're attempting to interact with: ``` X-Api-Version: 2.1 ``` [block:callout] { "type": "info", "title": "Acceptable API versions", "body": "Recurly supports the following API versions: **2.0**, **[2.1](https://dev.recurly.com/v2.1/docs)**.\n**Note**: we are currently in the process of updating our docs to showcase the differences in our API versions." } [/block] If your XML request is invalid, the API will respond with a status code 400 Bad Request. This commonly occurs when ampersands are not correctly encoded in the text of your request. Please inspect the body of the response for more details regarding the error. ##Private vs. Public A private key is used to authenticate APIs for access to private Recurly data. A public key identifies your site to Recurly servers. Recurly provides each site with one public key. This key can be regenerated in the same manner as private keys. ##Private API Keys Recurly supports the use of multiple Private API keys, which can be used to integrate third party services using unique, controlled credentials. ###Limits & Pricing Merchants on the Core or grandfathered Recurly plans or merchants in sandbox mode will be granted 5 private API keys. Merchants on Recurly’s Professional plan will be granted 10 private API keys. ###Default Key Your default private API key should be used to integrate Recurly with your backend systems. There will be at least one key active at all times. ###Additional Keys Additional private API keys should be used to connect your Recurly data to additional sources, like analytics software, accounting packages, or email tools. Recurly recommends clearly labeling the name of each key to identify the associated vendor. ###Regenerating private API Keys When you generate a private API key, you have two options: 1. Block the old key immediately. This is primarily recommended when the security of a key has been compromised. 2. Allow the old key access for 12 hours. This is primarily used when updating systems and a smooth transition between keys is needed. *If a private API key is changed, an email alert will be sent to your Recurly Site Technical Contact.* ###Read-Only Controls When creating a private key, you will have the option to set the key to “read-only”. This means the end-user of the API key may make GET requests but cannot use PUT or POST requests.
View all 90 endpoints
[block:api-header] { "type": "basic", "title": "API Authentication (HTTP Basic)" } [/block] Recurly uses HTTP Basic Authentication—your [API key](https://app.recurly.com/go/developer/api_access) is securely encrypted by the SSL channel. If you are testing the API calls via the command line with cURL, try: ``` curl -H 'Accept: application/xml' \ -H 'X-Api-Version: 2.1' \ -H 'Content-Type: application/xml; charset=utf-8' \ -u [API Key]: https://[subdomain].recurly.com/v2/accounts ``` In most programming languages, the API key can be specified in the authentication section of request. If your language requires a username and password, enter the API key in the username and set the password to an empty string. REGENERATING AN API KEY Your API key can be regenerated by clicking on the Regenerate button on the [API credentials](https://app.recurly.com/go/developer/api_access) page. [block:api-header] { "type": "basic", "title": "Calculating your own authorization header" } [/block] Most programming languages encode the authorization header automatically. With HTTP Basic Authentication, the `Authorization` header is a string containing a Base-64 encoded username and password. In the case of Recurly’s API, you need only specify the username as your API key. If your library requires a password, set it to an empty string. ``` "Authorization": "Basic " + base64_encode(API Key) ``` [block:api-header] { "type": "basic", "title": "Additional headers" } [/block] ACCEPT HEADER Recurly API v2 returns results as XML. Your requests should always include the header requesting the results as XML: ``` Accept: application/xml ``` CONTENT-TYPE HEADER When sending data to Recurly in a POST or PUT request, your request must specify the content type of your request: ``` Content-Type: application/xml; charset=utf-8 ``` X-API-VERSION HEADER When sending data to Recurly, your request should specify the API version you're attempting to interact with: ``` X-Api-Version: 2.1 ``` [block:callout] { "type": "info", "title": "Acceptable API versions", "body": "Recurly supports the following API versions: **2.0**, **[2.1](https://dev.recurly.com/v2.1/docs)**.\n**Note**: we are currently in the process of updating our docs to showcase the differences in our API versions." } [/block] If your XML request is invalid, the API will respond with a status code 400 Bad Request. This commonly occurs when ampersands are not correctly encoded in the text of your request. Please inspect the body of the response for more details regarding the error. ##Private vs. Public A private key is used to authenticate APIs for access to private Recurly data. A public key identifies your site to Recurly servers. Recurly provides each site with one public key. This key can be regenerated in the same manner as private keys. ##Private API Keys Recurly supports the use of multiple Private API keys, which can be used to integrate third party services using unique, controlled credentials. ###Limits & Pricing Merchants on the Core or grandfathered Recurly plans or merchants in sandbox mode will be granted 5 private API keys. Merchants on Recurly’s Professional plan will be granted 10 private API keys. ###Default Key Your default private API key should be used to integrate Recurly with your backend systems. There will be at least one key active at all times. ###Additional Keys Additional private API keys should be used to connect your Recurly data to additional sources, like analytics software, accounting packages, or email tools. Recurly recommends clearly labeling the name of each key to identify the associated vendor. ###Regenerating private API Keys When you generate a private API key, you have two options: 1. Block the old key immediately. This is primarily recommended when the security of a key has been compromised. 2. Allow the old key access for 12 hours. This is primarily used when updating systems and a smooth transition between keys is needed. *If a private API key is changed, an email alert will be sent to your Recurly Site Technical Contact.* ###Read-Only Controls When creating a private key, you will have the option to set the key to “read-only”. This means the end-user of the API key may make GET requests but cannot use PUT or POST requests.
{"__v":0,"_id":"56fd7e6b5a08190e00084f9e","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"## SUCCESSFUL STATUS CODES (2XX)\n`200 OK`\nThe request was successful.\n`201 Created`\nThe resource was successfully created. Confirms a success when creating a new account, credit, subscription, etc.\n`204 No Content`\nThe request was successful and there is no response body.\n\n## CLIENT ERROR STATUS CODES (4XX)\n`400 Bad Request`\nThe request was invalid or could not be understood by the server. Resubmitting the request will likely result in the same error.\n`401 Unauthorized`\nYour API key is missing or invalid.\n`402 Payment Required`\nYour Recurly account is in production mode but is not in good standing. Please pay any outstanding invoices.\n`403 Forbidden`\nThe login is attempting to perform an action it does not have privileges to access. Verify your login credentials are for the appropriate account.\n`404 Not Found`\nThe resource was not found with the given identifier. The response body will explain which resource was not found.\n`405 Method Not Allowed`\nThe requested method is not valid at the given URL.\n`406 Not Acceptable`\nThe request's Accept header is not set to application/xml.\n`412 Precondition Failed`\nThe request was unsuccessful because a condition was not met. For example, this message may be returned if you attempt to cancel a subscription for an account that has no subscription.\n`422 Unprocessable Entity`\nCould not process a POST or PUT request because the request is invalid. See the response body for more details.\n`429 Too many Requests`\nYou have made too many API requests in the last hour. Future API requests will be ignored until the beginning of the next hour.\n\n## SERVER ERROR STATUS CODES (5XX)\n`500 Internal Server Error`\nThe server encountered an error while processing your request and failed.\n`502 Gateway Error`\nThe load balancer or web server has trouble connecting to the Recurly app. Please try the request again.\n`503 Service Unavailable`\nThe service is temporarily unavailable. Please try the request again.\n\n##FUTURE COMPATIBILITY\nFor future compatibility, please interpret the following status code ranges:\n\n**200–299** as success,\n**400–499** as client request errors,\n**500–599** as server errors\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"404 Not found responses\"\n}\n[/block]\nWhen a lookup, update, or delete request is requested on an object that does not exist, the server returns `404 Not Found`:\n\n```\nStatus: 404 Not Found\nContent-Type: application/xml; charset=utf-8\n```\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n  <symbol>not_found</symbol>\n  <description>The record could not be located.</description>\n</error>\n```","category":"56fd7e6b5a08190e00084f46","createdAt":"2015-06-10T22:06:26.211Z","excerpt":"Every request includes an HTTP status code with the result. The status code should examined before the response. In most error cases, the response body will contain an errors XML document with more details.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"welcome","sync_unique":"","title":"HTTP Status Codes","type":"basic","updates":["56cd46e949abf10b0036a1e6"],"user":"5564a0073a61a72f0067cb22","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

HTTP Status Codes

Every request includes an HTTP status code with the result. The status code should examined before the response. In most error cases, the response body will contain an errors XML document with more details.

## SUCCESSFUL STATUS CODES (2XX) `200 OK` The request was successful. `201 Created` The resource was successfully created. Confirms a success when creating a new account, credit, subscription, etc. `204 No Content` The request was successful and there is no response body. ## CLIENT ERROR STATUS CODES (4XX) `400 Bad Request` The request was invalid or could not be understood by the server. Resubmitting the request will likely result in the same error. `401 Unauthorized` Your API key is missing or invalid. `402 Payment Required` Your Recurly account is in production mode but is not in good standing. Please pay any outstanding invoices. `403 Forbidden` The login is attempting to perform an action it does not have privileges to access. Verify your login credentials are for the appropriate account. `404 Not Found` The resource was not found with the given identifier. The response body will explain which resource was not found. `405 Method Not Allowed` The requested method is not valid at the given URL. `406 Not Acceptable` The request's Accept header is not set to application/xml. `412 Precondition Failed` The request was unsuccessful because a condition was not met. For example, this message may be returned if you attempt to cancel a subscription for an account that has no subscription. `422 Unprocessable Entity` Could not process a POST or PUT request because the request is invalid. See the response body for more details. `429 Too many Requests` You have made too many API requests in the last hour. Future API requests will be ignored until the beginning of the next hour. ## SERVER ERROR STATUS CODES (5XX) `500 Internal Server Error` The server encountered an error while processing your request and failed. `502 Gateway Error` The load balancer or web server has trouble connecting to the Recurly app. Please try the request again. `503 Service Unavailable` The service is temporarily unavailable. Please try the request again. ##FUTURE COMPATIBILITY For future compatibility, please interpret the following status code ranges: **200–299** as success, **400–499** as client request errors, **500–599** as server errors [block:api-header] { "type": "basic", "title": "404 Not found responses" } [/block] When a lookup, update, or delete request is requested on an object that does not exist, the server returns `404 Not Found`: ``` Status: 404 Not Found Content-Type: application/xml; charset=utf-8 ``` ``` <?xml version="1.0" encoding="UTF-8"?> <error> <symbol>not_found</symbol> <description>The record could not be located.</description> </error> ```
## SUCCESSFUL STATUS CODES (2XX) `200 OK` The request was successful. `201 Created` The resource was successfully created. Confirms a success when creating a new account, credit, subscription, etc. `204 No Content` The request was successful and there is no response body. ## CLIENT ERROR STATUS CODES (4XX) `400 Bad Request` The request was invalid or could not be understood by the server. Resubmitting the request will likely result in the same error. `401 Unauthorized` Your API key is missing or invalid. `402 Payment Required` Your Recurly account is in production mode but is not in good standing. Please pay any outstanding invoices. `403 Forbidden` The login is attempting to perform an action it does not have privileges to access. Verify your login credentials are for the appropriate account. `404 Not Found` The resource was not found with the given identifier. The response body will explain which resource was not found. `405 Method Not Allowed` The requested method is not valid at the given URL. `406 Not Acceptable` The request's Accept header is not set to application/xml. `412 Precondition Failed` The request was unsuccessful because a condition was not met. For example, this message may be returned if you attempt to cancel a subscription for an account that has no subscription. `422 Unprocessable Entity` Could not process a POST or PUT request because the request is invalid. See the response body for more details. `429 Too many Requests` You have made too many API requests in the last hour. Future API requests will be ignored until the beginning of the next hour. ## SERVER ERROR STATUS CODES (5XX) `500 Internal Server Error` The server encountered an error while processing your request and failed. `502 Gateway Error` The load balancer or web server has trouble connecting to the Recurly app. Please try the request again. `503 Service Unavailable` The service is temporarily unavailable. Please try the request again. ##FUTURE COMPATIBILITY For future compatibility, please interpret the following status code ranges: **200–299** as success, **400–499** as client request errors, **500–599** as server errors [block:api-header] { "type": "basic", "title": "404 Not found responses" } [/block] When a lookup, update, or delete request is requested on an object that does not exist, the server returns `404 Not Found`: ``` Status: 404 Not Found Content-Type: application/xml; charset=utf-8 ``` ``` <?xml version="1.0" encoding="UTF-8"?> <error> <symbol>not_found</symbol> <description>The record could not be located.</description> </error> ```
{"__v":0,"_id":"56fd7e6b5a08190e00084f9f","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Number of Records\"\n}\n[/block]\nEndpoints that return a list of resources will include a header indicating the total number of records available. This is specified with the `X-Records` header. E.g., for an endpoint with 14 records:\n\n```\nX-Records: 14\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Next\"\n}\n[/block]\nThe amount of records returns within a single API request defaults to 50. It may be changed to a maximum of 200 using a `per_page` query parameter, e.g. to return 200 accounts at a time:\n\n```\nhttps://your-subdomain.recurly.com/v2/accounts?per_page=200\n```\n\nWhen there are more records remaining than fit in the current response, the `Link` header is specified with the URI to the next page of results.\n\n```\nStatus: 200 OK\nX-Records: 204\nLink: <https://your-subdomain.recurly.com/v2/accounts?cursor=1304958672>; rel=\"next\"\nETag: \"a4b0568a2278bc591ceb64b31547eb78\"\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Cursors\"\n}\n[/block]\nThe cursor parameter is a time-based pointer indicating where to resume the results. By using a cursor instead of page numbers, the API avoids returning duplicate records in the case where additional resources are added between pagination requests.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Previous Pages\"\n}\n[/block]\nAfter paginating beyond the first page of results, the Link header will include a link to return to the first page of results (`rel=\"start\"`) and the previous page (`rel=\"prev\"`):\n\n```\nStatus: 200 OK\nX-Records: 204\nLink: <https://your-subdomain.recurly.com/v2/transactions>; rel=\"start\",\n  <https://your-subdomain.recurly.com/v2/transactions?cursor=-1318344434>; rel=\"prev\",\n  <https://your-subdomain.recurly.com/v2/transactions?cursor=1318388868>; rel=\"next\"\nETag: \"c7431fcfc386fd59ee6c3c2e9ac2a30c\"\n```\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n// When accessing a sub resource with a many-to-one relation\\n// to the parent model, the attribute returns a Recurly_Stub.\\n// For example, take Account -> Invoices\\n\\n$account = Recurly_Account::get('my_account_code');\\n\\n// Calling ->invoices returns a Stub which allows lazily loading the list\\n$invoices = $account->invoices;\\n\\nprint $invoices;\\n// => <Recurly_Stub[invoices] href=https://api.recurly.com/v2/accounts/my_account_code/invoices>\\n\\n/**\\n * Prior to 2.5.0 calling ->get() would only return the first page\\n * of results. With 2.5.0 and later, all results will be returned.\\n */\\nforeach ($invoices->get() as $inv) {\\n   print $inv->invoice_number . \\\"\\\\n\\\";\\n}\\n\\n/**\\n * Creating a List object directly will also allow you to iterate\\n * through all pages\\n */\\n$invoices = Recurly_InvoiceList::getForAccount('my_account_code');\\n\\n// Prints all invoices on the account\\nforeach ($invoices as $inv) {\\n   print $inv->invoice_number . \\\"\\\\n\\\";\\n}\\n\",\n      \"language\": \"php\",\n      \"gist\": \"44632c432dce4f56a0fa\"\n    },\n    {\n      \"code\": \"# When accessing a sub resource with a many-to-one relation \\n# to the parent model, the attribute returns a Recurly::Resource::Pager. \\n# For example, take Account -> Invoices\\n\\naccount = Recurly::Account.find('my_account_code')\\n\\nputs account.invoices.class\\n#=> Recurly::Resource::Pager\\n\\n# Pager#each can be used to iterate through the only the given page\\naccount.invoices.each do |invoice|\\n  puts invoice.invoice_number\\nend\\n\\n# The default page size is 50 items, if you wish to page through more\\n# you can use Pager#find_each, find_each continues to fetch pages until\\n# there are none left\\naccount.invoices.find_each do |invoice|\\n  puts invoice.invoice_number\\nend\\n\\n# You can also create a Pager directly from a resource\\nputs Recurly::Invoice.paginate.class\\n#=> Recurly::Resource::Pager\\n\\n# paginate takes options\\nRecurly::Invoice.paginate(per_page: 10).each do |invoice|\\n  puts invoice.invoice_number\\nend\\n\\n# You can also use #find_each directly on the resource\\nRecurly::Invoice.find_each(per_page: 10).each do |invoice|\\n  puts invoice.invoice_number\\nend\\n\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"# When accessing a sub resource with a many-to-one relation\\n# to the parent model, the attribute returns a `relatiator` function.\\n# When called it returns a recurly.resource.Page.\\n# For example, take Account -> Invoices\\n\\naccount = recurly.Account.get('tester')\\n\\nprint account.invoices\\n# => <function relatitator at 0x1023628c0>\\n\\nprint account.invoices().__class__\\n# => <class 'recurly.resource.Page'>\\n\\n# To page through every invoice on the account\\nfor invoice in account.invoices():\\n    print invoice.invoice_number\\n\\n# You can also call the all() method on\\n# a resource to page through every resource\\n# on your site. For instance, to page through\\n# every invoice:\\nfor invoice in recurly.Invoice.all():\\n    print invoice.invoice_number\",\n      \"language\": \"python\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"The PHP `Recurly_Pager` class sets up an iterator. It does not provide pagination functionality by default.\",\n  \"title\": \"PHP Pagination\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f46","createdAt":"2015-06-15T22:48:39.567Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"pagination","sync_unique":"","title":"Pagination","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Pagination


[block:api-header] { "type": "basic", "title": "Number of Records" } [/block] Endpoints that return a list of resources will include a header indicating the total number of records available. This is specified with the `X-Records` header. E.g., for an endpoint with 14 records: ``` X-Records: 14 ``` [block:api-header] { "type": "basic", "title": "Next" } [/block] The amount of records returns within a single API request defaults to 50. It may be changed to a maximum of 200 using a `per_page` query parameter, e.g. to return 200 accounts at a time: ``` https://your-subdomain.recurly.com/v2/accounts?per_page=200 ``` When there are more records remaining than fit in the current response, the `Link` header is specified with the URI to the next page of results. ``` Status: 200 OK X-Records: 204 Link: <https://your-subdomain.recurly.com/v2/accounts?cursor=1304958672>; rel="next" ETag: "a4b0568a2278bc591ceb64b31547eb78" ``` [block:api-header] { "type": "basic", "title": "Cursors" } [/block] The cursor parameter is a time-based pointer indicating where to resume the results. By using a cursor instead of page numbers, the API avoids returning duplicate records in the case where additional resources are added between pagination requests. [block:api-header] { "type": "basic", "title": "Previous Pages" } [/block] After paginating beyond the first page of results, the Link header will include a link to return to the first page of results (`rel="start"`) and the previous page (`rel="prev"`): ``` Status: 200 OK X-Records: 204 Link: <https://your-subdomain.recurly.com/v2/transactions>; rel="start", <https://your-subdomain.recurly.com/v2/transactions?cursor=-1318344434>; rel="prev", <https://your-subdomain.recurly.com/v2/transactions?cursor=1318388868>; rel="next" ETag: "c7431fcfc386fd59ee6c3c2e9ac2a30c" ``` [block:code] { "codes": [ { "code": "<?php\n// When accessing a sub resource with a many-to-one relation\n// to the parent model, the attribute returns a Recurly_Stub.\n// For example, take Account -> Invoices\n\n$account = Recurly_Account::get('my_account_code');\n\n// Calling ->invoices returns a Stub which allows lazily loading the list\n$invoices = $account->invoices;\n\nprint $invoices;\n// => <Recurly_Stub[invoices] href=https://api.recurly.com/v2/accounts/my_account_code/invoices>\n\n/**\n * Prior to 2.5.0 calling ->get() would only return the first page\n * of results. With 2.5.0 and later, all results will be returned.\n */\nforeach ($invoices->get() as $inv) {\n print $inv->invoice_number . \"\\n\";\n}\n\n/**\n * Creating a List object directly will also allow you to iterate\n * through all pages\n */\n$invoices = Recurly_InvoiceList::getForAccount('my_account_code');\n\n// Prints all invoices on the account\nforeach ($invoices as $inv) {\n print $inv->invoice_number . \"\\n\";\n}\n", "language": "php", "gist": "44632c432dce4f56a0fa" }, { "code": "# When accessing a sub resource with a many-to-one relation \n# to the parent model, the attribute returns a Recurly::Resource::Pager. \n# For example, take Account -> Invoices\n\naccount = Recurly::Account.find('my_account_code')\n\nputs account.invoices.class\n#=> Recurly::Resource::Pager\n\n# Pager#each can be used to iterate through the only the given page\naccount.invoices.each do |invoice|\n puts invoice.invoice_number\nend\n\n# The default page size is 50 items, if you wish to page through more\n# you can use Pager#find_each, find_each continues to fetch pages until\n# there are none left\naccount.invoices.find_each do |invoice|\n puts invoice.invoice_number\nend\n\n# You can also create a Pager directly from a resource\nputs Recurly::Invoice.paginate.class\n#=> Recurly::Resource::Pager\n\n# paginate takes options\nRecurly::Invoice.paginate(per_page: 10).each do |invoice|\n puts invoice.invoice_number\nend\n\n# You can also use #find_each directly on the resource\nRecurly::Invoice.find_each(per_page: 10).each do |invoice|\n puts invoice.invoice_number\nend\n", "language": "ruby" }, { "code": "# When accessing a sub resource with a many-to-one relation\n# to the parent model, the attribute returns a `relatiator` function.\n# When called it returns a recurly.resource.Page.\n# For example, take Account -> Invoices\n\naccount = recurly.Account.get('tester')\n\nprint account.invoices\n# => <function relatitator at 0x1023628c0>\n\nprint account.invoices().__class__\n# => <class 'recurly.resource.Page'>\n\n# To page through every invoice on the account\nfor invoice in account.invoices():\n print invoice.invoice_number\n\n# You can also call the all() method on\n# a resource to page through every resource\n# on your site. For instance, to page through\n# every invoice:\nfor invoice in recurly.Invoice.all():\n print invoice.invoice_number", "language": "python", "name": null } ] } [/block] [block:callout] { "type": "warning", "body": "The PHP `Recurly_Pager` class sets up an iterator. It does not provide pagination functionality by default.", "title": "PHP Pagination" } [/block]
[block:api-header] { "type": "basic", "title": "Number of Records" } [/block] Endpoints that return a list of resources will include a header indicating the total number of records available. This is specified with the `X-Records` header. E.g., for an endpoint with 14 records: ``` X-Records: 14 ``` [block:api-header] { "type": "basic", "title": "Next" } [/block] The amount of records returns within a single API request defaults to 50. It may be changed to a maximum of 200 using a `per_page` query parameter, e.g. to return 200 accounts at a time: ``` https://your-subdomain.recurly.com/v2/accounts?per_page=200 ``` When there are more records remaining than fit in the current response, the `Link` header is specified with the URI to the next page of results. ``` Status: 200 OK X-Records: 204 Link: <https://your-subdomain.recurly.com/v2/accounts?cursor=1304958672>; rel="next" ETag: "a4b0568a2278bc591ceb64b31547eb78" ``` [block:api-header] { "type": "basic", "title": "Cursors" } [/block] The cursor parameter is a time-based pointer indicating where to resume the results. By using a cursor instead of page numbers, the API avoids returning duplicate records in the case where additional resources are added between pagination requests. [block:api-header] { "type": "basic", "title": "Previous Pages" } [/block] After paginating beyond the first page of results, the Link header will include a link to return to the first page of results (`rel="start"`) and the previous page (`rel="prev"`): ``` Status: 200 OK X-Records: 204 Link: <https://your-subdomain.recurly.com/v2/transactions>; rel="start", <https://your-subdomain.recurly.com/v2/transactions?cursor=-1318344434>; rel="prev", <https://your-subdomain.recurly.com/v2/transactions?cursor=1318388868>; rel="next" ETag: "c7431fcfc386fd59ee6c3c2e9ac2a30c" ``` [block:code] { "codes": [ { "code": "<?php\n// When accessing a sub resource with a many-to-one relation\n// to the parent model, the attribute returns a Recurly_Stub.\n// For example, take Account -> Invoices\n\n$account = Recurly_Account::get('my_account_code');\n\n// Calling ->invoices returns a Stub which allows lazily loading the list\n$invoices = $account->invoices;\n\nprint $invoices;\n// => <Recurly_Stub[invoices] href=https://api.recurly.com/v2/accounts/my_account_code/invoices>\n\n/**\n * Prior to 2.5.0 calling ->get() would only return the first page\n * of results. With 2.5.0 and later, all results will be returned.\n */\nforeach ($invoices->get() as $inv) {\n print $inv->invoice_number . \"\\n\";\n}\n\n/**\n * Creating a List object directly will also allow you to iterate\n * through all pages\n */\n$invoices = Recurly_InvoiceList::getForAccount('my_account_code');\n\n// Prints all invoices on the account\nforeach ($invoices as $inv) {\n print $inv->invoice_number . \"\\n\";\n}\n", "language": "php", "gist": "44632c432dce4f56a0fa" }, { "code": "# When accessing a sub resource with a many-to-one relation \n# to the parent model, the attribute returns a Recurly::Resource::Pager. \n# For example, take Account -> Invoices\n\naccount = Recurly::Account.find('my_account_code')\n\nputs account.invoices.class\n#=> Recurly::Resource::Pager\n\n# Pager#each can be used to iterate through the only the given page\naccount.invoices.each do |invoice|\n puts invoice.invoice_number\nend\n\n# The default page size is 50 items, if you wish to page through more\n# you can use Pager#find_each, find_each continues to fetch pages until\n# there are none left\naccount.invoices.find_each do |invoice|\n puts invoice.invoice_number\nend\n\n# You can also create a Pager directly from a resource\nputs Recurly::Invoice.paginate.class\n#=> Recurly::Resource::Pager\n\n# paginate takes options\nRecurly::Invoice.paginate(per_page: 10).each do |invoice|\n puts invoice.invoice_number\nend\n\n# You can also use #find_each directly on the resource\nRecurly::Invoice.find_each(per_page: 10).each do |invoice|\n puts invoice.invoice_number\nend\n", "language": "ruby" }, { "code": "# When accessing a sub resource with a many-to-one relation\n# to the parent model, the attribute returns a `relatiator` function.\n# When called it returns a recurly.resource.Page.\n# For example, take Account -> Invoices\n\naccount = recurly.Account.get('tester')\n\nprint account.invoices\n# => <function relatitator at 0x1023628c0>\n\nprint account.invoices().__class__\n# => <class 'recurly.resource.Page'>\n\n# To page through every invoice on the account\nfor invoice in account.invoices():\n print invoice.invoice_number\n\n# You can also call the all() method on\n# a resource to page through every resource\n# on your site. For instance, to page through\n# every invoice:\nfor invoice in recurly.Invoice.all():\n print invoice.invoice_number", "language": "python", "name": null } ] } [/block] [block:callout] { "type": "warning", "body": "The PHP `Recurly_Pager` class sets up an iterator. It does not provide pagination functionality by default.", "title": "PHP Pagination" } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084fa0","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"In order to provide a fast response time to all our customers, we may rate limit excessive requests. By default, new Recurly sites have the following API rate limits:\n\n* Sandbox sites: 400 requests/min. All requests count towards the rate limit.\n* Production sites: 1,000 requests/min. Only GET requests count towards the rate limit.\n\nOnce your site moves into production mode, Recurly will only rate limit GET requests. New subscriptions, account modifications, and other requests using POST, PUT, or DELETE methods will not count against your rate limit.\n\nThe rate limit is calculated over a sliding 5 minute window. This means a production site could make 4,000 requests within one minute and not hit the rate limit so long as the site made less than 1,000 requests during the prior 4 minutes.\n\nIf an API request exceeds the rate limit, the API returns a 429 status code indicating `Too Many Requests`. If your business needs a higher limit, please contact support.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"HTTP Headers\"\n}\n[/block]\nEvery authenticated API request returns headers with your current rate limit information. Your requests’ rate limit headers may look like:\n\n```\nX-RateLimit-Limit: 5000\nX-RateLimit-Remaining: 4999\nX-RateLimit-Reset: 1414622019\n```\n\nThe `X-RateLimit-Limit` is your total request limit during the 5 minute window (e.g. requests/min * 5 min). The `X-RateLimit-Remaining` indicates the number of requests remaining until your requests will be denied. Finally, the `X-RateLimit-Reset` header contains a timestamp for when the current window will completely reset assuming no further API requests are made.","category":"56fd7e6b5a08190e00084f46","createdAt":"2015-06-15T22:49:59.038Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"rate-limits","sync_unique":"","title":"Rate Limits","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Rate Limits


In order to provide a fast response time to all our customers, we may rate limit excessive requests. By default, new Recurly sites have the following API rate limits: * Sandbox sites: 400 requests/min. All requests count towards the rate limit. * Production sites: 1,000 requests/min. Only GET requests count towards the rate limit. Once your site moves into production mode, Recurly will only rate limit GET requests. New subscriptions, account modifications, and other requests using POST, PUT, or DELETE methods will not count against your rate limit. The rate limit is calculated over a sliding 5 minute window. This means a production site could make 4,000 requests within one minute and not hit the rate limit so long as the site made less than 1,000 requests during the prior 4 minutes. If an API request exceeds the rate limit, the API returns a 429 status code indicating `Too Many Requests`. If your business needs a higher limit, please contact support. [block:api-header] { "type": "basic", "title": "HTTP Headers" } [/block] Every authenticated API request returns headers with your current rate limit information. Your requests’ rate limit headers may look like: ``` X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4999 X-RateLimit-Reset: 1414622019 ``` The `X-RateLimit-Limit` is your total request limit during the 5 minute window (e.g. requests/min * 5 min). The `X-RateLimit-Remaining` indicates the number of requests remaining until your requests will be denied. Finally, the `X-RateLimit-Reset` header contains a timestamp for when the current window will completely reset assuming no further API requests are made.
In order to provide a fast response time to all our customers, we may rate limit excessive requests. By default, new Recurly sites have the following API rate limits: * Sandbox sites: 400 requests/min. All requests count towards the rate limit. * Production sites: 1,000 requests/min. Only GET requests count towards the rate limit. Once your site moves into production mode, Recurly will only rate limit GET requests. New subscriptions, account modifications, and other requests using POST, PUT, or DELETE methods will not count against your rate limit. The rate limit is calculated over a sliding 5 minute window. This means a production site could make 4,000 requests within one minute and not hit the rate limit so long as the site made less than 1,000 requests during the prior 4 minutes. If an API request exceeds the rate limit, the API returns a 429 status code indicating `Too Many Requests`. If your business needs a higher limit, please contact support. [block:api-header] { "type": "basic", "title": "HTTP Headers" } [/block] Every authenticated API request returns headers with your current rate limit information. Your requests’ rate limit headers may look like: ``` X-RateLimit-Limit: 5000 X-RateLimit-Remaining: 4999 X-RateLimit-Reset: 1414622019 ``` The `X-RateLimit-Limit` is your total request limit during the 5 minute window (e.g. requests/min * 5 min). The `X-RateLimit-Remaining` indicates the number of requests remaining until your requests will be denied. Finally, the `X-RateLimit-Reset` header contains a timestamp for when the current window will completely reset assuming no further API requests are made.
{"__v":0,"_id":"56fd7e6b5a08190e00084fa1","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"If the requested create, update, or delete cannot be performed due to validation errors, the server returns a `422 Unprocessable Entity` response with an array of the validation errors:\n\n```\nStatus: 422 Unprocessable Entity\nContent-Type: application/xml; charset=utf-8\n```\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>\n  <error field=\"model_name.field_name\" symbol=\"not_a_number\" lang=\"en-US\">is not a number</error>\n</errors>\n```","category":"56fd7e6b5a08190e00084f46","createdAt":"2015-06-15T22:50:50.788Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"api-validation-errors","sync_unique":"","title":"API Validation Errors","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

API Validation Errors


If the requested create, update, or delete cannot be performed due to validation errors, the server returns a `422 Unprocessable Entity` response with an array of the validation errors: ``` Status: 422 Unprocessable Entity Content-Type: application/xml; charset=utf-8 ``` ``` <?xml version="1.0" encoding="UTF-8"?> <errors> <error field="model_name.field_name" symbol="not_a_number" lang="en-US">is not a number</error> </errors> ```
If the requested create, update, or delete cannot be performed due to validation errors, the server returns a `422 Unprocessable Entity` response with an array of the validation errors: ``` Status: 422 Unprocessable Entity Content-Type: application/xml; charset=utf-8 ``` ``` <?xml version="1.0" encoding="UTF-8"?> <errors> <error field="model_name.field_name" symbol="not_a_number" lang="en-US">is not a number</error> </errors> ```
{"__v":0,"_id":"56fd7e6c5a08190e00084fb8","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Recurly has a variety of integrations you should check out!\n\n[Recurly.js](https://docs.recurly.com/js/)\n\n[Webhooks API](https://dev.recurly.com/page/webhooks)\n\n[Customer Imports](https://dev.recurly.com/page/customer-imports)","category":"56fd7e6b5a08190e00084f47","createdAt":"2015-06-26T18:21:30.595Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"integrations","sync_unique":"","title":"Integrations","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Integrations


Recurly has a variety of integrations you should check out! [Recurly.js](https://docs.recurly.com/js/) [Webhooks API](https://dev.recurly.com/page/webhooks) [Customer Imports](https://dev.recurly.com/page/customer-imports)
Recurly has a variety of integrations you should check out! [Recurly.js](https://docs.recurly.com/js/) [Webhooks API](https://dev.recurly.com/page/webhooks) [Customer Imports](https://dev.recurly.com/page/customer-imports)
{"__v":0,"_id":"56fd7e6b5a08190e00084f82","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Recurly has a variety of official client libraries you should check out!\n\n[PHP](https://dev.recurly.com/page/php)\n[Ruby](https://dev.recurly.com/page/ruby)\n[Python](https://dev.recurly.com/page/python)\n[.Net](https://dev.recurly.com/page/net)\niOS – [Github](https://github.com/recurly/recurly-client-ios) | [Documentation](http://cocoadocs.org/docsets/RecurlySDK/)\n[Android](https://github.com/recurly/recurly-client-android)\n\nThere are also some unofficial libraries created by our users\n\n[Java](https://github.com/killbilling/recurly-java-library)\n[GO](https://github.com/cgerrior/gorecurly)\n[Node.js](https://github.com/cgerrior/node-recurly)","category":"56fd7e6b5a08190e00084f48","createdAt":"2015-06-26T18:25:56.960Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"client-libraries","sync_unique":"","title":"Client Libraries","type":"basic","updates":["55940e20fd29b92300c262bf","55b2bfc0a74a380d00e290a6","55b2c0466862a10d00887adf","55bbb926a8400c2d00873f2a","565f689e413e06170093df6a"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Client Libraries


Recurly has a variety of official client libraries you should check out! [PHP](https://dev.recurly.com/page/php) [Ruby](https://dev.recurly.com/page/ruby) [Python](https://dev.recurly.com/page/python) [.Net](https://dev.recurly.com/page/net) iOS – [Github](https://github.com/recurly/recurly-client-ios) | [Documentation](http://cocoadocs.org/docsets/RecurlySDK/) [Android](https://github.com/recurly/recurly-client-android) There are also some unofficial libraries created by our users [Java](https://github.com/killbilling/recurly-java-library) [GO](https://github.com/cgerrior/gorecurly) [Node.js](https://github.com/cgerrior/node-recurly)
Recurly has a variety of official client libraries you should check out! [PHP](https://dev.recurly.com/page/php) [Ruby](https://dev.recurly.com/page/ruby) [Python](https://dev.recurly.com/page/python) [.Net](https://dev.recurly.com/page/net) iOS – [Github](https://github.com/recurly/recurly-client-ios) | [Documentation](http://cocoadocs.org/docsets/RecurlySDK/) [Android](https://github.com/recurly/recurly-client-android) There are also some unofficial libraries created by our users [Java](https://github.com/killbilling/recurly-java-library) [GO](https://github.com/cgerrior/gorecurly) [Node.js](https://github.com/cgerrior/node-recurly)
{"__v":0,"_id":"56fd7e6b5a08190e00084f91","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"<img src=\"https://www.filepicker.io/api/file/g4uPIoMbQR6VlTF7JHyD\" alt=\"Recurly.js Logo\" width=\"300\">\n\n<h3>Customize Your Checkout Process and Accept Payments Securely</h3>\n\nSecurely accept sensitive payment details within your checkout process with a fully customizable user experience. The Recurly.js JavaScript library secures your checkout forms. Create subscriptions, process one-time transactions, and update customer billing information worry-free.\n\n<h3>PCI Compliance through Hosted Fields</h3>\n\nRecurly provides transparent iframes that allow you to deliver a customized customer checkout experience, while ensuring you meet the latest PCI DSS SAQ A compliance requirements.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-04T22:51:11.649Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"recurlyjs","sync_unique":"","title":"Recurly.js Overview","type":"basic","updates":[],"user":"5564a0073a61a72f0067cb22","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Recurly.js Overview


<img src="https://www.filepicker.io/api/file/g4uPIoMbQR6VlTF7JHyD" alt="Recurly.js Logo" width="300"> <h3>Customize Your Checkout Process and Accept Payments Securely</h3> Securely accept sensitive payment details within your checkout process with a fully customizable user experience. The Recurly.js JavaScript library secures your checkout forms. Create subscriptions, process one-time transactions, and update customer billing information worry-free. <h3>PCI Compliance through Hosted Fields</h3> Recurly provides transparent iframes that allow you to deliver a customized customer checkout experience, while ensuring you meet the latest PCI DSS SAQ A compliance requirements.
<img src="https://www.filepicker.io/api/file/g4uPIoMbQR6VlTF7JHyD" alt="Recurly.js Logo" width="300"> <h3>Customize Your Checkout Process and Accept Payments Securely</h3> Securely accept sensitive payment details within your checkout process with a fully customizable user experience. The Recurly.js JavaScript library secures your checkout forms. Create subscriptions, process one-time transactions, and update customer billing information worry-free. <h3>PCI Compliance through Hosted Fields</h3> Recurly provides transparent iframes that allow you to deliver a customized customer checkout experience, while ensuring you meet the latest PCI DSS SAQ A compliance requirements.
{"__v":1,"_id":"56fd7e6b5a08190e00084f92","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"When a customer submits your payment form, Recurly.js sends customer payment information to be encrypted and stored at Recurly and gives you an authorization key to complete the subscription process using our API.\n\nWith this authorization key (or *token*), you can do anything with our API that requires payment information. Because you never handle any sensitive payment information, your PCI scope is drastically reduced.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T03:19:34.724Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"how-it-works","sync_unique":"","title":"How it Works","type":"basic","updates":["570eb5f23160d10e0041df28"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

How it Works


When a customer submits your payment form, Recurly.js sends customer payment information to be encrypted and stored at Recurly and gives you an authorization key to complete the subscription process using our API. With this authorization key (or *token*), you can do anything with our API that requires payment information. Because you never handle any sensitive payment information, your PCI scope is drastically reduced.
When a customer submits your payment form, Recurly.js sends customer payment information to be encrypted and stored at Recurly and gives you an authorization key to complete the subscription process using our API. With this authorization key (or *token*), you can do anything with our API that requires payment information. Because you never handle any sensitive payment information, your PCI scope is drastically reduced.
{"__v":3,"_id":"56fd7e6b5a08190e00084f93","api":{"auth":"required","params":[],"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","url":""},"body":"## Include\n\n`<script src=\"https://js.recurly.com/v4/recurly.js\"></script>`\n\nTo begin, you'll include the Recurly.js script on your page.\n\nThis exposes a single global object, `recurly`.\n\n## Configure\n\n`recurly.configure('sc-ABCDEFGHI123456789');`\n\nSimply call `recurly.configure` anywhere on your page, passing your public key. This identifies your site to Recurly servers. You can find your public key in the [API Access section](https://app.recurly.com/go/developer/api_access) of your admin app.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Be sure to replace `sc-ABCDEFGHI123456789` with your own public key.\",\n  \"title\": \"\"\n}\n[/block]\n`recurly.configure` accepts other options not detailed here. You may refer to the [source](https://github.com/recurly/recurly-js/blob/master/lib/recurly.js#L76-L88) for more detail.\n\n## Build a Card form\n\nBuild a form however you like. Use the data-recurly attribute to identify input field targets to Recurly.js. To identify where Recurly.js will inject card data fields, we recommend using simple div elements.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<form>\\n  <input type=\\\"text\\\" data-recurly=\\\"first_name\\\">\\n  <input type=\\\"text\\\" data-recurly=\\\"last_name\\\">\\n  <div data-recurly=\\\"number\\\"></div>\\n  <div data-recurly=\\\"month\\\"></div>\\n  <div data-recurly=\\\"year\\\"></div>\\n  <div data-recurly=\\\"cvv\\\"></div>\\n  <input type=\\\"hidden\\\" name=\\\"recurly-token\\\" data-recurly=\\\"token\\\">\\n  <button>submit</button>\\n</form>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nTo collect card payment information from your customers, you'll create a form similar to this one. Recurly.js uses the `data-recurly` attributes on the input tags to gather customer information before sending it to our servers.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"In order for recurly.js to inject the card payment hosted fields into your form, the target elements must be present in the document at the time you make the `recurly.configure` call.\"\n}\n[/block]\nNote that card data is not present in the form, but merely given a placeholder element. This is because Recurly.js must inject those fields onto the page within iframes to ensure strict security of customer card data.\n\nThis particular form contains the minimum required input fields, and **the table below demonstrates all possible input fields.**\n\n### Card data\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"number\",\n    \"1-0\": \"month\",\n    \"2-0\": \"year\",\n    \"3-0\": \"first_name\",\n    \"4-0\": \"last_name\",\n    \"5-0\": \"cvv\",\n    \"0-1\": \"`4111-1111-1111-1111`\",\n    \"1-1\": \"`8` or `02`\",\n    \"2-1\": \"`18` or `2018`\",\n    \"3-1\": \"`Pat`\",\n    \"4-1\": \"`Smith`\",\n    \"5-1\": \"`123`\",\n    \"0-2\": \"Credit card number. **Required**\",\n    \"1-2\": \"Card expiration month as a number. **Required**\",\n    \"2-2\": \"Card expiration year as a number. **Required**\",\n    \"3-2\": \"Cardholder first name. **Required**\",\n    \"4-2\": \"Cardholder last name. **Required**\",\n    \"5-2\": \"Card security code.\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\nDepending on how you've configured your [billing address requirements](http://docs.recurly.com/site-settings#address_requirements), some of the following fields may be required.\n\n### Billing address\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"address1\",\n    \"0-1\": \"`1313 Main St.`\",\n    \"0-2\": \"First line of a street address.\",\n    \"1-0\": \"address2\",\n    \"1-1\": \"`Unit 1`\",\n    \"1-2\": \"Second line of a street address.\",\n    \"2-0\": \"city\",\n    \"2-1\": \"`Hope`\",\n    \"2-2\": \"Town or locality.\",\n    \"3-0\": \"state\",\n    \"3-1\": \"`WA`\",\n    \"3-2\": \"Province or region.\",\n    \"4-0\": \"postal_code\",\n    \"4-1\": \"`98552`\",\n    \"4-2\": \"Postal code.\",\n    \"5-0\": \"country\",\n    \"5-1\": \"`US`\",\n    \"5-2\": \"[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.\",\n    \"6-0\": \"phone\",\n    \"6-1\": \"`555-867-5309`\",\n    \"6-2\": \"Phone number.\",\n    \"7-0\": \"vat_number\",\n    \"7-1\": \"`SE0000`\",\n    \"7-2\": \"Customer VAT number. Used for VAT exclusion.\"\n  },\n  \"cols\": 3,\n  \"rows\": 8\n}\n[/block]\n## Styling card fields\n\nSince card fields must be injected within iframes, any font style information must be passed to recurly.configure\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"recurly.configure({\\n  // ...\\n  fields: {\\n    number: '#recurly-number',\\n    month: '#recurly-month',\\n    year: '#recurly-year',\\n    cvv: '#recurly-cvv'\\n  },\\n  style: {\\n    all: {\\n      fontFamily: 'Droid Sans',\\n      fontSize: '14px',\\n      fontColor: 'green',\\n      fontWeight: 'bold',\\n      fontVariant: 'small-caps',\\n      fontStyle: 'italic',\\n      lineHeight: '1em'\\n      placeholder: {\\n        color: 'pink !important'\\n      }\\n    },\\n    number: {\\n      placeholder: {\\n        content: 'Credit Card Number'\\n      }\\n    },\\n    month: {\\n      placeholder: {\\n        content: 'Month (mm)'\\n      }\\n    },\\n    year: {\\n      placeholder: {\\n        content: 'Year (yy)'\\n      }\\n    },\\n    cvv: {\\n      placeholder: {\\n        content: 'Security Code',\\n        color: 'red !important'\\n      }\\n    }\\n  }\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nSince Recurly.js must inject card data fields into iframes, the default browser appearance for those fields will likely not match the appearance of the other fields in your payment form. We provide the following CSS classes to achieve a look and feel similar to your form. Using these classes, you may specify field size, colors, and a full range of appearance customization to make the injected card fields blend into your payment form.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Class Name\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"recurly-hosted-field\",\n    \"1-0\": \"recurly-hosted-field-focus\",\n    \"2-0\": \"recurly-hosted-field-number\",\n    \"3-0\": \"recurly-hosted-field-month\",\n    \"4-0\": \"recurly-hosted-field-year\",\n    \"5-0\": \"recurly-hosted-field-cvv | Default styles for the div surrounding the cvv field iframe\",\n    \"3-1\": \"Default styles for the div surrounding the month field iframe.\",\n    \"4-1\": \"Default styles for the div surrounding the year field iframe.\",\n    \"2-1\": \"Default styles for the div surrounding the month field iframe.\",\n    \"1-1\": \"Applied when the user focuses on a field.\",\n    \"0-1\": \"Default styles for the div surrounding each field iframe.\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n### Fonts\n\nYou may specify font and placeholder text for card fields through `recurly.configure`. The example call to the right demonstrates all available style attributes you may send to `recurly.configure`.\n\nCustom fonts are sourced from [Google Web Fonts](https://www.google.com/fonts). Simply use the name of the font as it appears on the Google Web Fonts site.\n\n### Responsive styles\n\nAll of the built in field classes will support and respond to media queries. You may call `recurly.configure` again to change style properties -- thus you may change any property if the window size changes.\n\n## Working with bank accounts\n\nJust like a card form, use the data-recurly attribute to identify fields to Recurly.js. Since Recurly.js does not need to inject fields for bank accounts, all fields may be displayed as inputs on your payment form.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<form>\\n  <input type=\\\"text\\\" data-recurly=\\\"routing_number\\\">\\n  <input type=\\\"text\\\" data-recurly=\\\"account_number\\\">\\n  <input type=\\\"text\\\" data-recurly=\\\"account_number_confirmation\\\">\\n  <input type=\\\"text\\\" data-recurly=\\\"account_type\\\">\\n  <input type=\\\"text\\\" data-recurly=\\\"name_on_account\\\">\\n  <input type=\\\"hidden\\\" name=\\\"recurly-token\\\" data-recurly=\\\"token\\\">\\n  <button>submit</button>\\n</form>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nAs you would a card form, you collect bank account payment information from your customers, identifying them with the `data-recurly` attributes on the input tags. This form demonstrates the minimum required input fields, and __the table below highlights all possible input fields.__\n\n### Bank Account data\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"routing_number\",\n    \"0-1\": \"`123456789`\",\n    \"0-2\": \"Routing number. **Required**\",\n    \"1-0\": \"account_number\",\n    \"2-0\": \"account_number_confirmation\",\n    \"3-0\": \"account_type\",\n    \"4-0\": \"name_on_account\",\n    \"4-1\": \"`Pat Smith`\",\n    \"3-1\": \"`checking` or `savings`\",\n    \"2-1\": \"`987654321`\",\n    \"1-1\": \"`987654321`\",\n    \"1-2\": \"Account number. **Required**\",\n    \"2-2\": \"Account number confirmation. **Required**\",\n    \"3-2\": \"Account type. **Required**\",\n    \"4-2\": \"Full name on account. **Required**\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\n### Billing address\n\n[See card billing address]","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T03:21:56.345Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"getting-started-1","sync_unique":"","title":"Getting Started","type":"basic","updates":["57180cd7602b9c0e000dab2c"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Getting Started


## Include `<script src="https://js.recurly.com/v4/recurly.js"></script>` To begin, you'll include the Recurly.js script on your page. This exposes a single global object, `recurly`. ## Configure `recurly.configure('sc-ABCDEFGHI123456789');` Simply call `recurly.configure` anywhere on your page, passing your public key. This identifies your site to Recurly servers. You can find your public key in the [API Access section](https://app.recurly.com/go/developer/api_access) of your admin app. [block:callout] { "type": "info", "body": "Be sure to replace `sc-ABCDEFGHI123456789` with your own public key.", "title": "" } [/block] `recurly.configure` accepts other options not detailed here. You may refer to the [source](https://github.com/recurly/recurly-js/blob/master/lib/recurly.js#L76-L88) for more detail. ## Build a Card form Build a form however you like. Use the data-recurly attribute to identify input field targets to Recurly.js. To identify where Recurly.js will inject card data fields, we recommend using simple div elements. [block:code] { "codes": [ { "code": "<form>\n <input type=\"text\" data-recurly=\"first_name\">\n <input type=\"text\" data-recurly=\"last_name\">\n <div data-recurly=\"number\"></div>\n <div data-recurly=\"month\"></div>\n <div data-recurly=\"year\"></div>\n <div data-recurly=\"cvv\"></div>\n <input type=\"hidden\" name=\"recurly-token\" data-recurly=\"token\">\n <button>submit</button>\n</form>", "language": "html" } ] } [/block] To collect card payment information from your customers, you'll create a form similar to this one. Recurly.js uses the `data-recurly` attributes on the input tags to gather customer information before sending it to our servers. [block:callout] { "type": "info", "body": "In order for recurly.js to inject the card payment hosted fields into your form, the target elements must be present in the document at the time you make the `recurly.configure` call." } [/block] Note that card data is not present in the form, but merely given a placeholder element. This is because Recurly.js must inject those fields onto the page within iframes to ensure strict security of customer card data. This particular form contains the minimum required input fields, and **the table below demonstrates all possible input fields.** ### Card data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "number", "1-0": "month", "2-0": "year", "3-0": "first_name", "4-0": "last_name", "5-0": "cvv", "0-1": "`4111-1111-1111-1111`", "1-1": "`8` or `02`", "2-1": "`18` or `2018`", "3-1": "`Pat`", "4-1": "`Smith`", "5-1": "`123`", "0-2": "Credit card number. **Required**", "1-2": "Card expiration month as a number. **Required**", "2-2": "Card expiration year as a number. **Required**", "3-2": "Cardholder first name. **Required**", "4-2": "Cardholder last name. **Required**", "5-2": "Card security code." }, "cols": 3, "rows": 6 } [/block] Depending on how you've configured your [billing address requirements](http://docs.recurly.com/site-settings#address_requirements), some of the following fields may be required. ### Billing address [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "address1", "0-1": "`1313 Main St.`", "0-2": "First line of a street address.", "1-0": "address2", "1-1": "`Unit 1`", "1-2": "Second line of a street address.", "2-0": "city", "2-1": "`Hope`", "2-2": "Town or locality.", "3-0": "state", "3-1": "`WA`", "3-2": "Province or region.", "4-0": "postal_code", "4-1": "`98552`", "4-2": "Postal code.", "5-0": "country", "5-1": "`US`", "5-2": "[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.", "6-0": "phone", "6-1": "`555-867-5309`", "6-2": "Phone number.", "7-0": "vat_number", "7-1": "`SE0000`", "7-2": "Customer VAT number. Used for VAT exclusion." }, "cols": 3, "rows": 8 } [/block] ## Styling card fields Since card fields must be injected within iframes, any font style information must be passed to recurly.configure [block:code] { "codes": [ { "code": "recurly.configure({\n // ...\n fields: {\n number: '#recurly-number',\n month: '#recurly-month',\n year: '#recurly-year',\n cvv: '#recurly-cvv'\n },\n style: {\n all: {\n fontFamily: 'Droid Sans',\n fontSize: '14px',\n fontColor: 'green',\n fontWeight: 'bold',\n fontVariant: 'small-caps',\n fontStyle: 'italic',\n lineHeight: '1em'\n placeholder: {\n color: 'pink !important'\n }\n },\n number: {\n placeholder: {\n content: 'Credit Card Number'\n }\n },\n month: {\n placeholder: {\n content: 'Month (mm)'\n }\n },\n year: {\n placeholder: {\n content: 'Year (yy)'\n }\n },\n cvv: {\n placeholder: {\n content: 'Security Code',\n color: 'red !important'\n }\n }\n }\n});", "language": "javascript" } ] } [/block] Since Recurly.js must inject card data fields into iframes, the default browser appearance for those fields will likely not match the appearance of the other fields in your payment form. We provide the following CSS classes to achieve a look and feel similar to your form. Using these classes, you may specify field size, colors, and a full range of appearance customization to make the injected card fields blend into your payment form. [block:parameters] { "data": { "h-0": "Class Name", "h-1": "Description", "0-0": "recurly-hosted-field", "1-0": "recurly-hosted-field-focus", "2-0": "recurly-hosted-field-number", "3-0": "recurly-hosted-field-month", "4-0": "recurly-hosted-field-year", "5-0": "recurly-hosted-field-cvv | Default styles for the div surrounding the cvv field iframe", "3-1": "Default styles for the div surrounding the month field iframe.", "4-1": "Default styles for the div surrounding the year field iframe.", "2-1": "Default styles for the div surrounding the month field iframe.", "1-1": "Applied when the user focuses on a field.", "0-1": "Default styles for the div surrounding each field iframe." }, "cols": 2, "rows": 5 } [/block] ### Fonts You may specify font and placeholder text for card fields through `recurly.configure`. The example call to the right demonstrates all available style attributes you may send to `recurly.configure`. Custom fonts are sourced from [Google Web Fonts](https://www.google.com/fonts). Simply use the name of the font as it appears on the Google Web Fonts site. ### Responsive styles All of the built in field classes will support and respond to media queries. You may call `recurly.configure` again to change style properties -- thus you may change any property if the window size changes. ## Working with bank accounts Just like a card form, use the data-recurly attribute to identify fields to Recurly.js. Since Recurly.js does not need to inject fields for bank accounts, all fields may be displayed as inputs on your payment form. [block:code] { "codes": [ { "code": "<form>\n <input type=\"text\" data-recurly=\"routing_number\">\n <input type=\"text\" data-recurly=\"account_number\">\n <input type=\"text\" data-recurly=\"account_number_confirmation\">\n <input type=\"text\" data-recurly=\"account_type\">\n <input type=\"text\" data-recurly=\"name_on_account\">\n <input type=\"hidden\" name=\"recurly-token\" data-recurly=\"token\">\n <button>submit</button>\n</form>", "language": "html" } ] } [/block] As you would a card form, you collect bank account payment information from your customers, identifying them with the `data-recurly` attributes on the input tags. This form demonstrates the minimum required input fields, and __the table below highlights all possible input fields.__ ### Bank Account data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "routing_number", "0-1": "`123456789`", "0-2": "Routing number. **Required**", "1-0": "account_number", "2-0": "account_number_confirmation", "3-0": "account_type", "4-0": "name_on_account", "4-1": "`Pat Smith`", "3-1": "`checking` or `savings`", "2-1": "`987654321`", "1-1": "`987654321`", "1-2": "Account number. **Required**", "2-2": "Account number confirmation. **Required**", "3-2": "Account type. **Required**", "4-2": "Full name on account. **Required**" }, "cols": 3, "rows": 5 } [/block] ### Billing address [See card billing address]
## Include `<script src="https://js.recurly.com/v4/recurly.js"></script>` To begin, you'll include the Recurly.js script on your page. This exposes a single global object, `recurly`. ## Configure `recurly.configure('sc-ABCDEFGHI123456789');` Simply call `recurly.configure` anywhere on your page, passing your public key. This identifies your site to Recurly servers. You can find your public key in the [API Access section](https://app.recurly.com/go/developer/api_access) of your admin app. [block:callout] { "type": "info", "body": "Be sure to replace `sc-ABCDEFGHI123456789` with your own public key.", "title": "" } [/block] `recurly.configure` accepts other options not detailed here. You may refer to the [source](https://github.com/recurly/recurly-js/blob/master/lib/recurly.js#L76-L88) for more detail. ## Build a Card form Build a form however you like. Use the data-recurly attribute to identify input field targets to Recurly.js. To identify where Recurly.js will inject card data fields, we recommend using simple div elements. [block:code] { "codes": [ { "code": "<form>\n <input type=\"text\" data-recurly=\"first_name\">\n <input type=\"text\" data-recurly=\"last_name\">\n <div data-recurly=\"number\"></div>\n <div data-recurly=\"month\"></div>\n <div data-recurly=\"year\"></div>\n <div data-recurly=\"cvv\"></div>\n <input type=\"hidden\" name=\"recurly-token\" data-recurly=\"token\">\n <button>submit</button>\n</form>", "language": "html" } ] } [/block] To collect card payment information from your customers, you'll create a form similar to this one. Recurly.js uses the `data-recurly` attributes on the input tags to gather customer information before sending it to our servers. [block:callout] { "type": "info", "body": "In order for recurly.js to inject the card payment hosted fields into your form, the target elements must be present in the document at the time you make the `recurly.configure` call." } [/block] Note that card data is not present in the form, but merely given a placeholder element. This is because Recurly.js must inject those fields onto the page within iframes to ensure strict security of customer card data. This particular form contains the minimum required input fields, and **the table below demonstrates all possible input fields.** ### Card data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "number", "1-0": "month", "2-0": "year", "3-0": "first_name", "4-0": "last_name", "5-0": "cvv", "0-1": "`4111-1111-1111-1111`", "1-1": "`8` or `02`", "2-1": "`18` or `2018`", "3-1": "`Pat`", "4-1": "`Smith`", "5-1": "`123`", "0-2": "Credit card number. **Required**", "1-2": "Card expiration month as a number. **Required**", "2-2": "Card expiration year as a number. **Required**", "3-2": "Cardholder first name. **Required**", "4-2": "Cardholder last name. **Required**", "5-2": "Card security code." }, "cols": 3, "rows": 6 } [/block] Depending on how you've configured your [billing address requirements](http://docs.recurly.com/site-settings#address_requirements), some of the following fields may be required. ### Billing address [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "address1", "0-1": "`1313 Main St.`", "0-2": "First line of a street address.", "1-0": "address2", "1-1": "`Unit 1`", "1-2": "Second line of a street address.", "2-0": "city", "2-1": "`Hope`", "2-2": "Town or locality.", "3-0": "state", "3-1": "`WA`", "3-2": "Province or region.", "4-0": "postal_code", "4-1": "`98552`", "4-2": "Postal code.", "5-0": "country", "5-1": "`US`", "5-2": "[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.", "6-0": "phone", "6-1": "`555-867-5309`", "6-2": "Phone number.", "7-0": "vat_number", "7-1": "`SE0000`", "7-2": "Customer VAT number. Used for VAT exclusion." }, "cols": 3, "rows": 8 } [/block] ## Styling card fields Since card fields must be injected within iframes, any font style information must be passed to recurly.configure [block:code] { "codes": [ { "code": "recurly.configure({\n // ...\n fields: {\n number: '#recurly-number',\n month: '#recurly-month',\n year: '#recurly-year',\n cvv: '#recurly-cvv'\n },\n style: {\n all: {\n fontFamily: 'Droid Sans',\n fontSize: '14px',\n fontColor: 'green',\n fontWeight: 'bold',\n fontVariant: 'small-caps',\n fontStyle: 'italic',\n lineHeight: '1em'\n placeholder: {\n color: 'pink !important'\n }\n },\n number: {\n placeholder: {\n content: 'Credit Card Number'\n }\n },\n month: {\n placeholder: {\n content: 'Month (mm)'\n }\n },\n year: {\n placeholder: {\n content: 'Year (yy)'\n }\n },\n cvv: {\n placeholder: {\n content: 'Security Code',\n color: 'red !important'\n }\n }\n }\n});", "language": "javascript" } ] } [/block] Since Recurly.js must inject card data fields into iframes, the default browser appearance for those fields will likely not match the appearance of the other fields in your payment form. We provide the following CSS classes to achieve a look and feel similar to your form. Using these classes, you may specify field size, colors, and a full range of appearance customization to make the injected card fields blend into your payment form. [block:parameters] { "data": { "h-0": "Class Name", "h-1": "Description", "0-0": "recurly-hosted-field", "1-0": "recurly-hosted-field-focus", "2-0": "recurly-hosted-field-number", "3-0": "recurly-hosted-field-month", "4-0": "recurly-hosted-field-year", "5-0": "recurly-hosted-field-cvv | Default styles for the div surrounding the cvv field iframe", "3-1": "Default styles for the div surrounding the month field iframe.", "4-1": "Default styles for the div surrounding the year field iframe.", "2-1": "Default styles for the div surrounding the month field iframe.", "1-1": "Applied when the user focuses on a field.", "0-1": "Default styles for the div surrounding each field iframe." }, "cols": 2, "rows": 5 } [/block] ### Fonts You may specify font and placeholder text for card fields through `recurly.configure`. The example call to the right demonstrates all available style attributes you may send to `recurly.configure`. Custom fonts are sourced from [Google Web Fonts](https://www.google.com/fonts). Simply use the name of the font as it appears on the Google Web Fonts site. ### Responsive styles All of the built in field classes will support and respond to media queries. You may call `recurly.configure` again to change style properties -- thus you may change any property if the window size changes. ## Working with bank accounts Just like a card form, use the data-recurly attribute to identify fields to Recurly.js. Since Recurly.js does not need to inject fields for bank accounts, all fields may be displayed as inputs on your payment form. [block:code] { "codes": [ { "code": "<form>\n <input type=\"text\" data-recurly=\"routing_number\">\n <input type=\"text\" data-recurly=\"account_number\">\n <input type=\"text\" data-recurly=\"account_number_confirmation\">\n <input type=\"text\" data-recurly=\"account_type\">\n <input type=\"text\" data-recurly=\"name_on_account\">\n <input type=\"hidden\" name=\"recurly-token\" data-recurly=\"token\">\n <button>submit</button>\n</form>", "language": "html" } ] } [/block] As you would a card form, you collect bank account payment information from your customers, identifying them with the `data-recurly` attributes on the input tags. This form demonstrates the minimum required input fields, and __the table below highlights all possible input fields.__ ### Bank Account data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "routing_number", "0-1": "`123456789`", "0-2": "Routing number. **Required**", "1-0": "account_number", "2-0": "account_number_confirmation", "3-0": "account_type", "4-0": "name_on_account", "4-1": "`Pat Smith`", "3-1": "`checking` or `savings`", "2-1": "`987654321`", "1-1": "`987654321`", "1-2": "Account number. **Required**", "2-2": "Account number confirmation. **Required**", "3-2": "Account type. **Required**", "4-2": "Full name on account. **Required**" }, "cols": 3, "rows": 5 } [/block] ### Billing address [See card billing address]
{"__v":0,"_id":"56fd7e6b5a08190e00084f94","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Interrupt the form submit to send billing info to Recurly and get a secure token in exchange. Once you have the token, submit the form to your server.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$('form').on('submit', function (event) {\\n  var form = this;\\n  event.preventDefault();\\n  recurly.token(form, function (err, token) {\\n    if (err) {\\n      // handle error using err.code and err.fields\\n    } else {\\n      // recurly.js has filled in the 'token' field, so now we can submit the\\n      // form to your server; alternatively, you can access token.id and do\\n      // any processing you wish\\n      form.submit();\\n    }\\n  });\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nRecurly.js works with tokens, which represent secure and temporary storage for your customer's sensitive billing information. They are stored directly on Recurly servers to reduce your PCI exposure.\n\nWhen your customers submit your billing form, you'll need to interrupt the submit and ask Recurly.js to create a token from the form. You may have noticed an additional hidden field in the form above, `token`. When you ask Recurly.js for a token during submit, it will automatically populate this field for you. After you get the token, you will submit it to your servers and use it there to talk to any endpoint in our API that accepts a `billing_info`.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"This example demonstrates jQuery as an event-binding and DOM library; however, you may use any library you choose, or interact directly with the DOM (hard mode).\"\n}\n[/block]\n## recurly.token (API)\n\nYou must call recurly.token with your form element.\n\n`recurly.token(document.querySelector('form'), tokenHandler);`\n\nUsing a handler function like this one:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function tokenHandler (err, token) {\\n  if (err) {\\n    // handle error using err.code and err.fields\\n  } else {\\n    // handle success using token.id\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nSends billing information to Recurly to store as a token, sending that token id back to you. There are two ways to call `recurly.token`: with a form, and with an object.\n\nThe simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"form\",\n    \"0-1\": \"`HTMLFormElement`\",\n    \"0-2\": \"Parent form containing `data-recurly` fields.\",\n    \"1-0\": \"callback\",\n    \"1-1\": \"`Function`\",\n    \"1-2\": \"Callback function to accept the returned token.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nA callback is always required\n\n### Callback Arguments\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"err\",\n    \"1-0\": \"token\",\n    \"2-0\": \"id\",\n    \"0-1\": \"`RecurlyError` or `null`\",\n    \"0-2\": \"A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.\",\n    \"1-1\": \"`Object`\",\n    \"1-2\": \"An object containing a token id.\",\n    \"2-1\": \"`String`\",\n    \"2-2\": \"A token id.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n### Returns\n\nNothing.\n\n## recurly.bankAccount.token(API)\n\nYou may call recurly.bankAccount.token with a form element\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"recurly.bankAccount.token(document.querySelector('form'), tokenHandler);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nOr with an Object\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// alternatively..\\nvar billingInfo = {\\n  // required attributes\\n  routing_number: '123456780',\\n  account_number: '111111111',\\n  account_number_confirmation: '111111111',\\n  account_type: 'checking',\\n  name_on_account: 'Pat Smith',\\n\\n  // optional attributes\\n  address1: '123 Main St.',\\n  address2: 'Unit 1',\\n  city: 'Hope',\\n  state: 'WA',\\n  postal_code: '98552',\\n  country: 'US',\\n  vat_number: 'SE0000'\\n};\\n\\nrecurly.bankAccount.token(billingInfo, tokenHandler);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nBoth methods require using a handler function like this one\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function tokenHandler (err, token) {\\n  if (err) {\\n    // handle error using err.code and err.fields\\n  } else {\\n    // handle success using token.id\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nSends bank account billing information to Recurly to store as a token, sending that token id back to you. Just as with card tokenization, there are two ways to call `recurly.bankAccount.token`: with a form, and with an object.\n\nThe simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes.\n\n### Arguments (form)\n[block:parameters]\n{\n  \"data\": {\n    \"1-0\": \"callback\",\n    \"0-0\": \"form\",\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-1\": \"`HTMLFormElement`\",\n    \"0-2\": \"Parent form containing `data-recurly` fields.\",\n    \"1-1\": \"`Function`\",\n    \"1-2\": \"Callback function to accept the returned token.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nAlternatively, you can call `recurly.bankAccount.token` with a plain JavaScript object. This allows a more direct interface to the payment flow, eliminating any need to use the DOM.\n\n### Arguments (object)\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"options\",\n    \"1-0\": \"callback\",\n    \"0-1\": \"`Object`\",\n    \"0-2\": \"An object with billing information properties matching those [outlined above].\",\n    \"1-1\": \"`Function`\",\n    \"1-2\": \"Callback function to accept the returned token.\",\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nA callback is always required\n\n### Callback Arguments\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"err\",\n    \"1-0\": \"token\",\n    \"2-0\": \"id\",\n    \"2-1\": \"`String`\",\n    \"2-2\": \"A token id.\",\n    \"0-1\": \"`RecurlyError` or `null`\",\n    \"0-2\": \"A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.\",\n    \"1-1\": \"`Object`\",\n    \"1-2\": \"An object containing a token id.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n### Returns\n\nNothing.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T04:39:30.344Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"getting-a-token","sync_unique":"","title":"Getting a Token","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Getting a Token


Interrupt the form submit to send billing info to Recurly and get a secure token in exchange. Once you have the token, submit the form to your server. [block:code] { "codes": [ { "code": "$('form').on('submit', function (event) {\n var form = this;\n event.preventDefault();\n recurly.token(form, function (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // recurly.js has filled in the 'token' field, so now we can submit the\n // form to your server; alternatively, you can access token.id and do\n // any processing you wish\n form.submit();\n }\n });\n});", "language": "javascript" } ] } [/block] Recurly.js works with tokens, which represent secure and temporary storage for your customer's sensitive billing information. They are stored directly on Recurly servers to reduce your PCI exposure. When your customers submit your billing form, you'll need to interrupt the submit and ask Recurly.js to create a token from the form. You may have noticed an additional hidden field in the form above, `token`. When you ask Recurly.js for a token during submit, it will automatically populate this field for you. After you get the token, you will submit it to your servers and use it there to talk to any endpoint in our API that accepts a `billing_info`. [block:callout] { "type": "info", "body": "This example demonstrates jQuery as an event-binding and DOM library; however, you may use any library you choose, or interact directly with the DOM (hard mode)." } [/block] ## recurly.token (API) You must call recurly.token with your form element. `recurly.token(document.querySelector('form'), tokenHandler);` Using a handler function like this one: [block:code] { "codes": [ { "code": "function tokenHandler (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // handle success using token.id\n }\n}", "language": "javascript" } ] } [/block] Sends billing information to Recurly to store as a token, sending that token id back to you. There are two ways to call `recurly.token`: with a form, and with an object. The simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes. [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "form", "0-1": "`HTMLFormElement`", "0-2": "Parent form containing `data-recurly` fields.", "1-0": "callback", "1-1": "`Function`", "1-2": "Callback function to accept the returned token." }, "cols": 3, "rows": 2 } [/block] A callback is always required ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.", "1-1": "`Object`", "1-2": "An object containing a token id.", "2-1": "`String`", "2-2": "A token id." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing. ## recurly.bankAccount.token(API) You may call recurly.bankAccount.token with a form element [block:code] { "codes": [ { "code": "recurly.bankAccount.token(document.querySelector('form'), tokenHandler);", "language": "javascript" } ] } [/block] Or with an Object [block:code] { "codes": [ { "code": "// alternatively..\nvar billingInfo = {\n // required attributes\n routing_number: '123456780',\n account_number: '111111111',\n account_number_confirmation: '111111111',\n account_type: 'checking',\n name_on_account: 'Pat Smith',\n\n // optional attributes\n address1: '123 Main St.',\n address2: 'Unit 1',\n city: 'Hope',\n state: 'WA',\n postal_code: '98552',\n country: 'US',\n vat_number: 'SE0000'\n};\n\nrecurly.bankAccount.token(billingInfo, tokenHandler);", "language": "javascript" } ] } [/block] Both methods require using a handler function like this one [block:code] { "codes": [ { "code": "function tokenHandler (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // handle success using token.id\n }\n}", "language": "javascript" } ] } [/block] Sends bank account billing information to Recurly to store as a token, sending that token id back to you. Just as with card tokenization, there are two ways to call `recurly.bankAccount.token`: with a form, and with an object. The simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes. ### Arguments (form) [block:parameters] { "data": { "1-0": "callback", "0-0": "form", "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-1": "`HTMLFormElement`", "0-2": "Parent form containing `data-recurly` fields.", "1-1": "`Function`", "1-2": "Callback function to accept the returned token." }, "cols": 3, "rows": 2 } [/block] Alternatively, you can call `recurly.bankAccount.token` with a plain JavaScript object. This allows a more direct interface to the payment flow, eliminating any need to use the DOM. ### Arguments (object) [block:parameters] { "data": { "0-0": "options", "1-0": "callback", "0-1": "`Object`", "0-2": "An object with billing information properties matching those [outlined above].", "1-1": "`Function`", "1-2": "Callback function to accept the returned token.", "h-0": "Param", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 2 } [/block] A callback is always required ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "2-1": "`String`", "2-2": "A token id.", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.", "1-1": "`Object`", "1-2": "An object containing a token id." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing.
Interrupt the form submit to send billing info to Recurly and get a secure token in exchange. Once you have the token, submit the form to your server. [block:code] { "codes": [ { "code": "$('form').on('submit', function (event) {\n var form = this;\n event.preventDefault();\n recurly.token(form, function (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // recurly.js has filled in the 'token' field, so now we can submit the\n // form to your server; alternatively, you can access token.id and do\n // any processing you wish\n form.submit();\n }\n });\n});", "language": "javascript" } ] } [/block] Recurly.js works with tokens, which represent secure and temporary storage for your customer's sensitive billing information. They are stored directly on Recurly servers to reduce your PCI exposure. When your customers submit your billing form, you'll need to interrupt the submit and ask Recurly.js to create a token from the form. You may have noticed an additional hidden field in the form above, `token`. When you ask Recurly.js for a token during submit, it will automatically populate this field for you. After you get the token, you will submit it to your servers and use it there to talk to any endpoint in our API that accepts a `billing_info`. [block:callout] { "type": "info", "body": "This example demonstrates jQuery as an event-binding and DOM library; however, you may use any library you choose, or interact directly with the DOM (hard mode)." } [/block] ## recurly.token (API) You must call recurly.token with your form element. `recurly.token(document.querySelector('form'), tokenHandler);` Using a handler function like this one: [block:code] { "codes": [ { "code": "function tokenHandler (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // handle success using token.id\n }\n}", "language": "javascript" } ] } [/block] Sends billing information to Recurly to store as a token, sending that token id back to you. There are two ways to call `recurly.token`: with a form, and with an object. The simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes. [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "form", "0-1": "`HTMLFormElement`", "0-2": "Parent form containing `data-recurly` fields.", "1-0": "callback", "1-1": "`Function`", "1-2": "Callback function to accept the returned token." }, "cols": 3, "rows": 2 } [/block] A callback is always required ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.", "1-1": "`Object`", "1-2": "An object containing a token id.", "2-1": "`String`", "2-2": "A token id." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing. ## recurly.bankAccount.token(API) You may call recurly.bankAccount.token with a form element [block:code] { "codes": [ { "code": "recurly.bankAccount.token(document.querySelector('form'), tokenHandler);", "language": "javascript" } ] } [/block] Or with an Object [block:code] { "codes": [ { "code": "// alternatively..\nvar billingInfo = {\n // required attributes\n routing_number: '123456780',\n account_number: '111111111',\n account_number_confirmation: '111111111',\n account_type: 'checking',\n name_on_account: 'Pat Smith',\n\n // optional attributes\n address1: '123 Main St.',\n address2: 'Unit 1',\n city: 'Hope',\n state: 'WA',\n postal_code: '98552',\n country: 'US',\n vat_number: 'SE0000'\n};\n\nrecurly.bankAccount.token(billingInfo, tokenHandler);", "language": "javascript" } ] } [/block] Both methods require using a handler function like this one [block:code] { "codes": [ { "code": "function tokenHandler (err, token) {\n if (err) {\n // handle error using err.code and err.fields\n } else {\n // handle success using token.id\n }\n}", "language": "javascript" } ] } [/block] Sends bank account billing information to Recurly to store as a token, sending that token id back to you. Just as with card tokenization, there are two ways to call `recurly.bankAccount.token`: with a form, and with an object. The simplest is to pass it a form element containing form fields with their corresponding `data-recurly` attributes. ### Arguments (form) [block:parameters] { "data": { "1-0": "callback", "0-0": "form", "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-1": "`HTMLFormElement`", "0-2": "Parent form containing `data-recurly` fields.", "1-1": "`Function`", "1-2": "Callback function to accept the returned token." }, "cols": 3, "rows": 2 } [/block] Alternatively, you can call `recurly.bankAccount.token` with a plain JavaScript object. This allows a more direct interface to the payment flow, eliminating any need to use the DOM. ### Arguments (object) [block:parameters] { "data": { "0-0": "options", "1-0": "callback", "0-1": "`Object`", "0-2": "An object with billing information properties matching those [outlined above].", "1-1": "`Function`", "1-2": "Callback function to accept the returned token.", "h-0": "Param", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 2 } [/block] A callback is always required ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "2-1": "`String`", "2-2": "A token id.", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](#errors) if an error occurred; otherwise `null`.", "1-1": "`Object`", "1-2": "An object containing a token id." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing.
{"__v":1,"_id":"56fd7e6b5a08190e00084f95","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Create a new subscription with a token using one of our [client libraries](http://dev.recurly.com/client-libraries) or [API v2](https://dev.recurly.com).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$subscription = new Recurly_Subscription();\\n$subscription->plan_code = 'monthly_subscription';\\n\\n$subscription->account = new Recurly_Account();\\n$subscription->account->account_code = 'pat_smith';\\n$subscription->account->first_name = 'Pat';\\n$subscription->account->last_name = 'Smith';\\n$subscription->account->email = 'pat@enterpriseexecutive.com';\\n\\n$subscription->account->billing_info = new Recurly_BillingInfo();\\n$subscription->account->billing_info->token_id = 'TOKEN_ID';\\n\\n$subscription->create();\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"Recurly::Subscription.create! plan_code: :monthly_subscription,\\n  account: {\\n    account_code: 'pat_smith',\\n    billing_info: { token_id: 'TOKEN_ID' }\\n  }\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"subscription = recurly.Subscription(\\n  plan_code = 'monthly_subscription',\\n  account = recurly.Account(\\n    account_code = 'pat_smith',\\n    billing_info = recurly.BillingInfo(token_id = 'TOKEN_ID')\\n  )\\n)\\nsubscription.save()\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"var plan = Plans.Get(\\\"monthly_subscription\\\");\\nvar account = new Account(\\\"pat_smith\\\");\\nvar billingInfo = new BillingInfo(account) { TokenId = \\\"TOKEN_ID\\\" };\\nvar subscription = new Subscription(account, plan, \\\"USD\\\");\\n\\nsubscription.Create();\",\n      \"language\": \"csharp\"\n    },\n    {\n      \"code\": \"$ curl https://:subdomain.recurly.com/v2/subscriptions \\\\\\n    -u API_KEY \\\\\\n    -X POST \\\\\\n    -d '<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?> \\\\\\n<subscription> \\\\\\n  <plan_code>monthly_subscription</plan_code> \\\\\\n  <currency>USD</currency> \\\\\\n  <account> \\\\\\n    <account_code>pat_smith</account_code> \\\\\\n    <email>pat@enterpriseexecutive.com</email> \\\\\\n    <first_name>Pat</first_name> \\\\\\n    <last_name>Smith</last_name> \\\\\\n    <billing_info> \\\\\\n      <token_id>TOKEN_ID</token_id> \\\\\\n    </billing_info> \\\\\\n  </account> \\\\\\n</subscription>'\\n\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nOnce Recurly.js has stored your customer's sensitive data and given you a token reference, you will have 20 minutes to use it in our [API](https://dev.recurly.com). Expired tokens are permanently removed from the Recurly servers.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Tokens expire after 20 minutes.\"\n}\n[/block]\nTokens can be used to populate any account Billing Info data through our API. Simply assign it to the Billing Info's `token_id` property and we'll do the rest.\n\n### These endpoints accept tokens within Billing Info.\n\n- Subscription [`create`](https://dev.recurly.com/docs/create-subscription)\n- Account [`create`](https://dev.recurly.com/docs/create-an-account), [`update`](https://dev.recurly.com/docs/update-account)\n- Billing Info [`update`](https://dev.recurly.com/docs/update-an-accounts-billing-info-token)\n- Transaction [`create`](https://dev.recurly.com/docs/create-transaction)\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"If you use a token, no other attributes will be allowed on that Billing Info\\n  for that request.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T04:28:39.561Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"using-a-token","sync_unique":"","title":"Using a Token","type":"basic","updates":["5718f243459f6f0e0075070c"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Using a Token


Create a new subscription with a token using one of our [client libraries](http://dev.recurly.com/client-libraries) or [API v2](https://dev.recurly.com). [block:code] { "codes": [ { "code": "$subscription = new Recurly_Subscription();\n$subscription->plan_code = 'monthly_subscription';\n\n$subscription->account = new Recurly_Account();\n$subscription->account->account_code = 'pat_smith';\n$subscription->account->first_name = 'Pat';\n$subscription->account->last_name = 'Smith';\n$subscription->account->email = 'pat@enterpriseexecutive.com';\n\n$subscription->account->billing_info = new Recurly_BillingInfo();\n$subscription->account->billing_info->token_id = 'TOKEN_ID';\n\n$subscription->create();", "language": "php" }, { "code": "Recurly::Subscription.create! plan_code: :monthly_subscription,\n account: {\n account_code: 'pat_smith',\n billing_info: { token_id: 'TOKEN_ID' }\n }", "language": "ruby" }, { "code": "subscription = recurly.Subscription(\n plan_code = 'monthly_subscription',\n account = recurly.Account(\n account_code = 'pat_smith',\n billing_info = recurly.BillingInfo(token_id = 'TOKEN_ID')\n )\n)\nsubscription.save()", "language": "python" }, { "code": "var plan = Plans.Get(\"monthly_subscription\");\nvar account = new Account(\"pat_smith\");\nvar billingInfo = new BillingInfo(account) { TokenId = \"TOKEN_ID\" };\nvar subscription = new Subscription(account, plan, \"USD\");\n\nsubscription.Create();", "language": "csharp" }, { "code": "$ curl https://:subdomain.recurly.com/v2/subscriptions \\\n -u API_KEY \\\n -X POST \\\n -d '<?xml version=\"1.0\" encoding=\"UTF-8\"?> \\\n<subscription> \\\n <plan_code>monthly_subscription</plan_code> \\\n <currency>USD</currency> \\\n <account> \\\n <account_code>pat_smith</account_code> \\\n <email>pat@enterpriseexecutive.com</email> \\\n <first_name>Pat</first_name> \\\n <last_name>Smith</last_name> \\\n <billing_info> \\\n <token_id>TOKEN_ID</token_id> \\\n </billing_info> \\\n </account> \\\n</subscription>'\n", "language": "curl" } ] } [/block] Once Recurly.js has stored your customer's sensitive data and given you a token reference, you will have 20 minutes to use it in our [API](https://dev.recurly.com). Expired tokens are permanently removed from the Recurly servers. [block:callout] { "type": "info", "body": "Tokens expire after 20 minutes." } [/block] Tokens can be used to populate any account Billing Info data through our API. Simply assign it to the Billing Info's `token_id` property and we'll do the rest. ### These endpoints accept tokens within Billing Info. - Subscription [`create`](https://dev.recurly.com/docs/create-subscription) - Account [`create`](https://dev.recurly.com/docs/create-an-account), [`update`](https://dev.recurly.com/docs/update-account) - Billing Info [`update`](https://dev.recurly.com/docs/update-an-accounts-billing-info-token) - Transaction [`create`](https://dev.recurly.com/docs/create-transaction) [block:callout] { "type": "info", "body": "If you use a token, no other attributes will be allowed on that Billing Info\n for that request." } [/block]
Create a new subscription with a token using one of our [client libraries](http://dev.recurly.com/client-libraries) or [API v2](https://dev.recurly.com). [block:code] { "codes": [ { "code": "$subscription = new Recurly_Subscription();\n$subscription->plan_code = 'monthly_subscription';\n\n$subscription->account = new Recurly_Account();\n$subscription->account->account_code = 'pat_smith';\n$subscription->account->first_name = 'Pat';\n$subscription->account->last_name = 'Smith';\n$subscription->account->email = 'pat@enterpriseexecutive.com';\n\n$subscription->account->billing_info = new Recurly_BillingInfo();\n$subscription->account->billing_info->token_id = 'TOKEN_ID';\n\n$subscription->create();", "language": "php" }, { "code": "Recurly::Subscription.create! plan_code: :monthly_subscription,\n account: {\n account_code: 'pat_smith',\n billing_info: { token_id: 'TOKEN_ID' }\n }", "language": "ruby" }, { "code": "subscription = recurly.Subscription(\n plan_code = 'monthly_subscription',\n account = recurly.Account(\n account_code = 'pat_smith',\n billing_info = recurly.BillingInfo(token_id = 'TOKEN_ID')\n )\n)\nsubscription.save()", "language": "python" }, { "code": "var plan = Plans.Get(\"monthly_subscription\");\nvar account = new Account(\"pat_smith\");\nvar billingInfo = new BillingInfo(account) { TokenId = \"TOKEN_ID\" };\nvar subscription = new Subscription(account, plan, \"USD\");\n\nsubscription.Create();", "language": "csharp" }, { "code": "$ curl https://:subdomain.recurly.com/v2/subscriptions \\\n -u API_KEY \\\n -X POST \\\n -d '<?xml version=\"1.0\" encoding=\"UTF-8\"?> \\\n<subscription> \\\n <plan_code>monthly_subscription</plan_code> \\\n <currency>USD</currency> \\\n <account> \\\n <account_code>pat_smith</account_code> \\\n <email>pat@enterpriseexecutive.com</email> \\\n <first_name>Pat</first_name> \\\n <last_name>Smith</last_name> \\\n <billing_info> \\\n <token_id>TOKEN_ID</token_id> \\\n </billing_info> \\\n </account> \\\n</subscription>'\n", "language": "curl" } ] } [/block] Once Recurly.js has stored your customer's sensitive data and given you a token reference, you will have 20 minutes to use it in our [API](https://dev.recurly.com). Expired tokens are permanently removed from the Recurly servers. [block:callout] { "type": "info", "body": "Tokens expire after 20 minutes." } [/block] Tokens can be used to populate any account Billing Info data through our API. Simply assign it to the Billing Info's `token_id` property and we'll do the rest. ### These endpoints accept tokens within Billing Info. - Subscription [`create`](https://dev.recurly.com/docs/create-subscription) - Account [`create`](https://dev.recurly.com/docs/create-an-account), [`update`](https://dev.recurly.com/docs/update-account) - Billing Info [`update`](https://dev.recurly.com/docs/update-an-accounts-billing-info-token) - Transaction [`create`](https://dev.recurly.com/docs/create-transaction) [block:callout] { "type": "info", "body": "If you use a token, no other attributes will be allowed on that Billing Info\n for that request." } [/block]
{"__v":1,"_id":"56fd7e6b5a08190e00084f96","api":{"auth":"required","params":[],"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","url":""},"body":"Listen to events using Emitter methods\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Listen to the 'change' event\\nrecurly.on('change', changeHandler);\\n\\n// But we're feeling indecisive today. Let's detach this event\\nrecurly.off('change', changeHandler);\\n\\n// .once will listen for one event then detach itself\\nrecurly.once('field:submit', function () {\\n  $('#my-payment-form').submit();\\n});\\n\\nfunction changeHandler (state) {\\n  // state.fields\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nExample RecurlyState object\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var recurlyState = {\\n  fields: {\\n    number: {\\n      valid: false,\\n      firstSix: '',\\n      lastFour: '',\\n      brand: 'unknown',\\n      empty: true,\\n      length: 0,\\n      focus: false\\n    },\\n    month: {\\n      valid: false,\\n      empty: true,\\n      length: 0,\\n      focus: false\\n    },\\n    year: {\\n      // same as month\\n    },\\n    cvv: {\\n      // same as month\\n    }\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nA `Recurly` instance is an event emitter, and will emit events throughout the lifecycle of your customer's interaction with your payment form. Events can be attached using the `recurly.on` method and removed using `recurly.off`. The example to the right shows the various ways that you can attach and remove events.\n\n### Event: change\n\n`change` is emitted whenever a customer changes the state of hosted card fields, those that you may not otherwise observe directly with DOM events. For example, if your customer types '4' into the number field, then the state of the number field will change, and the `change` event will emit.\n\nThe `change` event emits a `RecurlyState` object, whose values are demonstrated to the right. This will give you useful insight into the entire state of the recurly-controlled components of your payment form.\n\n### Event: field:submit\n\n`field:submit` is emitted when a user presses the `enter` key while they are focused on a hosted field. Since this action typically submits a form, we recommend performing a payment form submission when this event is emitted.\n\nNote that you can detect the brand of the credit card entered using the \"brand\" field in the state object above.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T18:53:08.841Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"events","sync_unique":"","title":"Events","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Events


Listen to events using Emitter methods [block:code] { "codes": [ { "code": "// Listen to the 'change' event\nrecurly.on('change', changeHandler);\n\n// But we're feeling indecisive today. Let's detach this event\nrecurly.off('change', changeHandler);\n\n// .once will listen for one event then detach itself\nrecurly.once('field:submit', function () {\n $('#my-payment-form').submit();\n});\n\nfunction changeHandler (state) {\n // state.fields\n}", "language": "javascript" } ] } [/block] Example RecurlyState object [block:code] { "codes": [ { "code": "var recurlyState = {\n fields: {\n number: {\n valid: false,\n firstSix: '',\n lastFour: '',\n brand: 'unknown',\n empty: true,\n length: 0,\n focus: false\n },\n month: {\n valid: false,\n empty: true,\n length: 0,\n focus: false\n },\n year: {\n // same as month\n },\n cvv: {\n // same as month\n }\n }\n}", "language": "javascript" } ] } [/block] A `Recurly` instance is an event emitter, and will emit events throughout the lifecycle of your customer's interaction with your payment form. Events can be attached using the `recurly.on` method and removed using `recurly.off`. The example to the right shows the various ways that you can attach and remove events. ### Event: change `change` is emitted whenever a customer changes the state of hosted card fields, those that you may not otherwise observe directly with DOM events. For example, if your customer types '4' into the number field, then the state of the number field will change, and the `change` event will emit. The `change` event emits a `RecurlyState` object, whose values are demonstrated to the right. This will give you useful insight into the entire state of the recurly-controlled components of your payment form. ### Event: field:submit `field:submit` is emitted when a user presses the `enter` key while they are focused on a hosted field. Since this action typically submits a form, we recommend performing a payment form submission when this event is emitted. Note that you can detect the brand of the credit card entered using the "brand" field in the state object above.
Listen to events using Emitter methods [block:code] { "codes": [ { "code": "// Listen to the 'change' event\nrecurly.on('change', changeHandler);\n\n// But we're feeling indecisive today. Let's detach this event\nrecurly.off('change', changeHandler);\n\n// .once will listen for one event then detach itself\nrecurly.once('field:submit', function () {\n $('#my-payment-form').submit();\n});\n\nfunction changeHandler (state) {\n // state.fields\n}", "language": "javascript" } ] } [/block] Example RecurlyState object [block:code] { "codes": [ { "code": "var recurlyState = {\n fields: {\n number: {\n valid: false,\n firstSix: '',\n lastFour: '',\n brand: 'unknown',\n empty: true,\n length: 0,\n focus: false\n },\n month: {\n valid: false,\n empty: true,\n length: 0,\n focus: false\n },\n year: {\n // same as month\n },\n cvv: {\n // same as month\n }\n }\n}", "language": "javascript" } ] } [/block] A `Recurly` instance is an event emitter, and will emit events throughout the lifecycle of your customer's interaction with your payment form. Events can be attached using the `recurly.on` method and removed using `recurly.off`. The example to the right shows the various ways that you can attach and remove events. ### Event: change `change` is emitted whenever a customer changes the state of hosted card fields, those that you may not otherwise observe directly with DOM events. For example, if your customer types '4' into the number field, then the state of the number field will change, and the `change` event will emit. The `change` event emits a `RecurlyState` object, whose values are demonstrated to the right. This will give you useful insight into the entire state of the recurly-controlled components of your payment form. ### Event: field:submit `field:submit` is emitted when a user presses the `enter` key while they are focused on a hosted field. Since this action typically submits a form, we recommend performing a payment form submission when this event is emitted. Note that you can detect the brand of the credit card entered using the "brand" field in the state object above.
{"__v":0,"_id":"56fd7e6b5a08190e00084f97","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<button>Subscribe with PayPal</button>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nPlace a button on your page, then bind its click event to a recurly.paypal call.\n\nRecurly.js supports both traditional credit card and PayPal reference transactions.  A PayPal transaction is handled entirely within the PayPal checkout flow in a new window. Your customer will authorize a transaction within PayPal, then Recurly will record the authorization of the billing agreement and you'll receive a token  just as if your customer had used a credit card directly.  The same Recurly token rules apply when generated by `recurly.paypal`.\n\nYou will need to use the token within our API before it expires, and expired tokens cannot be retrieved.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"As with the rest of Recurly.js, there are no external dependencies. The example uses jQuery to demonstrate binding events, but this can be done any way you wish.\"\n}\n[/block]\n## recurly.paypal (API)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$('button').on('click', function () {\\n  var opts = { description: 'Monthly Subscription' };\\n  recurly.paypal(opts, function (err, token) {\\n    if (err) {\\n      // handle errors using err.code\\n    } else {\\n      // handle success using token.id;\\n    }\\n  });\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nLaunches a new window with a PayPal reference transaction flow, eventually tokenizing the PayPal billing agreement for use within the Recurly API.\n\n### Arguments\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-1\": \"`Object`\",\n    \"0-2\": \"Options to configure the PayPal agreement flow.\",\n    \"0-0\": \"options\",\n    \"1-0\": \"description\",\n    \"2-0\": \"callback\",\n    \"2-1\": \"`Function`\",\n    \"2-2\": \"A callback function to receive the token or any errors.\",\n    \"1-1\": \"`String`\",\n    \"1-2\": \"Agreement description. This may include any text you desire, including pricing information.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\nA callback is always required.\n\n### Callback Arguments\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"err\",\n    \"1-0\": \"token\",\n    \"2-0\": \"id\",\n    \"2-1\": \"`String`\",\n    \"2-2\": \"A token id\",\n    \"1-1\": \"`Object`\",\n    \"1-2\": \"An object containing a token id\",\n    \"0-1\": \"`RecurlyError` or `null`\",\n    \"0-2\": \"A [`RecurlyError`](https://dev.recurly.com/docs/errors-1) if an error occurred; otherwise `null`.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n### Returns\n\nNothing.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T18:54:55.886Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"paypal","sync_unique":"","title":"Paypal","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Paypal


[block:code] { "codes": [ { "code": "<button>Subscribe with PayPal</button>", "language": "html" } ] } [/block] Place a button on your page, then bind its click event to a recurly.paypal call. Recurly.js supports both traditional credit card and PayPal reference transactions. A PayPal transaction is handled entirely within the PayPal checkout flow in a new window. Your customer will authorize a transaction within PayPal, then Recurly will record the authorization of the billing agreement and you'll receive a token just as if your customer had used a credit card directly. The same Recurly token rules apply when generated by `recurly.paypal`. You will need to use the token within our API before it expires, and expired tokens cannot be retrieved. [block:callout] { "type": "info", "body": "As with the rest of Recurly.js, there are no external dependencies. The example uses jQuery to demonstrate binding events, but this can be done any way you wish." } [/block] ## recurly.paypal (API) [block:code] { "codes": [ { "code": "$('button').on('click', function () {\n var opts = { description: 'Monthly Subscription' };\n recurly.paypal(opts, function (err, token) {\n if (err) {\n // handle errors using err.code\n } else {\n // handle success using token.id;\n }\n });\n});", "language": "javascript" } ] } [/block] Launches a new window with a PayPal reference transaction flow, eventually tokenizing the PayPal billing agreement for use within the Recurly API. ### Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-1": "`Object`", "0-2": "Options to configure the PayPal agreement flow.", "0-0": "options", "1-0": "description", "2-0": "callback", "2-1": "`Function`", "2-2": "A callback function to receive the token or any errors.", "1-1": "`String`", "1-2": "Agreement description. This may include any text you desire, including pricing information." }, "cols": 3, "rows": 3 } [/block] A callback is always required. ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "2-1": "`String`", "2-2": "A token id", "1-1": "`Object`", "1-2": "An object containing a token id", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](https://dev.recurly.com/docs/errors-1) if an error occurred; otherwise `null`." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing.
[block:code] { "codes": [ { "code": "<button>Subscribe with PayPal</button>", "language": "html" } ] } [/block] Place a button on your page, then bind its click event to a recurly.paypal call. Recurly.js supports both traditional credit card and PayPal reference transactions. A PayPal transaction is handled entirely within the PayPal checkout flow in a new window. Your customer will authorize a transaction within PayPal, then Recurly will record the authorization of the billing agreement and you'll receive a token just as if your customer had used a credit card directly. The same Recurly token rules apply when generated by `recurly.paypal`. You will need to use the token within our API before it expires, and expired tokens cannot be retrieved. [block:callout] { "type": "info", "body": "As with the rest of Recurly.js, there are no external dependencies. The example uses jQuery to demonstrate binding events, but this can be done any way you wish." } [/block] ## recurly.paypal (API) [block:code] { "codes": [ { "code": "$('button').on('click', function () {\n var opts = { description: 'Monthly Subscription' };\n recurly.paypal(opts, function (err, token) {\n if (err) {\n // handle errors using err.code\n } else {\n // handle success using token.id;\n }\n });\n});", "language": "javascript" } ] } [/block] Launches a new window with a PayPal reference transaction flow, eventually tokenizing the PayPal billing agreement for use within the Recurly API. ### Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-1": "`Object`", "0-2": "Options to configure the PayPal agreement flow.", "0-0": "options", "1-0": "description", "2-0": "callback", "2-1": "`Function`", "2-2": "A callback function to receive the token or any errors.", "1-1": "`String`", "1-2": "Agreement description. This may include any text you desire, including pricing information." }, "cols": 3, "rows": 3 } [/block] A callback is always required. ### Callback Arguments [block:parameters] { "data": { "h-0": "Param", "h-1": "Type", "h-2": "Description", "0-0": "err", "1-0": "token", "2-0": "id", "2-1": "`String`", "2-2": "A token id", "1-1": "`Object`", "1-2": "An object containing a token id", "0-1": "`RecurlyError` or `null`", "0-2": "A [`RecurlyError`](https://dev.recurly.com/docs/errors-1) if an error occurred; otherwise `null`." }, "cols": 3, "rows": 3 } [/block] ### Returns Nothing.
{"__v":0,"_id":"56fd7e6b5a08190e00084f98","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Recurly automates complicated subscriptions, with many factors influencing total subscription price. With this in mind, Recurly.js provides a robust pricing module designed to make determining actual subscription costs as simple and flexible as possible.\n\nA Recurly.js pricing module can be attached to the form we created above, or to any other section of your page meant to display subscription pricing. Let's get to the specifics!\n\n## recurly.Pricing (API)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var pricing = recurly.Pricing();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nCreates a `Pricing` instance.\n\n### No Arguments\n\n### Returns\n\n**recurly.Pricing** a new Pricing instance.\n\n## pricing.attach (API)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<section id=\\\"pricing\\\">\\n  <select data-recurly=\\\"plan\\\">\\n    <option value=\\\"basic\\\">Basic</option>\\n    <option value=\\\"notbasic\\\">Not Basic</option>\\n  </select>\\n  <input type=\\\"text\\\" data-recurly=\\\"coupon\\\">\\n</section>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nUse pricing.attach to bind the <section> to the pricing calculator.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var pricing = recurly.Pricing();\\n\\npricing.attach(document.querySelector('#pricing'));\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThis is the simplest way to use the pricing module. Simply pass a container element, and the pricing module with use all elements with a valid `data-recurly` attribute to determine price. When a value changes, the pricing module will automatically update its values. This allows your customers to manipulate a pricing form at will, and you will be able to react dynamically in any number of ways.\n\n### Arguments\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"container\",\n    \"0-1\": \"`HTMLElement`\",\n    \"0-2\": \"Parent element containing all `data-recurly` elements\",\n    \"h-0\": \"Param\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n### Returns\n\nNothing.\n\n### Elements\n\nElements bound to a pricing module may be for either input or output.\n\nInput elements should be user-manipulable elements like `input` or `select`. If you want to input a value but not let a customer manipulate it, use an `<input type=\"hidden\">`.\n\n### Input Elements\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example Value\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"plan\",\n    \"0-1\": \"`basic`\",\n    \"1-0\": \"plan_quantity\",\n    \"2-0\": \"coupon\",\n    \"3-0\": \"addon\",\n    \"4-0\": \"currency\",\n    \"5-0\": \"country\",\n    \"6-0\": \"postal_code\",\n    \"7-0\": \"tax_code\",\n    \"8-0\": \"vat_number\",\n    \"1-1\": \"`1`\",\n    \"2-1\": \"`15_off`\",\n    \"3-1\": \"`1`\",\n    \"4-1\": \"`USD`\",\n    \"5-1\": \"`US`\",\n    \"5-2\": \"[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.\",\n    \"4-2\": \"[ISO-4217 currency code](http://docs.recurly.com/currencies).\",\n    \"3-2\": \"Addon quantity. To identify the addon being modified, use the `data-recurly-addon` attribute to set the addon code.\",\n    \"2-2\": \"Coupon code.\",\n    \"1-2\": \"Play quantity. Defaults to 1 if not specified.\",\n    \"0-2\": \"Plan code.\",\n    \"6-2\": \"Customer postal code. Used primarily to compute taxes.\",\n    \"7-2\": \"Product tax code.\",\n    \"8-2\": \"Customer VAT number. Used for VAT exclusion.\",\n    \"6-1\": \"`90210`\",\n    \"7-1\": \"`digital`\",\n    \"8-1\": \"`SE0000`\"\n  },\n  \"cols\": 3,\n  \"rows\": 9\n}\n[/block]\nOutput elements should be plain text elements like `output`, `span`, or `div`.\n\n### Output Elements\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example Output\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"total_now\",\n    \"1-0\": \"subtotal_now\",\n    \"2-0\": \"addons_now\",\n    \"3-0\": \"discount_now\",\n    \"4-0\": \"setup_fee_now\",\n    \"5-0\": \"tax_now\",\n    \"6-0\": \"currency_code\",\n    \"7-0\": \"currency_symbol\",\n    \"7-1\": \"`$`, `€`\",\n    \"7-2\": \"Symbolic representation of `currency_code`.\",\n    \"6-1\": \"`USD`, `EUR`\",\n    \"6-2\": \"ISO-4217 currency code.\",\n    \"5-1\": \"`15.00`\",\n    \"5-2\": \"Total subscription taxation.\",\n    \"4-1\": \"`5.00`\",\n    \"4-2\": \"Subscription setup fee total.\",\n    \"3-1\": \"`5.00`\",\n    \"3-2\": \"Amount discounted with coupon use.\",\n    \"2-2\": \"Total addon cost.\",\n    \"2-1\": \"`10.00`\",\n    \"1-1\": \"`90.00`\",\n    \"1-2\": \"Subtotal of the following pricing components.\",\n    \"0-1\": \"`100.00`\",\n    \"0-2\": \"Total subscription cost due now.\"\n  },\n  \"cols\": 3,\n  \"rows\": 8\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"`data-recurly` values ending in `_now` like `subtotal_now` have counterparts ending in `_next`. As you might expect, these correspond to the next billing cycle cost. These values are especially useful for plans with trial periods.\"\n}\n[/block]\n## Events\n\nExample price object emitted by the **change** event.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var pricingState = {\\n  now: {\\n    subtotal: '25.00',\\n    addons: '0.00',\\n    discount: '0.00',\\n    setup_fee: '25.00',\\n    tax: '0.00',\\n    total: '25.00'\\n  },\\n  next: {\\n    subtotal: '10.00',\\n    addons: '0.00',\\n    discount: '0.00',\\n    tax: '0.00',\\n    total: '10.00'\\n  },\\n  base: {\\n    plan: {\\n      setup_fee: '25.00',\\n      unit: '10.00'\\n    },\\n    addons: {\\n      thing1: '14.00', // cost of one 'thing1' addon\\n      thing2: '8.00'\\n    },\\n  },\\n  currency: {\\n    code: 'USD',\\n    symbol: '$'\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nPricing instances emit events when various values are set or the price changes.\n\nA `Pricing` instance itself behaves as an event emitter, where events can be attached using the `pricing.on` method and removed using `pricing.off`, similarly to how events are managed on `recurly`.\n\n### Event: Change\n\n`change` is emitted whenever a pricing module has updated any of its pricing values. You can use this event to update your pricing display, compute total shopping costs, aggregate to analytics, etc.\n\nChange emits a price object, shown in detail to the right.\n\n### Event: set.*\n\n`set.*` events are emitted when specific pricing objects change on a pricing module. For example, when a customer changes their plan, the pricing module will send `set.plan`. This is especially useful for updating checkout previews based on what the customer has selected as one example.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`set.plan`\",\n    \"1-0\": \"`set.price`\",\n    \"2-0\": \"`set.addon`\",\n    \"5-0\": \"`set.currency`\",\n    \"4-0\": \"`set.address`\",\n    \"3-0\": \"`set.coupon`\",\n    \"0-1\": \"Plan object.\",\n    \"1-1\": \"Price object.\",\n    \"2-1\": \"Addon object.\",\n    \"3-1\": \"Coupon object.\",\n    \"4-1\": \"Address object.\",\n    \"5-1\": \"Currency code.\",\n    \"6-0\": \"`set.tax`\",\n    \"6-1\": \"Tax object.\"\n  },\n  \"cols\": 2,\n  \"rows\": 7\n}\n[/block]\n## Pricing API\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var pricing = recurly.Pricing();\\n\\npricing\\n  .plan('basic', { quantity: 1 })\\n  .currency('USD')\\n  .addon('addon1', { quantity: 2 })\\n  .coupon('coop')\\n  .address({\\n    country: 'US',\\n    postal_code: '90210'\\n  })\\n  .tax({\\n    tax_code: 'digital',\\n    vat_number: ''\\n  })\\n  .catch(function (err) {\\n    // err.code\\n  })\\n  .done(function (price) {\\n    // price object as emitted by 'change' event\\n  });\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe pricing module can be manipulated with a set of direct method calls. This is useful if you would like to set up a complex pricing schema for your customers, or would just like to use a more programmatic method of determining subscription price. Events fire just as they normally would when using `pricing.attach`.\n\nNote that Recurly.js's DOM binding is one-way. Thus if you use the Pricing API on a pricing instance already attached to a container, the elements within _will not_ update with your Pricing API calls. If you would like two-way DOM binding, we suggest using a framework such as [AngularJS](https://angularjs.org/) and using the Pricing API without attaching it to a container.\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"The example to the right demonstrates all the ways that a pricing module can be manipulated directly.\"\n}\n[/block]\n### PricingPromise\n\nEach Pricing API method will return a `PricingPromise`. This allows you to chain many asynchronous calls together without having to manage a complex chain of callbacks.\n\nYou don't need to worry much about the internals of a `PricingPromise`, as it is designed to stay out of your way and facilitate asynchronous calls for you.\n\nThe `catch` method, as shown in the example, is used to handle error scenarios, such as when an addon cannot be applied to the selected plan.\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"At the end of a chain of pricing method calls, be sure to call `.done()` as this tells the pricing module to begin calculating, and gives you the subscription price.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T18:58:37.649Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":7,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"pricing","sync_unique":"","title":"Pricing","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Pricing


Recurly automates complicated subscriptions, with many factors influencing total subscription price. With this in mind, Recurly.js provides a robust pricing module designed to make determining actual subscription costs as simple and flexible as possible. A Recurly.js pricing module can be attached to the form we created above, or to any other section of your page meant to display subscription pricing. Let's get to the specifics! ## recurly.Pricing (API) [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();", "language": "javascript" } ] } [/block] Creates a `Pricing` instance. ### No Arguments ### Returns **recurly.Pricing** a new Pricing instance. ## pricing.attach (API) [block:code] { "codes": [ { "code": "<section id=\"pricing\">\n <select data-recurly=\"plan\">\n <option value=\"basic\">Basic</option>\n <option value=\"notbasic\">Not Basic</option>\n </select>\n <input type=\"text\" data-recurly=\"coupon\">\n</section>", "language": "html" } ] } [/block] Use pricing.attach to bind the <section> to the pricing calculator. [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();\n\npricing.attach(document.querySelector('#pricing'));", "language": "javascript" } ] } [/block] This is the simplest way to use the pricing module. Simply pass a container element, and the pricing module with use all elements with a valid `data-recurly` attribute to determine price. When a value changes, the pricing module will automatically update its values. This allows your customers to manipulate a pricing form at will, and you will be able to react dynamically in any number of ways. ### Arguments [block:parameters] { "data": { "0-0": "container", "0-1": "`HTMLElement`", "0-2": "Parent element containing all `data-recurly` elements", "h-0": "Param", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 1 } [/block] ### Returns Nothing. ### Elements Elements bound to a pricing module may be for either input or output. Input elements should be user-manipulable elements like `input` or `select`. If you want to input a value but not let a customer manipulate it, use an `<input type="hidden">`. ### Input Elements [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example Value", "h-2": "Description", "0-0": "plan", "0-1": "`basic`", "1-0": "plan_quantity", "2-0": "coupon", "3-0": "addon", "4-0": "currency", "5-0": "country", "6-0": "postal_code", "7-0": "tax_code", "8-0": "vat_number", "1-1": "`1`", "2-1": "`15_off`", "3-1": "`1`", "4-1": "`USD`", "5-1": "`US`", "5-2": "[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.", "4-2": "[ISO-4217 currency code](http://docs.recurly.com/currencies).", "3-2": "Addon quantity. To identify the addon being modified, use the `data-recurly-addon` attribute to set the addon code.", "2-2": "Coupon code.", "1-2": "Play quantity. Defaults to 1 if not specified.", "0-2": "Plan code.", "6-2": "Customer postal code. Used primarily to compute taxes.", "7-2": "Product tax code.", "8-2": "Customer VAT number. Used for VAT exclusion.", "6-1": "`90210`", "7-1": "`digital`", "8-1": "`SE0000`" }, "cols": 3, "rows": 9 } [/block] Output elements should be plain text elements like `output`, `span`, or `div`. ### Output Elements [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example Output", "h-2": "Description", "0-0": "total_now", "1-0": "subtotal_now", "2-0": "addons_now", "3-0": "discount_now", "4-0": "setup_fee_now", "5-0": "tax_now", "6-0": "currency_code", "7-0": "currency_symbol", "7-1": "`$`, `€`", "7-2": "Symbolic representation of `currency_code`.", "6-1": "`USD`, `EUR`", "6-2": "ISO-4217 currency code.", "5-1": "`15.00`", "5-2": "Total subscription taxation.", "4-1": "`5.00`", "4-2": "Subscription setup fee total.", "3-1": "`5.00`", "3-2": "Amount discounted with coupon use.", "2-2": "Total addon cost.", "2-1": "`10.00`", "1-1": "`90.00`", "1-2": "Subtotal of the following pricing components.", "0-1": "`100.00`", "0-2": "Total subscription cost due now." }, "cols": 3, "rows": 8 } [/block] [block:callout] { "type": "success", "body": "`data-recurly` values ending in `_now` like `subtotal_now` have counterparts ending in `_next`. As you might expect, these correspond to the next billing cycle cost. These values are especially useful for plans with trial periods." } [/block] ## Events Example price object emitted by the **change** event. [block:code] { "codes": [ { "code": "var pricingState = {\n now: {\n subtotal: '25.00',\n addons: '0.00',\n discount: '0.00',\n setup_fee: '25.00',\n tax: '0.00',\n total: '25.00'\n },\n next: {\n subtotal: '10.00',\n addons: '0.00',\n discount: '0.00',\n tax: '0.00',\n total: '10.00'\n },\n base: {\n plan: {\n setup_fee: '25.00',\n unit: '10.00'\n },\n addons: {\n thing1: '14.00', // cost of one 'thing1' addon\n thing2: '8.00'\n },\n },\n currency: {\n code: 'USD',\n symbol: '$'\n }\n}", "language": "javascript" } ] } [/block] Pricing instances emit events when various values are set or the price changes. A `Pricing` instance itself behaves as an event emitter, where events can be attached using the `pricing.on` method and removed using `pricing.off`, similarly to how events are managed on `recurly`. ### Event: Change `change` is emitted whenever a pricing module has updated any of its pricing values. You can use this event to update your pricing display, compute total shopping costs, aggregate to analytics, etc. Change emits a price object, shown in detail to the right. ### Event: set.* `set.*` events are emitted when specific pricing objects change on a pricing module. For example, when a customer changes their plan, the pricing module will send `set.plan`. This is especially useful for updating checkout previews based on what the customer has selected as one example. [block:parameters] { "data": { "0-0": "`set.plan`", "1-0": "`set.price`", "2-0": "`set.addon`", "5-0": "`set.currency`", "4-0": "`set.address`", "3-0": "`set.coupon`", "0-1": "Plan object.", "1-1": "Price object.", "2-1": "Addon object.", "3-1": "Coupon object.", "4-1": "Address object.", "5-1": "Currency code.", "6-0": "`set.tax`", "6-1": "Tax object." }, "cols": 2, "rows": 7 } [/block] ## Pricing API [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();\n\npricing\n .plan('basic', { quantity: 1 })\n .currency('USD')\n .addon('addon1', { quantity: 2 })\n .coupon('coop')\n .address({\n country: 'US',\n postal_code: '90210'\n })\n .tax({\n tax_code: 'digital',\n vat_number: ''\n })\n .catch(function (err) {\n // err.code\n })\n .done(function (price) {\n // price object as emitted by 'change' event\n });", "language": "javascript" } ] } [/block] The pricing module can be manipulated with a set of direct method calls. This is useful if you would like to set up a complex pricing schema for your customers, or would just like to use a more programmatic method of determining subscription price. Events fire just as they normally would when using `pricing.attach`. Note that Recurly.js's DOM binding is one-way. Thus if you use the Pricing API on a pricing instance already attached to a container, the elements within _will not_ update with your Pricing API calls. If you would like two-way DOM binding, we suggest using a framework such as [AngularJS](https://angularjs.org/) and using the Pricing API without attaching it to a container. [block:callout] { "type": "success", "body": "The example to the right demonstrates all the ways that a pricing module can be manipulated directly." } [/block] ### PricingPromise Each Pricing API method will return a `PricingPromise`. This allows you to chain many asynchronous calls together without having to manage a complex chain of callbacks. You don't need to worry much about the internals of a `PricingPromise`, as it is designed to stay out of your way and facilitate asynchronous calls for you. The `catch` method, as shown in the example, is used to handle error scenarios, such as when an addon cannot be applied to the selected plan. [block:callout] { "type": "success", "body": "At the end of a chain of pricing method calls, be sure to call `.done()` as this tells the pricing module to begin calculating, and gives you the subscription price." } [/block]
Recurly automates complicated subscriptions, with many factors influencing total subscription price. With this in mind, Recurly.js provides a robust pricing module designed to make determining actual subscription costs as simple and flexible as possible. A Recurly.js pricing module can be attached to the form we created above, or to any other section of your page meant to display subscription pricing. Let's get to the specifics! ## recurly.Pricing (API) [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();", "language": "javascript" } ] } [/block] Creates a `Pricing` instance. ### No Arguments ### Returns **recurly.Pricing** a new Pricing instance. ## pricing.attach (API) [block:code] { "codes": [ { "code": "<section id=\"pricing\">\n <select data-recurly=\"plan\">\n <option value=\"basic\">Basic</option>\n <option value=\"notbasic\">Not Basic</option>\n </select>\n <input type=\"text\" data-recurly=\"coupon\">\n</section>", "language": "html" } ] } [/block] Use pricing.attach to bind the <section> to the pricing calculator. [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();\n\npricing.attach(document.querySelector('#pricing'));", "language": "javascript" } ] } [/block] This is the simplest way to use the pricing module. Simply pass a container element, and the pricing module with use all elements with a valid `data-recurly` attribute to determine price. When a value changes, the pricing module will automatically update its values. This allows your customers to manipulate a pricing form at will, and you will be able to react dynamically in any number of ways. ### Arguments [block:parameters] { "data": { "0-0": "container", "0-1": "`HTMLElement`", "0-2": "Parent element containing all `data-recurly` elements", "h-0": "Param", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 1 } [/block] ### Returns Nothing. ### Elements Elements bound to a pricing module may be for either input or output. Input elements should be user-manipulable elements like `input` or `select`. If you want to input a value but not let a customer manipulate it, use an `<input type="hidden">`. ### Input Elements [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example Value", "h-2": "Description", "0-0": "plan", "0-1": "`basic`", "1-0": "plan_quantity", "2-0": "coupon", "3-0": "addon", "4-0": "currency", "5-0": "country", "6-0": "postal_code", "7-0": "tax_code", "8-0": "vat_number", "1-1": "`1`", "2-1": "`15_off`", "3-1": "`1`", "4-1": "`USD`", "5-1": "`US`", "5-2": "[ISO 3166-1 alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.", "4-2": "[ISO-4217 currency code](http://docs.recurly.com/currencies).", "3-2": "Addon quantity. To identify the addon being modified, use the `data-recurly-addon` attribute to set the addon code.", "2-2": "Coupon code.", "1-2": "Play quantity. Defaults to 1 if not specified.", "0-2": "Plan code.", "6-2": "Customer postal code. Used primarily to compute taxes.", "7-2": "Product tax code.", "8-2": "Customer VAT number. Used for VAT exclusion.", "6-1": "`90210`", "7-1": "`digital`", "8-1": "`SE0000`" }, "cols": 3, "rows": 9 } [/block] Output elements should be plain text elements like `output`, `span`, or `div`. ### Output Elements [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example Output", "h-2": "Description", "0-0": "total_now", "1-0": "subtotal_now", "2-0": "addons_now", "3-0": "discount_now", "4-0": "setup_fee_now", "5-0": "tax_now", "6-0": "currency_code", "7-0": "currency_symbol", "7-1": "`$`, `€`", "7-2": "Symbolic representation of `currency_code`.", "6-1": "`USD`, `EUR`", "6-2": "ISO-4217 currency code.", "5-1": "`15.00`", "5-2": "Total subscription taxation.", "4-1": "`5.00`", "4-2": "Subscription setup fee total.", "3-1": "`5.00`", "3-2": "Amount discounted with coupon use.", "2-2": "Total addon cost.", "2-1": "`10.00`", "1-1": "`90.00`", "1-2": "Subtotal of the following pricing components.", "0-1": "`100.00`", "0-2": "Total subscription cost due now." }, "cols": 3, "rows": 8 } [/block] [block:callout] { "type": "success", "body": "`data-recurly` values ending in `_now` like `subtotal_now` have counterparts ending in `_next`. As you might expect, these correspond to the next billing cycle cost. These values are especially useful for plans with trial periods." } [/block] ## Events Example price object emitted by the **change** event. [block:code] { "codes": [ { "code": "var pricingState = {\n now: {\n subtotal: '25.00',\n addons: '0.00',\n discount: '0.00',\n setup_fee: '25.00',\n tax: '0.00',\n total: '25.00'\n },\n next: {\n subtotal: '10.00',\n addons: '0.00',\n discount: '0.00',\n tax: '0.00',\n total: '10.00'\n },\n base: {\n plan: {\n setup_fee: '25.00',\n unit: '10.00'\n },\n addons: {\n thing1: '14.00', // cost of one 'thing1' addon\n thing2: '8.00'\n },\n },\n currency: {\n code: 'USD',\n symbol: '$'\n }\n}", "language": "javascript" } ] } [/block] Pricing instances emit events when various values are set or the price changes. A `Pricing` instance itself behaves as an event emitter, where events can be attached using the `pricing.on` method and removed using `pricing.off`, similarly to how events are managed on `recurly`. ### Event: Change `change` is emitted whenever a pricing module has updated any of its pricing values. You can use this event to update your pricing display, compute total shopping costs, aggregate to analytics, etc. Change emits a price object, shown in detail to the right. ### Event: set.* `set.*` events are emitted when specific pricing objects change on a pricing module. For example, when a customer changes their plan, the pricing module will send `set.plan`. This is especially useful for updating checkout previews based on what the customer has selected as one example. [block:parameters] { "data": { "0-0": "`set.plan`", "1-0": "`set.price`", "2-0": "`set.addon`", "5-0": "`set.currency`", "4-0": "`set.address`", "3-0": "`set.coupon`", "0-1": "Plan object.", "1-1": "Price object.", "2-1": "Addon object.", "3-1": "Coupon object.", "4-1": "Address object.", "5-1": "Currency code.", "6-0": "`set.tax`", "6-1": "Tax object." }, "cols": 2, "rows": 7 } [/block] ## Pricing API [block:code] { "codes": [ { "code": "var pricing = recurly.Pricing();\n\npricing\n .plan('basic', { quantity: 1 })\n .currency('USD')\n .addon('addon1', { quantity: 2 })\n .coupon('coop')\n .address({\n country: 'US',\n postal_code: '90210'\n })\n .tax({\n tax_code: 'digital',\n vat_number: ''\n })\n .catch(function (err) {\n // err.code\n })\n .done(function (price) {\n // price object as emitted by 'change' event\n });", "language": "javascript" } ] } [/block] The pricing module can be manipulated with a set of direct method calls. This is useful if you would like to set up a complex pricing schema for your customers, or would just like to use a more programmatic method of determining subscription price. Events fire just as they normally would when using `pricing.attach`. Note that Recurly.js's DOM binding is one-way. Thus if you use the Pricing API on a pricing instance already attached to a container, the elements within _will not_ update with your Pricing API calls. If you would like two-way DOM binding, we suggest using a framework such as [AngularJS](https://angularjs.org/) and using the Pricing API without attaching it to a container. [block:callout] { "type": "success", "body": "The example to the right demonstrates all the ways that a pricing module can be manipulated directly." } [/block] ### PricingPromise Each Pricing API method will return a `PricingPromise`. This allows you to chain many asynchronous calls together without having to manage a complex chain of callbacks. You don't need to worry much about the internals of a `PricingPromise`, as it is designed to stay out of your way and facilitate asynchronous calls for you. The `catch` method, as shown in the example, is used to handle error scenarios, such as when an addon cannot be applied to the selected plan. [block:callout] { "type": "success", "body": "At the end of a chain of pricing method calls, be sure to call `.done()` as this tells the pricing module to begin calculating, and gives you the subscription price." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f99","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Recurly.js bundles a few helpful methods for validating payment information prior to processing. These methods are used when generating tokens, but you can also use them to enhance your form validations and checkout flow.\n\n## recurly.bankAccount.bankInfo (API)\n\nGet additional bank account info\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var lookupData = {\\n  routingNumber: '123456780'\\n};\\nrecurly.bankAccount.bankInfo(lookupData, infoHandler);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe bankInfo method requires a handler like this one\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function infoHandler (err, bankInfo) {\\n  if (err) {\\n    // handle error\\n  } else {\\n    // handle success using bankInfo\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nLooks up additional bank information based from a given routing number. If the routing number supplied is invalid, `invalid-routing-number` will be the error code returned.\n\n### Lookup data\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"routingNumber\",\n    \"0-1\": \"`123456780`\",\n    \"0-2\": \"The routing number for a bank\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n### Bank info data\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Field Name\",\n    \"h-1\": \"Example\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"bank_name\",\n    \"0-1\": \"`Bank of Recurly`\",\n    \"0-2\": \"The name for the found bank\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T19:17:35.326Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":8,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"validation","sync_unique":"","title":"Validation","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Validation


Recurly.js bundles a few helpful methods for validating payment information prior to processing. These methods are used when generating tokens, but you can also use them to enhance your form validations and checkout flow. ## recurly.bankAccount.bankInfo (API) Get additional bank account info [block:code] { "codes": [ { "code": "var lookupData = {\n routingNumber: '123456780'\n};\nrecurly.bankAccount.bankInfo(lookupData, infoHandler);", "language": "javascript" } ] } [/block] The bankInfo method requires a handler like this one [block:code] { "codes": [ { "code": "function infoHandler (err, bankInfo) {\n if (err) {\n // handle error\n } else {\n // handle success using bankInfo\n }\n}", "language": "javascript" } ] } [/block] Looks up additional bank information based from a given routing number. If the routing number supplied is invalid, `invalid-routing-number` will be the error code returned. ### Lookup data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "routingNumber", "0-1": "`123456780`", "0-2": "The routing number for a bank" }, "cols": 3, "rows": 1 } [/block] ### Bank info data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "bank_name", "0-1": "`Bank of Recurly`", "0-2": "The name for the found bank" }, "cols": 3, "rows": 1 } [/block]
Recurly.js bundles a few helpful methods for validating payment information prior to processing. These methods are used when generating tokens, but you can also use them to enhance your form validations and checkout flow. ## recurly.bankAccount.bankInfo (API) Get additional bank account info [block:code] { "codes": [ { "code": "var lookupData = {\n routingNumber: '123456780'\n};\nrecurly.bankAccount.bankInfo(lookupData, infoHandler);", "language": "javascript" } ] } [/block] The bankInfo method requires a handler like this one [block:code] { "codes": [ { "code": "function infoHandler (err, bankInfo) {\n if (err) {\n // handle error\n } else {\n // handle success using bankInfo\n }\n}", "language": "javascript" } ] } [/block] Looks up additional bank information based from a given routing number. If the routing number supplied is invalid, `invalid-routing-number` will be the error code returned. ### Lookup data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "routingNumber", "0-1": "`123456780`", "0-2": "The routing number for a bank" }, "cols": 3, "rows": 1 } [/block] ### Bank info data [block:parameters] { "data": { "h-0": "Field Name", "h-1": "Example", "h-2": "Description", "0-0": "bank_name", "0-1": "`Bank of Recurly`", "0-2": "The name for the found bank" }, "cols": 3, "rows": 1 } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f9a","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Example RecurlyError object.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  name: 'validation',\\n  code: 'validation',\\n  message: 'There was an error validating your request.',\\n  fields: [\\n    'number',\\n    'year'\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nErrors are encapsulated by a `RecurlyError`, which contains a few standard properties to help you diagnose error cases and inform your customers accordingly.\n\nErrors will be thrown if the exception will prevent proper execution. If an error can be recovered, it will be passed to the proper error handling event listener, callback, or `PricingPromise` handler for you to inspect.\n\n### Best Practices\n\nThe `message` property contains diagnostic information intended to help you diagnose problems with the form, and we do not recommend displaying its contents to your customers.\n\nTo provide the best customer experience, we recommend that you provide your own error text to be displayed, based on the error code you receive.\n\n### Error Codes\n\n## Configuration\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Code\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"not-configured\",\n    \"1-0\": \"missing-public-key\",\n    \"2-0\": \"invalid-public-key\",\n    \"3-0\": \"already-configured\",\n    \"4-0\": \"missing-hosted-field-target\",\n    \"5-0\": \"\",\n    \"0-1\": \"This error appears when you try to perform an operation without first calling [`recurly.configure`](#configure).\",\n    \"2-1\": \"Check the `publicKey` to ensure it matches that of your admin app's [API Access section](https://app.recurly.com/go/developer/api_access).\",\n    \"1-1\": \"When you call [`recurly.configure`](#configure), you must do so with a `publicKey` property.\",\n    \"3-1\": \"A recurly instance may only be configured once. Doing so more than once is excessive.\",\n    \"4-1\": \"This is thrown when the target element for a hosted payment field cannot be found on the page. Check the error message to check the selector being used, then check your page to ensure the element is present when `recurly.configure` is called.\",\n    \"5-1\": \"\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n## Tokenization\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Code\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"validation\",\n    \"1-0\": \"invalid-parameter\",\n    \"2-0\": \"api-error\",\n    \"3-0\": \"\",\n    \"1-1\": \"Occurs when a tokenization parameter does not pass our internal validations. Check the `fields` property to determine which fields caused the error.\",\n    \"2-1\": \"A request to the Recurly API has encountered an issue. This too can indicate many possible issues, and we recommend inspecting the `message` and `fields` properties for more information.\",\n    \"3-1\": \"\",\n    \"0-1\": \"A request validation error has occurred. This can indicate many possible issues, and you should check the `fields` property to determine which fields caused the error.\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n## Pricing\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Code\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"not-found\",\n    \"1-0\": \"missing-plan\",\n    \"2-0\": \"invalid-addon\",\n    \"3-0\": \"invalid-currency\",\n    \"4-0\": \"\",\n    \"4-1\": \"\",\n    \"3-1\": \"Similarly, if a currency is requested which is not valid for the selected plan.\",\n    \"2-1\": \"Occurs when an addon is added to a [`Pricing`](#pricing) instance but is not valid for the instance's selected plan.\",\n    \"1-1\": \"A [`Pricing`](#pricing) instance will emit this if a plan has not been specified before trying to set a proeprty that depends on a plan, such as a coupon or addon.\",\n    \"0-1\": \"This happens when a nonexistent plan is requested.\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n## PayPal\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"paypal-not-configured\",\n    \"0-1\": \"In order to perform a PayPal transaction, your site must be configured to accept PayPal reference\",\n    \"1-1\": \"The customer canceled the PayPal agreement flow.\",\n    \"2-1\": \"A generic PayPal error has occurred. Inspect `message` to learn more.\",\n    \"3-1\": \"The bank routing number is not valid\",\n    \"3-0\": \"invalid-routing-number\",\n    \"2-0\": \"paypal-error\",\n    \"1-0\": \"paypal-canceled\",\n    \"h-0\": \"Code\",\n    \"h-1\": \"Description\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T19:19:09.515Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":9,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"errors-1","sync_unique":"","title":"Errors","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Errors


Example RecurlyError object. [block:code] { "codes": [ { "code": "{\n name: 'validation',\n code: 'validation',\n message: 'There was an error validating your request.',\n fields: [\n 'number',\n 'year'\n ]\n}", "language": "json" } ] } [/block] Errors are encapsulated by a `RecurlyError`, which contains a few standard properties to help you diagnose error cases and inform your customers accordingly. Errors will be thrown if the exception will prevent proper execution. If an error can be recovered, it will be passed to the proper error handling event listener, callback, or `PricingPromise` handler for you to inspect. ### Best Practices The `message` property contains diagnostic information intended to help you diagnose problems with the form, and we do not recommend displaying its contents to your customers. To provide the best customer experience, we recommend that you provide your own error text to be displayed, based on the error code you receive. ### Error Codes ## Configuration [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "not-configured", "1-0": "missing-public-key", "2-0": "invalid-public-key", "3-0": "already-configured", "4-0": "missing-hosted-field-target", "5-0": "", "0-1": "This error appears when you try to perform an operation without first calling [`recurly.configure`](#configure).", "2-1": "Check the `publicKey` to ensure it matches that of your admin app's [API Access section](https://app.recurly.com/go/developer/api_access).", "1-1": "When you call [`recurly.configure`](#configure), you must do so with a `publicKey` property.", "3-1": "A recurly instance may only be configured once. Doing so more than once is excessive.", "4-1": "This is thrown when the target element for a hosted payment field cannot be found on the page. Check the error message to check the selector being used, then check your page to ensure the element is present when `recurly.configure` is called.", "5-1": "" }, "cols": 2, "rows": 5 } [/block] ## Tokenization [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "validation", "1-0": "invalid-parameter", "2-0": "api-error", "3-0": "", "1-1": "Occurs when a tokenization parameter does not pass our internal validations. Check the `fields` property to determine which fields caused the error.", "2-1": "A request to the Recurly API has encountered an issue. This too can indicate many possible issues, and we recommend inspecting the `message` and `fields` properties for more information.", "3-1": "", "0-1": "A request validation error has occurred. This can indicate many possible issues, and you should check the `fields` property to determine which fields caused the error." }, "cols": 2, "rows": 3 } [/block] ## Pricing [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "not-found", "1-0": "missing-plan", "2-0": "invalid-addon", "3-0": "invalid-currency", "4-0": "", "4-1": "", "3-1": "Similarly, if a currency is requested which is not valid for the selected plan.", "2-1": "Occurs when an addon is added to a [`Pricing`](#pricing) instance but is not valid for the instance's selected plan.", "1-1": "A [`Pricing`](#pricing) instance will emit this if a plan has not been specified before trying to set a proeprty that depends on a plan, such as a coupon or addon.", "0-1": "This happens when a nonexistent plan is requested." }, "cols": 2, "rows": 4 } [/block] ## PayPal [block:parameters] { "data": { "0-0": "paypal-not-configured", "0-1": "In order to perform a PayPal transaction, your site must be configured to accept PayPal reference", "1-1": "The customer canceled the PayPal agreement flow.", "2-1": "A generic PayPal error has occurred. Inspect `message` to learn more.", "3-1": "The bank routing number is not valid", "3-0": "invalid-routing-number", "2-0": "paypal-error", "1-0": "paypal-canceled", "h-0": "Code", "h-1": "Description" }, "cols": 2, "rows": 4 } [/block]
Example RecurlyError object. [block:code] { "codes": [ { "code": "{\n name: 'validation',\n code: 'validation',\n message: 'There was an error validating your request.',\n fields: [\n 'number',\n 'year'\n ]\n}", "language": "json" } ] } [/block] Errors are encapsulated by a `RecurlyError`, which contains a few standard properties to help you diagnose error cases and inform your customers accordingly. Errors will be thrown if the exception will prevent proper execution. If an error can be recovered, it will be passed to the proper error handling event listener, callback, or `PricingPromise` handler for you to inspect. ### Best Practices The `message` property contains diagnostic information intended to help you diagnose problems with the form, and we do not recommend displaying its contents to your customers. To provide the best customer experience, we recommend that you provide your own error text to be displayed, based on the error code you receive. ### Error Codes ## Configuration [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "not-configured", "1-0": "missing-public-key", "2-0": "invalid-public-key", "3-0": "already-configured", "4-0": "missing-hosted-field-target", "5-0": "", "0-1": "This error appears when you try to perform an operation without first calling [`recurly.configure`](#configure).", "2-1": "Check the `publicKey` to ensure it matches that of your admin app's [API Access section](https://app.recurly.com/go/developer/api_access).", "1-1": "When you call [`recurly.configure`](#configure), you must do so with a `publicKey` property.", "3-1": "A recurly instance may only be configured once. Doing so more than once is excessive.", "4-1": "This is thrown when the target element for a hosted payment field cannot be found on the page. Check the error message to check the selector being used, then check your page to ensure the element is present when `recurly.configure` is called.", "5-1": "" }, "cols": 2, "rows": 5 } [/block] ## Tokenization [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "validation", "1-0": "invalid-parameter", "2-0": "api-error", "3-0": "", "1-1": "Occurs when a tokenization parameter does not pass our internal validations. Check the `fields` property to determine which fields caused the error.", "2-1": "A request to the Recurly API has encountered an issue. This too can indicate many possible issues, and we recommend inspecting the `message` and `fields` properties for more information.", "3-1": "", "0-1": "A request validation error has occurred. This can indicate many possible issues, and you should check the `fields` property to determine which fields caused the error." }, "cols": 2, "rows": 3 } [/block] ## Pricing [block:parameters] { "data": { "h-0": "Code", "h-1": "Description", "0-0": "not-found", "1-0": "missing-plan", "2-0": "invalid-addon", "3-0": "invalid-currency", "4-0": "", "4-1": "", "3-1": "Similarly, if a currency is requested which is not valid for the selected plan.", "2-1": "Occurs when an addon is added to a [`Pricing`](#pricing) instance but is not valid for the instance's selected plan.", "1-1": "A [`Pricing`](#pricing) instance will emit this if a plan has not been specified before trying to set a proeprty that depends on a plan, such as a coupon or addon.", "0-1": "This happens when a nonexistent plan is requested." }, "cols": 2, "rows": 4 } [/block] ## PayPal [block:parameters] { "data": { "0-0": "paypal-not-configured", "0-1": "In order to perform a PayPal transaction, your site must be configured to accept PayPal reference", "1-1": "The customer canceled the PayPal agreement flow.", "2-1": "A generic PayPal error has occurred. Inspect `message` to learn more.", "3-1": "The bank routing number is not valid", "3-0": "invalid-routing-number", "2-0": "paypal-error", "1-0": "paypal-canceled", "h-0": "Code", "h-1": "Description" }, "cols": 2, "rows": 4 } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f9b","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"### Integration examples\n\nWe've prepared a full suite of example integrations for *Ruby*, *Node.js*, *Python*, and *PHP* using popular web frameworks for each language. These examples demonstrate the simplest method of integration, with a no-frills UI.\n\n[Code on GitHub](https://github.com/recurly/recurly-js-examples)\n\n### Integration examples with UI\n\nTo demonstrate the bare minimum to more advanced features of Recurly.js, we've prepared example merchant integrations of varying complexity. These examples also include a fancy UI to get you going with something nice.\n\n[Subscribe with minimal billing Info](https://kale-krate.herokuapp.com/subscribe-minimal)\n\n[Subscribe with more billing Info](https://kale-krate.herokuapp.com/subscribe-more)\n\n[Subscribe with advanced pricing](https://kale-krate.herokuapp.com/subscribe-advanced)\n\n[One-time transactions](https://kale-krate.herokuapp.com/one-time-transaction)\n\n[Update billing info](https://kale-krate.herokuapp.com/update-billing)\n\nThe Kale Krate site is open source. Its backend is written in Ruby with [Sinatra](http://www.sinatrarb.com/) and the [Recurly gem](https://github.com/recurly/recurly-client-ruby). It is deployable out of the box to [Heroku](https://heroku.com).\n\n[Code on GitHub](https://github.com/recurly/kalekrate)","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T19:35:36.709Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":10,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"examples","sync_unique":"","title":"Examples","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Examples


### Integration examples We've prepared a full suite of example integrations for *Ruby*, *Node.js*, *Python*, and *PHP* using popular web frameworks for each language. These examples demonstrate the simplest method of integration, with a no-frills UI. [Code on GitHub](https://github.com/recurly/recurly-js-examples) ### Integration examples with UI To demonstrate the bare minimum to more advanced features of Recurly.js, we've prepared example merchant integrations of varying complexity. These examples also include a fancy UI to get you going with something nice. [Subscribe with minimal billing Info](https://kale-krate.herokuapp.com/subscribe-minimal) [Subscribe with more billing Info](https://kale-krate.herokuapp.com/subscribe-more) [Subscribe with advanced pricing](https://kale-krate.herokuapp.com/subscribe-advanced) [One-time transactions](https://kale-krate.herokuapp.com/one-time-transaction) [Update billing info](https://kale-krate.herokuapp.com/update-billing) The Kale Krate site is open source. Its backend is written in Ruby with [Sinatra](http://www.sinatrarb.com/) and the [Recurly gem](https://github.com/recurly/recurly-client-ruby). It is deployable out of the box to [Heroku](https://heroku.com). [Code on GitHub](https://github.com/recurly/kalekrate)
### Integration examples We've prepared a full suite of example integrations for *Ruby*, *Node.js*, *Python*, and *PHP* using popular web frameworks for each language. These examples demonstrate the simplest method of integration, with a no-frills UI. [Code on GitHub](https://github.com/recurly/recurly-js-examples) ### Integration examples with UI To demonstrate the bare minimum to more advanced features of Recurly.js, we've prepared example merchant integrations of varying complexity. These examples also include a fancy UI to get you going with something nice. [Subscribe with minimal billing Info](https://kale-krate.herokuapp.com/subscribe-minimal) [Subscribe with more billing Info](https://kale-krate.herokuapp.com/subscribe-more) [Subscribe with advanced pricing](https://kale-krate.herokuapp.com/subscribe-advanced) [One-time transactions](https://kale-krate.herokuapp.com/one-time-transaction) [Update billing info](https://kale-krate.herokuapp.com/update-billing) The Kale Krate site is open source. Its backend is written in Ruby with [Sinatra](http://www.sinatrarb.com/) and the [Recurly gem](https://github.com/recurly/recurly-client-ruby). It is deployable out of the box to [Heroku](https://heroku.com). [Code on GitHub](https://github.com/recurly/kalekrate)
{"__v":0,"_id":"56fd7e6b5a08190e00084f9c","api":{"results":{"codes":[{"name":"","code":"{}","language":"json","status":200},{"name":"","code":"{}","language":"json","status":400}]},"settings":"","auth":"required","params":[],"url":""},"body":"Recurly.js supports Chrome, Firefox, Safari, iOS 6+, and IE 9+.\n\nWe're also here to lend a hand on any Recurly.js integration questions! You can get help from us in a handful of ways:\n\n* Find us and other fellow developers in [#recurly](irc://chat.freenode.net:+6697/recurly) on freenode to chat in real-time.\n* Browse and post questions on [Stackoverflow](http://stackoverflow.com/questions/tagged/recurly). We check these regularly.\n* Take a look at the code on [GitHub](https://github.com/recurly/recurly-js). We welcome bug reports through Issues and contributions through Pull Requests.\n\nFor other Recurly related questions, please contact [support@recurly.com](https://support.recurly.com) for help with your account or other general questions.\n\nFor copies of documentation for previous versions of Recurly.js, please contact support.","category":"56fd7e6b5a08190e00084f49","createdAt":"2016-03-01T19:37:11.437Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":11,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"support","sync_unique":"","title":"Support","type":"basic","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

Support


Recurly.js supports Chrome, Firefox, Safari, iOS 6+, and IE 9+. We're also here to lend a hand on any Recurly.js integration questions! You can get help from us in a handful of ways: * Find us and other fellow developers in [#recurly](irc://chat.freenode.net:+6697/recurly) on freenode to chat in real-time. * Browse and post questions on [Stackoverflow](http://stackoverflow.com/questions/tagged/recurly). We check these regularly. * Take a look at the code on [GitHub](https://github.com/recurly/recurly-js). We welcome bug reports through Issues and contributions through Pull Requests. For other Recurly related questions, please contact [support@recurly.com](https://support.recurly.com) for help with your account or other general questions. For copies of documentation for previous versions of Recurly.js, please contact support.
Recurly.js supports Chrome, Firefox, Safari, iOS 6+, and IE 9+. We're also here to lend a hand on any Recurly.js integration questions! You can get help from us in a handful of ways: * Find us and other fellow developers in [#recurly](irc://chat.freenode.net:+6697/recurly) on freenode to chat in real-time. * Browse and post questions on [Stackoverflow](http://stackoverflow.com/questions/tagged/recurly). We check these regularly. * Take a look at the code on [GitHub](https://github.com/recurly/recurly-js). We welcome bug reports through Issues and contributions through Pull Requests. For other Recurly related questions, please contact [support@recurly.com](https://support.recurly.com) for help with your account or other general questions. For copies of documentation for previous versions of Recurly.js, please contact support.
{"__v":0,"_id":"56fd7e6c5a08190e00084fb0","api":{"examples":{"codes":[{"code":"","language":"text"}]},"results":{"codes":[{"name":"","code":"<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n  <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n  <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n  <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n  <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n  <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n  <account_code>1</account_code>\n  <state>active</state>\n  <username nil=\"nil\"></username>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company_name></company_name>\n  <vat_number nil=\"nil\"></vat_number>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <cc_emails>cc1@example.com,cc2@example.com</cc_emails>\n  <address>\n    <address1>123 Main St.</address1>\n    <address2 nil=\"nil\"></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n    <phone nil=\"nil\"></phone>\n  </address>\n  <accept_language nil=\"nil\"></accept_language>\n  <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n  <created_at type=\"datetime\">2015-10-25T12:00:00Z</created_at>\n</account>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"557f45d07eafa719001d1c2b","ref":"","required":false,"desc":"The URL of adjustments for the specified account","default":"","type":"string","name":"adjustments"},{"_id":"557f45d07eafa719001d1c2a","ref":"","required":false,"desc":"The URL of billing info for the specified account","default":"","type":"string","name":"billing_info"},{"_id":"557f45d07eafa719001d1c29","ref":"","required":false,"desc":"The URL of invoices for the specified account","default":"","type":"string","name":"invoices"},{"_id":"55e4aa556f190c1900a40881","ref":"","required":false,"desc":"The URL of the coupon redemption for the specified account","default":"","type":"string","name":"redemption"},{"_id":"55e4aa556f190c1900a40880","ref":"","required":false,"desc":"The URL of subscriptions for the specified account","default":"","type":"string","name":"subscriptions"},{"_id":"55e4aa556f190c1900a4087f","ref":"","required":false,"desc":"The URL of transactions for the specified account","default":"","type":"string","name":"transactions"},{"_id":"55e4aa556f190c1900a4087e","ref":"","required":false,"desc":"The unique identifier of the account","default":"","type":"string","name":"account_code"},{"_id":"55e4aa556f190c1900a4087d","ref":"","required":false,"desc":"The state of accounts to return: `active` or `closed`","default":"","type":"string","name":"state"},{"_id":"55e4aa556f190c1900a4087c","ref":"","required":false,"desc":"The username of the account","default":"","type":"string","name":"username"},{"_id":"55e4aa556f190c1900a4087b","ref":"","required":false,"desc":"The email address of the account","default":"","type":"string","name":"email"},{"_id":"560b18973bcbd80d0077d0c0","ref":"","required":false,"desc":"Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.","default":"","type":"array_string","name":"cc_emails"},{"_id":"55e4aa556f190c1900a4087a","ref":"","required":false,"desc":"The first name of the account","default":"","type":"string","name":"first_name"},{"_id":"55e4aa556f190c1900a40879","ref":"","required":false,"desc":"The last name of the account","default":"","type":"string","name":"last_name"},{"_id":"55e4aa556f190c1900a40878","ref":"","required":false,"desc":"The company name of the account","default":"","type":"string","name":"company_name"},{"_id":"55e4aa556f190c1900a40877","ref":"","required":false,"desc":"The VAT number of the account (to avoid having the VAT applied)","default":"","type":"string","name":"vat_number"},{"_id":"55e4aa556f190c1900a40876","ref":"","required":false,"desc":"The tax status of the account. `true` exempts tax on the account, `false` applies tax on the account","default":"","type":"boolean","name":"tax_exempt"},{"_id":"55e4aa556f190c1900a40875","ref":"","required":false,"desc":"The nested address information of the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`","default":"","type":"object","name":"address"},{"_id":"55e4aa556f190c1900a40874","ref":"","required":false,"desc":"The ISO 639-1 language code from the user's browser, indicating their preferred language and locale","default":"","type":"string","name":"accept_language"},{"_id":"55e4aa556f190c1900a40873","ref":"","required":false,"desc":"The unique token for automatically logging the account in to the hosted management pages. You may automatically log the user into their hosted management pages by directing the user to: `https://:subdomain.recurly.com/account/:hosted_login_token`","default":"","type":"string","name":"hosted_login_token"},{"_id":"55e4aa556f190c1900a40872","ref":"","required":false,"desc":"The DateTime the account was created in Recurly","default":"","type":"datetime","name":"created_at"}],"url":"/accounts"},"body":"","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-08-31T20:16:33.273Z","excerpt":"Accounts are core to managing your customers inside of Recurly. The account object stores the entire Recurly history of your customer and acts as the entry point for working with a customer's billing information, subscription data, transactions, invoices and more.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"account-object","sync_unique":"","title":"Account Object","type":"get","updates":["56cec52444c5700b0095c02b"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getAccount Object

Accounts are core to managing your customers inside of Recurly. The account object stores the entire Recurly history of your customer and acts as the entry point for working with a customer's billing information, subscription data, transactions, invoices and more.

adjustments:
string
The URL of adjustments for the specified account
billing_info:
string
The URL of billing info for the specified account
invoices:
string
The URL of invoices for the specified account
redemption:
string
The URL of the coupon redemption for the specified account
subscriptions:
string
The URL of subscriptions for the specified account
transactions:
string
The URL of transactions for the specified account
account_code:
string
The unique identifier of the account
state:
string
The state of accounts to return: `active` or `closed`
username:
string
The username of the account
email:
string
The email address of the account
cc_emails:
array of strings
Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.
first_name:
string
The first name of the account
last_name:
string
The last name of the account
company_name:
string
The company name of the account
vat_number:
string
The VAT number of the account (to avoid having the VAT applied)
tax_exempt:
boolean
The tax status of the account. `true` exempts tax on the account, `false` applies tax on the account
address:
object
The nested address information of the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`
accept_language:
string
The ISO 639-1 language code from the user's browser, indicating their preferred language and locale
hosted_login_token:
string
The unique token for automatically logging the account in to the hosted management pages. You may automatically log the user into their hosted management pages by directing the user to: `https://:subdomain.recurly.com/account/:hosted_login_token`
created_at:
datetime
The DateTime the account was created in Recurly

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"__v":0,"_id":"56fd7e6c5a08190e00084fb1","api":{"examples":{"codes":[{"language":"php","code":"<?php\n$accounts = Recurly_AccountList::getActive();\nforeach ($accounts as $account) {\n  print \"Account: $account\\n\";\n}\n?>","name":""},{"language":"ruby","code":"Recurly::Account.find_each do |account|\n  puts \"Account: #{account.inspect}\"\nend"},{"language":"python","code":"#client version <= 2.1.5\naccounts = Account.all()\nwhile accounts:\n    for account in accounts:\n        print 'Account: %s' % account\n    try:\n        accounts = accounts.next_page()\n    except PageError:\n        accounts = ()\n\n#client version 2.1.6+\nfor account in Account.all():\n    print 'Account: %s' % account"},{"name":null,"language":"csharp","code":"using System.Linq;\n\nvar accounts = Accounts.List();\nwhile (accounts.Any())\n{\n\tforeach (var account in accounts)\n\t\tConsole.WriteLine(account);\n\taccounts = accounts.Next;\n}"}]},"results":{"codes":[{"name":"","code":"<accounts type=\"array\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n    <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n    <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n    <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n    <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n    <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n    <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n    <account_code>1</account_code>\n    <state>active</state>\n    <username nil=\"nil\"></username>\n    <email>verena@example.com</email>\n    <first_name>Verena</first_name>\n    <last_name>Example</last_name>\n    <company_name></company_name>\n    <vat_number nil=\"nil\"></vat_number>\n    <tax_exempt type=\"boolean\">false</tax_exempt>\n    <cc_emails>cc1@example.com,cc2@example.com</cc_emails>\n    <address>\n      <address1>123 Main St.</address1>\n      <address2 nil=\"nil\"></address2>\n      <city>San Francisco</city>\n      <state>CA</state>\n      <zip>94105</zip>\n      <country>US</country>\n      <phone nil=\"nil\"></phone>\n    </address>\n    <accept_language nil=\"nil\"></accept_language>\n    <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n    <created_at type=\"datetime\">2015-08-25T12:00:00Z</created_at>\n  </account>\n  <!-- Continued... -->\n</accounts>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"56465088054d8f0d00bc76aa","ref":"","required":false,"desc":"The state of accounts to return: \"active\", \"closed\", \"subscriber\", \"non_subscriber\", \"past_due\".","default":"","type":"string","name":"state"},{"_id":"56d8bace7ce7550b00c81d78","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"int","name":"cursor"},{"_id":"56d8bace7ce7550b00c81d77","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"int","name":"per_page"}],"url":"/accounts"},"body":"###Account Query States\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"state\",\n    \"h-1\": \"description\",\n    \"0-0\": \"active\",\n    \"1-0\": \"closed\",\n    \"0-1\": \"Open accounts.\",\n    \"1-1\": \"Accounts that are not open.\",\n    \"2-0\": \"subscriber\",\n    \"2-1\": \"Accounts with subscriptions that are valid for the current time. This includes subscriptions in a trial period.\",\n    \"3-0\": \"non_subscriber\",\n    \"3-1\": \"Accounts without subscriptions that are valid for the current time.\",\n    \"4-0\": \"past_due\",\n    \"4-1\": \"Accounts with invoices that have failed initial collection but still have collection attempts remaining.\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Please note: a queried state and the base state of a returned account may differ. For example, querying for past_due account will not result in a list of accounts with a 'past_due' state (they will either be 'active' or 'closed'). Only base states ('active','closed') will be present in the returned account records.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T21:38:24.720Z","excerpt":"Returns a list of accounts on your site. Results are ordered by the time created, sorted by newest first.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-accounts","sync_unique":"","title":"List Accounts","type":"get","updates":["55f1f9abd4d3160d00439b6c"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Accounts

Returns a list of accounts on your site. Results are ordered by the time created, sorted by newest first.

state:
string
The state of accounts to return: "active", "closed", "subscriber", "non_subscriber", "past_due".
cursor:
integer
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
integer50
Number of records to return per page, up to a maximum of 200.
###Account Query States [block:parameters] { "data": { "h-0": "state", "h-1": "description", "0-0": "active", "1-0": "closed", "0-1": "Open accounts.", "1-1": "Accounts that are not open.", "2-0": "subscriber", "2-1": "Accounts with subscriptions that are valid for the current time. This includes subscriptions in a trial period.", "3-0": "non_subscriber", "3-1": "Accounts without subscriptions that are valid for the current time.", "4-0": "past_due", "4-1": "Accounts with invoices that have failed initial collection but still have collection attempts remaining." }, "cols": 2, "rows": 5 } [/block] [block:callout] { "type": "warning", "body": "Please note: a queried state and the base state of a returned account may differ. For example, querying for past_due account will not result in a list of accounts with a 'past_due' state (they will either be 'active' or 'closed'). Only base states ('active','closed') will be present in the returned account records." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



###Account Query States [block:parameters] { "data": { "h-0": "state", "h-1": "description", "0-0": "active", "1-0": "closed", "0-1": "Open accounts.", "1-1": "Accounts that are not open.", "2-0": "subscriber", "2-1": "Accounts with subscriptions that are valid for the current time. This includes subscriptions in a trial period.", "3-0": "non_subscriber", "3-1": "Accounts without subscriptions that are valid for the current time.", "4-0": "past_due", "4-1": "Accounts with invoices that have failed initial collection but still have collection attempts remaining." }, "cols": 2, "rows": 5 } [/block] [block:callout] { "type": "warning", "body": "Please note: a queried state and the base state of a returned account may differ. For example, querying for past_due account will not result in a list of accounts with a 'past_due' state (they will either be 'active' or 'closed'). Only base states ('active','closed') will be present in the returned account records." } [/block]
{"__v":0,"_id":"56fd7e6c5a08190e00084fb2","api":{"examples":{"codes":[{"name":"","code":"try {\n  $account = Recurly_Account::get('1');\n  print \"Account: $account\\n\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Account not found.\\n\";\n}\n","language":"php"},{"code":"begin\n  account = Recurly::Account.find '1'\n  puts \"Account: #{account.inspect}\"\nrescue Recurly::Resource::NotFound => e\n  puts e.message\nend","language":"ruby"},{"code":"try:\n  account = Account.get('1')\n  print \"Account: %s\" % account\nexcept NotFoundError:\n  print \"Account not found.\\n\"","language":"python"},{"code":"try\n{\n\tvar account = Accounts.Get(\"1\");\n\tConsole.WriteLine(\"Account \" + account);\n}\ncatch (NotFoundException e)\n{\n\tConsole.WriteLine(\"Account not found.\");\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n  <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n  <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n  <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n  <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n  <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n  <account_code>1</account_code>\n  <state>active</state>\n  <username nil=\"nil\"></username>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company_name></company_name>\n  <vat_number nil=\"nil\"></vat_number>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <cc_emails>cc1@example.com,cc2@example.com</cc_emails>\n  <address>\n    <address1>123 Main St.</address1>\n    <address2 nil=\"nil\"></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n    <phone nil=\"nil\"></phone>\n  </address>\n  <accept_language nil=\"nil\"></accept_language>\n  <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n  <created_at type=\"datetime\">2015-08-25T12:00:00Z</created_at>\n</account>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"557f478deb75d80d00af4086","ref":"","required":true,"desc":"The unique account identifier","default":"","type":"string","name":"account_code"}],"url":"/accounts/:account_code"},"body":"","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T21:45:49.420Z","excerpt":"Returns information about a single account.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"get-account","sync_unique":"","title":"Get Account","type":"get","updates":["55bbdd4e1067fc1700510eed"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getGet Account

Returns information about a single account.

account_code:
required
string
The unique account identifier

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6c5a08190e00084fb3","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $account = new Recurly_Account('b6f5783');\n  $account->email = 'verena@example.com';\n  $account->first_name = 'Verena';\n  $account->last_name = 'Example';\n  $account->create();\n\n  print \"Account: $account\\n\";\n\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Account: $e\";\n}","name":""},{"language":"ruby","code":"account = Recurly::Account.create(\n  :account_code => '1',\n  :email        => 'verena@example.com',\n  :first_name   => 'Verena',\n  :last_name    => 'Example'\n)"},{"language":"python","code":"account = Account(account_code='1')\naccount.email = 'verena@example.com'\naccount.first_name = 'Verena'\naccount.last_name = 'Example'\naccount.save()"},{"language":"csharp","code":"var account = new Account(\"1\")\n{\n  Email = \"verena@example.com\",\n  FirstName = \"Verena\",\n  LastName = \"Example\"\n};\naccount.Create();"},{"code":"<account>\n  <account_code>1</account_code>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <address>\n    <address1>123 Main St.</address1>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n  </address>\n</account>","language":"xml"}]},"results":{"codes":[{"status":201,"language":"xml","code":"<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n  <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n  <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n  <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n  <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n  <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n  <account_code>1</account_code>\n  <state>active</state>\n  <username nil=\"nil\"></username>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company_name></company_name>\n  <vat_number nil=\"nil\"></vat_number>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <cc_emails>cc1@example.com,cc2@example.com</cc_emails>\n  <address>\n    <address1>123 Main St.</address1>\n    <address2 nil=\"nil\"></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n    <phone nil=\"nil\"></phone>\n  </address>\n  <accept_language nil=\"nil\"></accept_language>\n  <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n  <created_at type=\"datetime\">2015-10-25T12:00:00Z</created_at>\n</account>","name":""}]},"settings":"","auth":"required","params":[{"_id":"557f3209e211d20d00601425","ref":"","required":true,"desc":"A unique identifier used by your application to identify the account. This code may only contain the following characters: [a-z 0-9 @ - _ .] but it may not begin with a dot character. Max of 50 characters","default":"","type":"string","name":"account_code"},{"_id":"557f3209e211d20d00601424","ref":"","required":false,"desc":"The username for the account, ignore if you do not use usernames. Max of 255 characters","default":"","type":"string","name":"username"},{"_id":"557f3209e211d20d00601423","ref":"","required":false,"desc":"The email address for the account","default":"","type":"string","name":"email"},{"_id":"557f32d1e211d20d00601430","ref":"","required":false,"desc":"The first name for the account. Max of 255 characters","default":"","type":"string","name":"first_name"},{"_id":"557f32d1e211d20d0060142f","ref":"","required":false,"desc":"The last name for the account.  Max of 255 characters","default":"","type":"string","name":"last_name"},{"_id":"557f32d1e211d20d0060142e","ref":"","required":false,"desc":"The company name for the account. Max of 50 characters","default":"","type":"string","name":"company_name"},{"_id":"557f32d1e211d20d0060142d","ref":"","required":false,"desc":"The VAT number to avoid having the VAT applied (if applicable)","default":"","type":"string","name":"vat_number"},{"_id":"557f32d1e211d20d0060142c","ref":"","required":false,"desc":"The tax status for the account","default":"","type":"boolean","name":"tax_exempt"},{"_id":"557f32d1e211d20d0060142b","ref":"","required":false,"desc":"The Avalara AvaTax value that can be passed to identify the customer type for tax purposes. The range of values can be A - R (more info at Avalara). Value is case-sensitive","default":"","type":"string","name":"entity_use_code"},{"_id":"557f32d1e211d20d0060142a","ref":"","required":false,"desc":"The nested billing information. If present, the account will only be created after the billing information is validated","default":"","type":"object","name":"billing_info"},{"_id":"557f32d1e211d20d00601429","ref":"","required":false,"desc":"The nested address information for the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`","default":"","type":"object","name":"address"},{"_id":"557f32d1e211d20d00601428","ref":"","required":false,"desc":"The ISO 639-1 language code from the user's browser, indicating their preferred language and locale","default":"","type":"string","name":"accept_language"},{"_id":"561c362cd308ee0d00749370","ref":"","required":false,"desc":"Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.","default":"","type":"array_string","name":"cc_emails"}],"url":"/accounts"},"body":"","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T20:12:03.880Z","excerpt":"Creates a new account. You may optionally include billing information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-account","sync_unique":"","title":"Create an Account","type":"post","updates":["562908002c0fd9190067da26"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate an Account

Creates a new account. You may optionally include billing information.

account_code:
required
string
A unique identifier used by your application to identify the account. This code may only contain the following characters: [a-z 0-9 @ - _ .] but it may not begin with a dot character. Max of 50 characters
username:
string
The username for the account, ignore if you do not use usernames. Max of 255 characters
email:
string
The email address for the account
first_name:
string
The first name for the account. Max of 255 characters
last_name:
string
The last name for the account. Max of 255 characters
company_name:
string
The company name for the account. Max of 50 characters
vat_number:
string
The VAT number to avoid having the VAT applied (if applicable)
tax_exempt:
boolean
The tax status for the account
entity_use_code:
string
The Avalara AvaTax value that can be passed to identify the customer type for tax purposes. The range of values can be A - R (more info at Avalara). Value is case-sensitive
billing_info:
object
The nested billing information. If present, the account will only be created after the billing information is validated
address:
object
The nested address information for the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`
accept_language:
string
The ISO 639-1 language code from the user's browser, indicating their preferred language and locale
cc_emails:
array of strings
Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6c5a08190e00084fb4","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $account = Recurly_Account::get('b6f5783');\n  $account->company_name = 'New Company Name';\n  $account->update();\n\n  print \"Account: $account\\n\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid account code: $e\";\n}","name":""},{"language":"ruby","code":"account = Recurly::Account.find('account_1')\naccount.company_name = 'New Company Name'\naccount.save"},{"language":"python","code":"account = Account.get('account_1')\naccount.company_name = 'New Company Name'\naccount.save()"},{"language":"csharp","code":"var account = Account.Get(\"account_1\");\naccount.CompanyName = 'New Company Name'\naccount.Update();"},{"language":"xml","code":"<account>\n  <company_name>New Company Name</company_name>\n</account>"}]},"results":{"codes":[{"name":"","code":"<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n  <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n  <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n  <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n  <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n  <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n  <account_code>1</account_code>\n  <state>active</state>\n  <username nil=\"nil\"></username>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company_name>New Company Name</company_name>\n  <vat_number nil=\"nil\"></vat_number>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <cc_emails>cc1@example.com,cc2@example.com</cc_emails>\n  <address>\n    <address1>123 Main St.</address1>\n    <address2 nil=\"nil\"></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n    <phone nil=\"nil\"></phone>\n  </address>\n  <accept_language nil=\"nil\"></accept_language>\n  <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n  <created_at type=\"datetime\">2015-08-25T12:00:00Z</created_at>\n</account>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"557f4a527eafa719001d1c43","ref":"","required":true,"desc":"A unique identifier used by your application to identify the account. This code may only contain the following characters: [a-z 0-9 @ - _ .] but it may not begin with a dot character. Max of 50 characters","default":"","type":"string","name":"account_code"},{"_id":"557f4a527eafa719001d1c42","ref":"","required":false,"desc":"The username for the account, ignore if you do not use usernames. Max of 255 characters","default":"","type":"string","name":"username"},{"_id":"557f4a527eafa719001d1c41","ref":"","required":false,"desc":"The email address for the account","default":"","type":"string","name":"email"},{"_id":"557f4a527eafa719001d1c40","ref":"","required":false,"desc":"The first name for the account. Max of 255 characters","default":"","type":"string","name":"first_name"},{"_id":"557f4a527eafa719001d1c3f","ref":"","required":false,"desc":"The last name for the account. Max of 255 characters","default":"","type":"string","name":"last_name"},{"_id":"557f4a527eafa719001d1c3e","ref":"","required":false,"desc":"The company name for the account. Max of 255 characters","default":"","type":"string","name":"company_name"},{"_id":"557f4a527eafa719001d1c3d","ref":"","required":false,"desc":"The VAT number to avoid having the VAT applied (if applicable)","default":"","type":"string","name":"vat_number"},{"_id":"557f4a527eafa719001d1c3c","ref":"","required":false,"desc":"The tax status for the account","default":"","type":"boolean","name":"tax_exempt"},{"_id":"557f4a527eafa719001d1c3b","ref":"","required":false,"desc":"The Avalara AvaTax value that can be passed to identify the customer type for tax purposes. The range of values can be A - R (more info at Avalara). Value is case-sensitive","default":"","type":"string","name":"entity_use_code"},{"_id":"557f4a527eafa719001d1c3a","ref":"","required":false,"desc":"The nested billing information. If present, the account will only be created after the billing information is validated","default":"","type":"object","name":"billing_info"},{"_id":"557f4a527eafa719001d1c39","ref":"","required":false,"desc":"The nested address information for the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`","default":"","type":"object","name":"address"},{"_id":"557f4a527eafa719001d1c38","ref":"","required":false,"desc":"The ISO 639-1 language code from the user's browser, indicating their preferred language and locale","default":"","type":"string","name":"accept_language"},{"_id":"561c3606d468a60d00f51ebe","ref":"","required":false,"desc":"Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.","default":"","type":"array_string","name":"cc_emails"}],"url":"/accounts/:account_code"},"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Please note\",\n  \"body\": \"You may optionally include billing information when updating an account. If the billing information is provided, the billing information will be validated. The account will only be updated if the billing information is valid.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T21:57:38.556Z","excerpt":"Updates an existing account.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-account","sync_unique":"","title":"Update Account","type":"put","updates":["568ffb69769f210d00132584"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate Account

Updates an existing account.

account_code:
required
string
A unique identifier used by your application to identify the account. This code may only contain the following characters: [a-z 0-9 @ - _ .] but it may not begin with a dot character. Max of 50 characters
username:
string
The username for the account, ignore if you do not use usernames. Max of 255 characters
email:
string
The email address for the account
first_name:
string
The first name for the account. Max of 255 characters
last_name:
string
The last name for the account. Max of 255 characters
company_name:
string
The company name for the account. Max of 255 characters
vat_number:
string
The VAT number to avoid having the VAT applied (if applicable)
tax_exempt:
boolean
The tax status for the account
entity_use_code:
string
The Avalara AvaTax value that can be passed to identify the customer type for tax purposes. The range of values can be A - R (more info at Avalara). Value is case-sensitive
billing_info:
object
The nested billing information. If present, the account will only be created after the billing information is validated
address:
object
The nested address information for the account: `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`
accept_language:
string
The ISO 639-1 language code from the user's browser, indicating their preferred language and locale
cc_emails:
array of strings
Additional email address that should receive account correspondence. These should be separated only by commas. These CC emails will receive all emails that the `email` field also receives.
[block:callout] { "type": "success", "title": "Please note", "body": "You may optionally include billing information when updating an account. If the billing information is provided, the billing information will be validated. The account will only be updated if the billing information is valid." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "success", "title": "Please note", "body": "You may optionally include billing information when updating an account. If the billing information is provided, the billing information will be validated. The account will only be updated if the billing information is valid." } [/block]
{"__v":0,"_id":"56fd7e6c5a08190e00084fb5","api":{"examples":{"codes":[{"name":"","code":"try {\n  $account = Recurly_Account::get('b6f5783');\n  $account->close();\n\n  print \"Account: $account\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid account code: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.destroy","language":"ruby"},{"code":"account = Account.get('1')\naccount.delete()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\naccount.Close();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944ebb5c9eaa2300a86337","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"}],"url":"/accounts/:account_code"},"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Please note\",\n  \"body\": \"Closing an account permanently deletes its billing information and cancels any active subscriptions (canceled subscriptions will remain active until the end of the current billing cycle before expiring).\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T22:00:42.004Z","excerpt":"Marks an account as closed and cancels any active subscriptions.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"close-account","sync_unique":"","title":"Close Account","type":"delete","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteClose Account

Marks an account as closed and cancels any active subscriptions.

account_code:
required
string
Your unique account identifier.
[block:callout] { "type": "success", "title": "Please note", "body": "Closing an account permanently deletes its billing information and cancels any active subscriptions (canceled subscriptions will remain active until the end of the current billing cycle before expiring)." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples



[block:callout] { "type": "success", "title": "Please note", "body": "Closing an account permanently deletes its billing information and cancels any active subscriptions (canceled subscriptions will remain active until the end of the current billing cycle before expiring)." } [/block]
{"__v":0,"_id":"56fd7e6c5a08190e00084fb6","api":{"examples":{"codes":[{"name":"","code":"try {\n  $account = Recurly_Account::get('b6f5783');\n  $account->reopen();\n\n  // Or to fetch and reopen in one call\n  // $account = Recurly_Account::reopenAccount('b6f5783');\n\n  print \"Account: $account\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid account code: $e\";\n} catch (Recurly_ValidationError $e) {\n  print \"Account already open: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find '1'\naccount.reopen","language":"ruby"},{"code":"account = Account.get('1')\naccount.reopen() ","language":"python"},{"code":"var account = Accounts.Get(\"1\");\naccount.Reopen();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\">\n  <adjustments href=\"https://your-subdomain.recurly.com/v2/accounts/1/adjustments\"/>\n  <billing_info href=\"https://your-subdomain.recurly.com/v2/accounts/1/billing_info\"/>\n  <invoices href=\"https://your-subdomain.recurly.com/v2/accounts/1/invoices\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemption\"/>\n  <subscriptions href=\"https://your-subdomain.recurly.com/v2/accounts/1/subscriptions\"/>\n  <transactions href=\"https://your-subdomain.recurly.com/v2/accounts/1/transactions\"/>\n  <account_code>1</account_code>\n  <state>active</state>\n  <username nil=\"nil\"></username>\n  <email>verena@example.com</email>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company_name>New Company Name</company_name>\n  <vat_number nil=\"nil\"></vat_number>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <address>\n    <address1>123 Main St.</address1>\n    <address2 nil=\"nil\"></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94105</zip>\n    <country>US</country>\n    <phone nil=\"nil\"></phone>\n  </address>\n  <accept_language nil=\"nil\"></accept_language>\n  <hosted_login_token>a92468579e9c4231a6c0031c4716c01d</hosted_login_token>\n  <created_at type=\"datetime\">2015-08-25T12:00:00Z</created_at>\n</account>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944ed45c9eaa2300a86339","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"}],"url":"/accounts/:account_code/reopen"},"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Please note\",\n  \"body\": \"Editing an account, creating an account with the same `account_code` as the deleted account, or creating a new transaction or subscription will also reopen an account. Reopening an account will restore its history. Reopening an account does not modify any previously canceled or expired subscriptions and billing information will need to be provided by the customer to continue billing.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T22:03:14.174Z","excerpt":"Transitions a closed account back to active.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"reopen-account","sync_unique":"","title":"Reopen Account","type":"put","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putReopen Account

Transitions a closed account back to active.

account_code:
required
string
Your unique account identifier.
[block:callout] { "type": "success", "title": "Please note", "body": "Editing an account, creating an account with the same `account_code` as the deleted account, or creating a new transaction or subscription will also reopen an account. Reopening an account will restore its history. Reopening an account does not modify any previously canceled or expired subscriptions and billing information will need to be provided by the customer to continue billing." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "success", "title": "Please note", "body": "Editing an account, creating an account with the same `account_code` as the deleted account, or creating a new transaction or subscription will also reopen an account. Reopening an account will restore its history. Reopening an account does not modify any previously canceled or expired subscriptions and billing information will need to be provided by the customer to continue billing." } [/block]
{"__v":0,"_id":"56fd7e6c5a08190e00084fb7","api":{"examples":{"codes":[{"name":"","code":"try {\n  $notes = Recurly_NoteList::get('b6f5783');\n  foreach ($notes as $note) {\n    print \"Note: {$note->message}\\n\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid account code: $e\";\n}","language":"php"},{"code":"try:\n  account = Account.get('1')\n  for note in account.notes():\n   print \"Note: %s\" % note.message\nexcept NotFoundError:\n  print \"Account not found.\\n\"","language":"python"},{"code":"using System.Linq;\n\nvar account = Accounts.Get(\"1\");\nvar notes = account.GetNotes();\nwhile (notes.Any())\n{\n\tforeach (var note in notes)\n\t\tConsole.WriteLine(\"Note: \" + note.Message);\n\tnotes = notes.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<notes type=\"array\">\n  <note>\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <message>This is my second note</message>\n    <created_at type=\"datetime\">2015-08-14T18:53:04Z</created_at>\n  </note>\n  <note>\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <message>This is my first note</message>\n    <created_at type=\"datetime\">2015-08-14T18:52:50Z</created_at>\n  </note>\n  <!-- Continued... -->\n</notes>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944eddccc3052300569882","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"}],"url":"/accounts/:account_code/notes"},"body":"","category":"56fd7e6b5a08190e00084f4a","createdAt":"2015-06-15T22:04:40.352Z","excerpt":"Returns a list of the notes on an account sorted in descending order.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":7,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-account-notes","sync_unique":"","title":"List Account Notes","type":"get","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Account Notes

Returns a list of the notes on an account sorted in descending order.

account_code:
required
string
Your unique account identifier.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f7c","api":{"results":{"codes":[{"status":200,"language":"xml","code":"<adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/626db120a84102b1809909071c701c60\" type=\"charge\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/100\"/>\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n  <uuid>626db120a84102b1809909071c701c60</uuid>\n  <state>invoiced</state>\n  <description>Description of the adjustment</description>\n  <accounting_code>adjustment_ac</accounting_code>\n  <product_code>basic</product_code>\n  <origin>debit</origin>\n  <unit_amount_in_cents type=\"integer\">2000</unit_amount_in_cents>\n  <quantity type=\"integer\">1</quantity>\n  <original_adjustment_uuid>2cc95aa62517e56d5bec3a48afa1b3b9</original_adjustment_uuid>\n  <discount_in_cents type=\"integer\">0</discount_in_cents>\n  <tax_in_cents type=\"integer\">175</tax_in_cents>\n  <total_in_cents type=\"integer\">2175</total_in_cents>\n  <currency>USD</currency>\n  <taxable type=\"boolean\">false</taxable>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0.0875</tax_rate>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <tax_details type=\"array\">\n    <tax_detail>\n      <name>california</name>\n      <type>state</type>\n      <tax_rate type=\"float\">0.065</tax_rate>\n      <tax_in_cents type=\"integer\">130</tax_in_cents>\n    </tax_detail>\n  </tax_details>\n  <start_date type=\"datetime\">2015-02-04T23:13:07Z</start_date>\n  <end_date nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-02-04T23:13:07Z</created_at>\n</adjustment>","name":""}]},"settings":"","auth":"required","params":[{"_id":"55f8905559eace0d0087dc69","ref":"","required":false,"desc":"The type of adjustment to return: `charge` or `credit`","default":"","type":"string","name":"type"},{"_id":"55f88d0560cc850d008a7bae","ref":"","required":false,"desc":"The URL of the account for the specified adjustment","default":"","type":"string","name":"account"},{"_id":"55f88d0560cc850d008a7bad","ref":"","required":false,"desc":"The URL of the invoice for the specified adjustment","default":"","type":"string","name":"invoice"},{"_id":"55f88d0560cc850d008a7bac","ref":"","required":false,"desc":"The unique identifier of the adjustment","default":"","type":"string","name":"uuid"},{"_id":"55f88d0560cc850d008a7bab","ref":"","required":false,"desc":"The state of the adjustments to return: `pending` or `invoiced`.","default":"","type":"string","name":"state"},{"_id":"55f88d0560cc850d008a7baa","ref":"","required":false,"desc":"Description of the adjustment for the adjustment. Max 255 characters","default":"","type":"string","name":"description"},{"_id":"55f88d0560cc850d008a7ba9","ref":"","required":false,"desc":"Accounting code. Max of 20 characters","default":"","type":"string","name":"accounting_code"},{"_id":"55f88d0560cc850d008a7ba8","ref":"","required":false,"desc":"The origin of the adjustment to return: `plan`, `plan_trial`, `setup_fee`, `add_on`, `add_on_trial`, `one_time`, `debit`, `credit`, `coupon`, or `carryforward`","default":"","type":"string","name":"origin"},{"_id":"55f88d0560cc850d008a7ba7","ref":"","required":false,"desc":"Positive amount for a charge, negative amount for a credit. Max 10000000.","default":"","type":"int","name":"unit_amount_in_cents"},{"_id":"55f88d0560cc850d008a7ba6","ref":"","required":false,"desc":"Quantity","default":"1","type":"string","name":"quantity"},{"_id":"55f88d0560cc850d008a7ba5","ref":"","required":false,"desc":"Only shows if adjustment is a credit created from another credit.","default":"","type":"string","name":"original_adjustment_uuid"},{"_id":"55f88d0560cc850d008a7ba4","ref":"","required":false,"desc":"The discount on the adjustment, in cents","default":"","type":"int","name":"discount_in_cents"},{"_id":"55f88d0560cc850d008a7ba3","ref":"","required":false,"desc":"The tax on the adjustment, in cents","default":"","type":"int","name":"tax_in_cents"},{"_id":"55f88d0560cc850d008a7ba2","ref":"","required":false,"desc":"The total amount of the adjustment, in cents.","default":"","type":"int","name":"total_in_cents"},{"_id":"55f88d0560cc850d008a7ba1","ref":"","required":false,"desc":"Currency, 3-letter ISO code","default":"","type":"string","name":"currency"},{"_id":"55f88d0560cc850d008a7ba0","ref":"","required":false,"desc":"`true` if the current adjustment is taxable, `false` if it is not","default":"","type":"boolean","name":"taxable"},{"_id":"55f88d0560cc850d008a7b9f","ref":"","required":false,"desc":"The tax type of the adjustment","default":"","type":"string","name":"tax_type"},{"_id":"55f88d0560cc850d008a7b9e","ref":"","required":false,"desc":"The tax region of the adjustment","default":"","type":"string","name":"tax_region"},{"_id":"55f88d0560cc850d008a7b9d","ref":"","required":false,"desc":"The tax rate of the adjustment","default":"","type":"string","name":"tax_rate"},{"_id":"55f88d0560cc850d008a7b9c","ref":"","required":false,"desc":"`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.","default":"","type":"boolean","name":"tax_exempt"},{"_id":"55f88d0560cc850d008a7b9b","ref":"","required":false,"desc":"The nested address information of the adjustment: `name `, `type`, `tax_rate`, `tax_in_cents`","default":"","type":"array_mixed","name":"tax_details"},{"_id":"55f88d2bb089b71700a8363c","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"55f88d0560cc850d008a7b9a","ref":"","required":false,"desc":"A timestamp associated with when the adjustment began","default":"Today","type":"datetime","name":"start_date"},{"_id":"55f88d0560cc850d008a7b99","ref":"","required":false,"desc":"A timestamp associated with when the adjustment ended","default":"","type":"datetime","name":"end_date"},{"_id":"55f88d0560cc850d008a7b98","ref":"","required":false,"desc":"A timestamp associated with when the adjustment was created","default":"","type":"datetime","name":"created_at"}],"url":"/adjustments"},"body":"","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-09-15T21:26:29.282Z","excerpt":"The history of your customer's Recurly account can be tracked through adjustments, made up of credits and charges.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"adjustment-object","sync_unique":"","title":"Adjustment Object","type":"get","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getAdjustment Object

The history of your customer's Recurly account can be tracked through adjustments, made up of credits and charges.

type:
string
The type of adjustment to return: `charge` or `credit`
account:
string
The URL of the account for the specified adjustment
invoice:
string
The URL of the invoice for the specified adjustment
uuid:
string
The unique identifier of the adjustment
state:
string
The state of the adjustments to return: `pending` or `invoiced`.
description:
string
Description of the adjustment for the adjustment. Max 255 characters
accounting_code:
string
Accounting code. Max of 20 characters
origin:
string
The origin of the adjustment to return: `plan`, `plan_trial`, `setup_fee`, `add_on`, `add_on_trial`, `one_time`, `debit`, `credit`, `coupon`, or `carryforward`
unit_amount_in_cents:
integer
Positive amount for a charge, negative amount for a credit. Max 10000000.
quantity:
string1
Quantity
original_adjustment_uuid:
string
Only shows if adjustment is a credit created from another credit.
discount_in_cents:
integer
The discount on the adjustment, in cents
tax_in_cents:
integer
The tax on the adjustment, in cents
total_in_cents:
integer
The total amount of the adjustment, in cents.
currency:
string
Currency, 3-letter ISO code
taxable:
boolean
`true` if the current adjustment is taxable, `false` if it is not
tax_type:
string
The tax type of the adjustment
tax_region:
string
The tax region of the adjustment
tax_rate:
string
The tax rate of the adjustment
tax_exempt:
boolean
`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.
tax_details:
array of mixed
The nested address information of the adjustment: `name `, `type`, `tax_rate`, `tax_in_cents`
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.
start_date:
datetimeToday
A timestamp associated with when the adjustment began
end_date:
datetime
A timestamp associated with when the adjustment ended
created_at:
datetime
A timestamp associated with when the adjustment was created

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f7d","api":{"examples":{"codes":[{"name":"","code":"try {\n  $adjustments = Recurly_AdjustmentList::get('b6f5783');\n  foreach ($adjustments as $adjustment) {\n    print \"Adjustment: $adjustment\\n\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid account code: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.adjustments.find_each do |adjustment|\n  puts \"Adjustment: #{adjustment.inspect}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\naccount = Account.get('1')\nadjustments = account.adjustments()\nwhile adjustments:\n    for adjustment in adjustments:\n        print 'Adjustment: %s' % adjustment\n    try:\n        adjustments = adjustments.next_page()\n    except PageError:\n        adjustments = ()\n\n#client version 2.1.6+\naccount = Account.get('1')\nfor adjustment in account.adjustments():\n    print 'Adjustment: %s' % adjustment","language":"python"},{"code":"using System.Linq;\n\nvar account = Accounts.Get(\"1\");\nvar adjustments = account.GetAdjustments();\nwhile (adjustments.Any())\n{\n\tforeach (var adjustment in adjustments)\n\t\tConsole.WriteLine(\"Adjustment: \" + adjustment);\n\tadjustments = adjustments.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<adjustments type=\"array\">\n  <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/626db120a84102b1809909071c701c60\" type=\"charge\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/100\"/>\n    <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n    <uuid>626db120a84102b1809909071c701c60</uuid>\n    <state>invoiced</state>\n    <description>One-time Charged Fee</description>\n    <accounting_code nil=\"nil\"/>\n    <product_code>basic</product_code>\n    <origin>debit</origin>\n    <unit_amount_in_cents type=\"integer\">2000</unit_amount_in_cents>\n    <quantity type=\"integer\">1</quantity>\n    <original_adjustment_uuid>2cc95aa62517e56d5bec3a48afa1b3b9</original_adjustment_uuid> <!-- Only shows if adjustment is a credit created from another credit. -->\n    <discount_in_cents type=\"integer\">0</discount_in_cents>\n    <tax_in_cents type=\"integer\">180</tax_in_cents>\n    <total_in_cents type=\"integer\">2180</total_in_cents>\n    <currency>USD</currency>\n    <taxable type=\"boolean\">false</taxable>\n    <tax_exempt type=\"boolean\">false</tax_exempt>\n    <tax_code nil=\"nil\"/>\n    <start_date type=\"datetime\">2011-08-31T03:30:00Z</start_date>\n    <end_date nil=\"nil\"/>\n    <created_at type=\"datetime\">2011-08-31T03:30:00Z</created_at>\n  </adjustment>\n  <!-- Continued... -->\n</adjustments>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/accounts/:account_code/adjustments"},"body":"","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-06-15T22:21:48.674Z","excerpt":"Returns a list of adjustments for a given account. Results are ordered by the time created, sorted by newest first.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-an-accounts-adjustments","sync_unique":"","title":"List an Account's Adjustments","type":"get","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList an Account's Adjustments

Returns a list of adjustments for a given account. Results are ordered by the time created, sorted by newest first.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f7e","api":{"examples":{"codes":[{"name":"","code":"try {\n  $adjustment = Recurly_Adjustment::get('2fded6a3e36e8b56b37007432f8c1b0d');\n  print \"Adjustment: $adjustment\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invalid adjustment uuid: $e\";\n}","language":"php"},{"code":"adjustment = Recurly::Adjustment.find('30498bb2d52bb9037b4d62480eb98b8f')\n","language":"ruby"},{"code":"adjustment = Adjustment.get('30498bb2d52bb9037b4d62480eb98b8f')\n","language":"python"},{"code":"var adjustment = Adjustments.Get(\"30498bb2d52bb9037b4d62480eb98b8f\");\nConsole.WriteLine(\"Adjustment: \" + adjustment);","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/626db120a84102b1809909071c701c60\" type=\"charge\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/100\"/>\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n  <uuid>626db120a84102b1809909071c701c60</uuid>\n  <state>invoiced</state>\n  <description>One-time Charged Fee</description>\n  <accounting_code/>\n  <product_code>basic</product_code>\n  <origin>debit</origin>\n  <unit_amount_in_cents type=\"integer\">2000</unit_amount_in_cents>\n  <quantity type=\"integer\">1</quantity>\n  <original_adjustment_uuid>2cc95aa62517e56d5bec3a48afa1b3b9</original_adjustment_uuid> <!-- Only shows if adjustment is a credit created from another credit. -->\n  <discount_in_cents type=\"integer\">0</discount_in_cents>\n  <tax_in_cents type=\"integer\">175</tax_in_cents>\n  <total_in_cents type=\"integer\">2175</total_in_cents>\n  <currency>USD</currency>\n  <taxable type=\"boolean\">false</taxable>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0.0875</tax_rate>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <tax_details type=\"array\">\n    <tax_detail>\n      <name>california</name>\n      <type>state</type>\n      <tax_rate type=\"float\">0.065</tax_rate>\n      <tax_in_cents type=\"integer\">130</tax_in_cents>\n    </tax_detail>\n    <tax_detail>\n      <name>san mateo county</name>\n      <type>county</type>\n      <tax_rate type=\"float\">0.01</tax_rate>\n      <tax_in_cents type=\"integer\">20</tax_in_cents>\n    </tax_detail>\n    <tax_detail>\n      <name>sf municipal tax</name>\n      <type>city</type>\n      <tax_rate type=\"float\">0.0</tax_rate>\n      <tax_in_cents type=\"integer\">0</tax_in_cents>\n    </tax_detail>\n    <tax_detail>\n      <name nil=\"nil\"/>\n      <type>special</type>\n      <tax_rate type=\"float\">0.0125</tax_rate>\n      <tax_in_cents type=\"integer\">25</tax_in_cents>\n    </tax_detail>\n  </tax_details>\n  <start_date type=\"datetime\">2015-02-04T23:13:07Z</start_date>\n  <end_date nil=\"nil\"/>}}}\n  <created_at type=\"datetime\">2015-02-04T23:13:07Z</created_at>\n</adjustment>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944f4fccc3052300569883","ref":"","required":true,"desc":"The unique identifier for the adjustment","default":"","type":"string","name":"uuid"}],"url":"/adjustments/:uuid"},"body":"","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-06-15T22:24:48.657Z","excerpt":"Returns information about a single adjustment.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"get-an-adjustment","sync_unique":"","title":"Get an Adjustment","type":"get","updates":["55b79c68aea7c8190058b98e"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getGet an Adjustment

Returns information about a single adjustment.

uuid:
required
string
The unique identifier for the adjustment

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f7f","api":{"examples":{"codes":[{"name":"","code":"try {\n  $charge = new Recurly_Adjustment();\n  $charge->account_code = 'b6f5783';\n  $charge->description = 'Charge for extra bandwidth';\n  $charge->unit_amount_in_cents = 5000; // $50.00\n  $charge->currency = 'USD';\n  $charge->quantity = 1;\n  $charge->accounting_code = 'bandwidth';\n  $charge->tax_exempt = false;\n  $charge->create();\n\n  print \"Charge: $charge\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Account not found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.adjustments.create(\n  :description          => 'Charge for extra bandwidth',\n  :unit_amount_in_cents => 50_00,\n  :currency             => 'USD',\n  :quantity             => 1,\n  :accounting_code      => 'bandwidth',\n  :tax_exempt           => false\n)","language":"ruby"},{"code":"account = Account.get('1')\ncharge = Adjustment(\n  description='Charge for extra bandwidth',\n  unit_amount_in_cents=5000,\n  currency='USD',\n  quantity=1,\n  accounting_code='bandwidth',\n  tax_exempt=False\n)\naccount.charge(charge)","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar adjustment = account.NewAdjustment(\n\t\"USD\",                        // currency\n\t5000,                         // unit_amount_in_cents\n\t\"Charge for extra bandwidth\", // description\n\t1,                            // quantity\n\t\"bandwidth\",                  // accounting_code\n\tfalse);                       // tax_exempt\nadjustment.Create();","language":"csharp"},{"code":"<adjustment>\n  <description>Charge for extra bandwidth</description>\n  <unit_amount_in_cents>5000</unit_amount_in_cents>\n  <currency>USD</currency>\n  <quantity>1</quantity>\n  <accounting_code>bandwidth</accounting_code>\n  <tax_exempt>false</tax_exempt>\n</adjustment>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/626db120a84102b1809909071c701c60\" type=\"charge\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <uuid>626db120a84102b1809909071c701c60</uuid>\n  <state>pending</state>\n  <description>Charge for extra bandwidth</description>\n  <accounting_code>bandwidth</accounting_code>\n  <product_code nil=\"nil\"/>\n  <origin>debit</origin>\n  <unit_amount_in_cents type=\"integer\">5000</unit_amount_in_cents>\n  <quantity type=\"integer\">1</quantity>\n  <discount_in_cents type=\"integer\">0</discount_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">5000</total_in_cents>\n  <currency>USD</currency>\n  <taxable type=\"boolean\">false</taxable>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <start_date type=\"datetime\">2015-02-04T23:54:06Z</start_date>\n  <end_date nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-02-04T23:54:06Z</created_at>\n</adjustment>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"557f5188eb75d80d00af40a7","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"557f5188eb75d80d00af40a6","ref":"","required":true,"desc":"Currency, 3-letter ISO code","default":"","type":"string","name":"currency"},{"_id":"557f5188eb75d80d00af40a5","ref":"","required":true,"desc":"Positive amount for a charge, negative amount for a credit. Max 10000000.","default":"","type":"string","name":"unit_amount_in_cents"},{"_id":"557f5188eb75d80d00af40a4","ref":"","required":false,"desc":"Description of the adjustment for the invoice.","default":"","type":"string","name":"description"},{"_id":"557f5188eb75d80d00af40a3","ref":"","required":false,"desc":"Quantity","default":"1","type":"int","name":"quantity"},{"_id":"557f5188eb75d80d00af40a2","ref":"","required":false,"desc":"Accounting code. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"557f5188eb75d80d00af40a1","ref":"","required":false,"desc":"`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.","default":"","type":"boolean","name":"tax_exempt"},{"_id":"557f5188eb75d80d00af40a0","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"55e09fbfa44fae0d0021473e","ref":"","required":false,"desc":"A timestamp associated with when the charge began","default":"Today","type":"timestamp","name":"start_date"},{"_id":"55e09fbfa44fae0d0021473d","ref":"","required":false,"desc":"A timestamp associated with when the charge ended","default":"","type":"timestamp","name":"end_date"}],"url":"/accounts/:account_code/adjustments"},"body":"","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-06-15T22:28:24.162Z","excerpt":"Creates a one-time charge on an account. Charges are not invoiced or collected immediately. Non-invoiced charges will automatically be invoices when the account's subscription renews, or you trigger a collection by posting an invoice. Charges may be removed from an account if they have not been invoiced.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-a-charge-or-credit","sync_unique":"","title":"Create a Charge","type":"post","updates":["55b2f1b5a96deb1900990c6f","565dc7d277f0090d0058196c"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate a Charge

Creates a one-time charge on an account. Charges are not invoiced or collected immediately. Non-invoiced charges will automatically be invoices when the account's subscription renews, or you trigger a collection by posting an invoice. Charges may be removed from an account if they have not been invoiced.

account_code:
required
string
Your unique account identifier.
currency:
required
string
Currency, 3-letter ISO code
unit_amount_in_cents:
required
string
Positive amount for a charge, negative amount for a credit. Max 10000000.
description:
string
Description of the adjustment for the invoice.
quantity:
integer1
Quantity
accounting_code:
string
Accounting code. Max of 20 characters.
tax_exempt:
boolean
`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.
start_date:
timestampToday
A timestamp associated with when the charge began
end_date:
timestamp
A timestamp associated with when the charge ended

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f80","api":{"examples":{"codes":[{"language":"php","code":"$credit = new Recurly_Adjustment();\n$credit->account_code = '1';\n$credit->description = 'Refund for being a great customer';\n$credit->unit_amount_in_cents = -2000; // Negative $20.00.\n$credit->currency = 'USD';\n$credit->quantity = 1;\n$credit->create();","name":""},{"language":"ruby","code":"account = Recurly::Account.find('1')\naccount.adjustments.create(\n  :description          => 'Refund for being a great customer',\n  :unit_amount_in_cents => -20_00,\n  :currency             => 'USD',\n  :quantity             => 1\n)"},{"language":"python","code":"account = Account.get('1')\ncredit = Adjustment(\n  description='Refund for being a great customer',\n  unit_amount_in_cents=-2000,\n  currency='USD',\n  quantity=1\n)\naccount.charge(credit)"},{"language":"csharp","code":"var account = Accounts.Get(\"1\");\nvar adjustment = account.NewAdjustment(\n\t\"USD\",                               // currency\n\t-2000,                               // unit_amount_in_cents\n\t\"Refund for being a great customer\", // description\n\t1);                                  // quantity (default is 1)\nadjustment.Create();"},{"language":"xml","code":"<adjustment>\n  <description>Refund for being a great customer</description>\n  <unit_amount_in_cents>-2000</unit_amount_in_cents>\n  <currency>USD</currency>\n  <quantity>1</quantity>\n</adjustment>"}]},"results":{"codes":[{"name":"","code":"<adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/945a4cb9afd64300b97b138407a51aef\" type=\"credit\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <uuid>945a4cb9afd64300b97b138407a51aef</uuid>\n  <state>pending</state>\n  <description>Refund for being a great customer</description>\n  <accounting_code nil=\"nil\"/>\n  <product_code nil=\"nil\"/>\n  <origin>credit</origin>\n  <unit_amount_in_cents type=\"integer\">-2000</unit_amount_in_cents>\n  <quantity type=\"integer\">1</quantity>\n  <discount_in_cents type=\"integer\">0</discount_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">-2000</total_in_cents>\n  <currency>USD</currency>\n  <taxable type=\"boolean\">false</taxable>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <start_date type=\"datetime\">2015-02-04T23:56:56Z</start_date>\n  <end_date nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-02-04T23:56:56Z</created_at>\n</adjustment>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"557f5188eb75d80d00af40a7","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"557f5188eb75d80d00af40a6","ref":"","required":true,"desc":"Currency, 3-letter ISO code","default":"","type":"string","name":"currency"},{"_id":"557f5188eb75d80d00af40a5","ref":"","required":true,"desc":"Positive amount for a charge, negative amount for a credit. Max 10000000.","default":"","type":"string","name":"unit_amount_in_cents"},{"_id":"557f5188eb75d80d00af40a4","ref":"","required":false,"desc":"Description of the adjustment for the invoice.","default":"","type":"string","name":"description"},{"_id":"557f5188eb75d80d00af40a3","ref":"","required":false,"desc":"Quantity","default":"1","type":"string","name":"quantity"},{"_id":"557f5188eb75d80d00af40a2","ref":"","required":false,"desc":"Accounting code. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"557f5188eb75d80d00af40a1","ref":"","required":false,"desc":"`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.","default":"","type":"boolean","name":"tax_exempt"},{"_id":"557f5188eb75d80d00af40a0","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"55e0dcbda44fae0d0021491f","ref":"","required":false,"desc":"A timestamp associated with when the credit began","default":"Today","type":"timestamp","name":"start_date"},{"_id":"55e0dcbda44fae0d0021491e","ref":"","required":false,"desc":"A timestamp associated with when the credit ended","default":"","type":"timestamp","name":"end_date"}],"url":"/accounts/:account_code/adjustments"},"body":"","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-08-07T19:15:36.088Z","excerpt":"Creates a one-time charge on an account. Charges are not invoiced or collected immediately. Non-invoiced charges will automatically be invoices when the account's subscription renews, or you trigger a collection by posting an invoice. Charges may be removed from an account if they have not been invoiced.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-a-credit","sync_unique":"","title":"Create a Credit","type":"post","updates":["563ce057913e650d00b65f47"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate a Credit

Creates a one-time charge on an account. Charges are not invoiced or collected immediately. Non-invoiced charges will automatically be invoices when the account's subscription renews, or you trigger a collection by posting an invoice. Charges may be removed from an account if they have not been invoiced.

account_code:
required
string
Your unique account identifier.
currency:
required
string
Currency, 3-letter ISO code
unit_amount_in_cents:
required
string
Positive amount for a charge, negative amount for a credit. Max 10000000.
description:
string
Description of the adjustment for the invoice.
quantity:
string1
Quantity
accounting_code:
string
Accounting code. Max of 20 characters.
tax_exempt:
boolean
`true` exempts tax on the charge, `false` applies tax on the charge. If not defined, then defaults to the Plan and Site settings. This attribute does not work for credits (negative adjustments). Credits are always post-tax. Pre-tax discounts should use the Coupons feature.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of `unknown`, `physical`, or `digital`. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.
start_date:
timestampToday
A timestamp associated with when the credit began
end_date:
timestamp
A timestamp associated with when the credit ended

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f81","api":{"examples":{"codes":[{"name":"","code":"try {\n  $adjustment = Recurly_Adjustment::get('626db120a84102b1809909071c701c60');\n  $adjustment->delete();\n\n  print \"Adjustment: $adjustment\";\n} catch (Recurly_NotFoundError $e) {\n  // NotFoundError if invalid uuid or already deleted\n  print \"Invalid adjustment uuid: $e\";\n}\n","language":"php"},{"code":"adjustment = Recurly::Adjustment.find('945a4cb9afd64300b97b138407a51aef')\nadjustment.destroy","language":"ruby"},{"code":"adjustment = Adjustment.get('945a4cb9afd64300b97b138407a51aef')\nadjustment.delete()","language":"python"},{"code":"var adjustment = Adjustments.Get(\"945a4cb9afd64300b97b138407a51aef\");\nadjustment.Delete(","language":"csharp"}]},"results":{"codes":[{"code":"Status: 204 No Content","language":"xml","status":204}]},"settings":"","auth":"required","params":[{"_id":"55944f6a0c33bd0d0005964a","ref":"","required":true,"desc":"The unique identifier for the adjustment","default":"","type":"string","name":"uuid"}],"url":"/adjustments/:uuid"},"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Please note\",\n  \"body\": \"An adjustment may only be deleted if it has not been invoiced.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4b","createdAt":"2015-06-15T23:21:38.993Z","excerpt":"Delete a non-invoiced adjustment from an account.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"delete-an-adjustment","sync_unique":"","title":"Delete an Adjustment","type":"delete","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteDelete an Adjustment

Delete a non-invoiced adjustment from an account.

uuid:
required
string
The unique identifier for the adjustment
[block:callout] { "type": "success", "title": "Please note", "body": "An adjustment may only be deleted if it has not been invoiced." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "success", "title": "Please note", "body": "An adjustment may only be deleted if it has not been invoiced." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f70","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = Recurly_BillingInfo::get('b6f5783');\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account or account\n  // doesn't have billing info\n  print \"Not found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\nbilling_info = account.billing_info","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = account.BillingInfo;","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <vat_number>US1234567890</vat_number>\n  <ip_address>127.0.0.1</ip_address>\n  <ip_address_country>US</ip_address_country>\n  <card_type>Visa</card_type>\n  <year type=\"integer\">2015</year>\n  <month type=\"integer\">11</month>\n  <first_six>411111</first_six>\n  <last_four>1111</last_four>\n</billing_info>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944f815c9eaa2300a8633a","ref":"","required":true,"desc":"Your unique account identifier","default":"","type":"string","name":"account_code"},{"_id":"5581ce0ea5474a0d00d946a1","ref":"","required":false,"desc":"First name","default":"","type":"string","name":"first_name"},{"_id":"5581ce0ea5474a0d00d946a0","ref":"","required":false,"desc":"Last name","default":"","type":"string","name":"last_name"},{"_id":"5646783bc7687d0d00739f3f","ref":"","required":false,"desc":"Company name","default":"","type":"string","name":"company"},{"_id":"5581ce0ea5474a0d00d9469f","ref":"","required":false,"desc":"Address line 1","default":"","type":"string","name":"address1"},{"_id":"5581ce0ea5474a0d00d9469e","ref":"","required":false,"desc":"Address line 2","default":"","type":"string","name":"address2"},{"_id":"5581ce0ea5474a0d00d9469d","ref":"","required":false,"desc":"City","default":"","type":"string","name":"city"},{"_id":"5581ce0ea5474a0d00d94695","ref":"","required":false,"desc":"Credit card number, last four digits","default":"","type":"int","name":"last_four"},{"_id":"5581ce0ea5474a0d00d9469c","ref":"","required":false,"desc":"State","default":"","type":"string","name":"state"},{"_id":"5581ce0ea5474a0d00d9469b","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements)","default":"","type":"string","name":"country"},{"_id":"5581ce0ea5474a0d00d9469a","ref":"","required":false,"desc":"Zip or postal code","default":"","type":"string","name":"zip"},{"_id":"5581ce0ea5474a0d00d94699","ref":"","required":false,"desc":"Customer's VAT number","default":"","type":"string","name":"vat_number"},{"_id":"5581ce0ea5474a0d00d94698","ref":"","required":false,"desc":"Customer's IP address when updating their billing information","default":"","type":"string","name":"ip_address"},{"_id":"5581ce0ea5474a0d00d94697","ref":"","required":false,"desc":"Country of IP address, if known by Recurly","default":"","type":"string","name":"ip_address_country"},{"_id":"5581ce0ea5474a0d00d94696","ref":"","required":false,"desc":"Credit card number, first six digits","default":"","type":"int","name":"first_six"},{"_id":"5581ce0ea5474a0d00d94694","ref":"","required":false,"desc":"Visa, MasterCard, American Express, Discover, JCB, etc","default":"","type":"string","name":"card_type"},{"_id":"5581ce0ea5474a0d00d94693","ref":"","required":false,"desc":"Expiration month","default":"","type":"int","name":"month"},{"_id":"5581ce0ea5474a0d00d94692","ref":"","required":false,"desc":"Expiration year","default":"","type":"int","name":"year"},{"_id":"5581ce0ea5474a0d00d94691","ref":"","required":false,"desc":"PayPal Billing Agreement ID","default":"","type":"string","name":"paypal_billing_agreement_id"},{"_id":"5581ce0ea5474a0d00d94690","ref":"","required":false,"desc":"Amazon Billing Agreement ID","default":"","type":"string","name":"amazon_billing_agreement_id"},{"_id":"5581ce0ea5474a0d00d9468f","ref":"","required":false,"desc":"The name associated with the account. This may be a person's full name or a business name. name_on_account is used instead of first_name and last_name if the payment method is Bank Account.","default":"","type":"string","name":"name_on_account"},{"_id":"5581ce0ea5474a0d00d9468e","ref":"","required":false,"desc":"U.S. bank account routing number","default":"","type":"int","name":"routing_number"},{"_id":"5581ce0ea5474a0d00d9468d","ref":"","required":false,"desc":"Bank account number","default":"","type":"int","name":"account_number"},{"_id":"5581ce0ea5474a0d00d9468c","ref":"","required":false,"desc":"Either 'checking' or 'savings'","default":"","type":"string","name":"account_type"}],"url":"/accounts/:account_code/billing_info"},"body":"","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T19:44:14.605Z","excerpt":"Returns only the account's current billing information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-an-accounts-billing-info","sync_unique":"","title":"Lookup an Account's Billing Info","type":"get","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup an Account's Billing Info

Returns only the account's current billing information.

account_code:
required
string
Your unique account identifier
first_name:
string
First name
last_name:
string
Last name
company:
string
Company name
address1:
string
Address line 1
address2:
string
Address line 2
city:
string
City
last_four:
integer
Credit card number, last four digits
state:
string
State
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements)
zip:
string
Zip or postal code
vat_number:
string
Customer's VAT number
ip_address:
string
Customer's IP address when updating their billing information
ip_address_country:
string
Country of IP address, if known by Recurly
first_six:
integer
Credit card number, first six digits
card_type:
string
Visa, MasterCard, American Express, Discover, JCB, etc
month:
integer
Expiration month
year:
integer
Expiration year
paypal_billing_agreement_id:
string
PayPal Billing Agreement ID
amazon_billing_agreement_id:
string
Amazon Billing Agreement ID
name_on_account:
string
The name associated with the account. This may be a person's full name or a business name. name_on_account is used instead of first_name and last_name if the payment method is Bank Account.
routing_number:
integer
U.S. bank account routing number
account_number:
integer
Bank account number
account_type:
string
Either 'checking' or 'savings'

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f71","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->token_id = '7z6furn4jvb9'; // From Recurly.js\n  $billing_info->create();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account or token is invalid or expired\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  token_id: 'TOKEN_ID'\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.token_id = 'TOKEN_ID'\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.TokenId = \"TOKEN_ID\";\ninfo.Create();","language":"csharp"},{"code":"<billing_info>\n  <token_id>TOKEN_ID</token_id>\n</billing_info>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <card_type>Visa</card_type>\n  <year type=\"integer\">2015</year>\n  <month type=\"integer\">11</month>\n  <first_six>411111</first_six>\n  <last_four>1111</last_four>\n</billing_info>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55944f99ccc3052300569885","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581ced4a5474a0d00d946a5","ref":"","required":false,"desc":"A token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token)","default":"","type":"string","name":"token_id"},{"_id":"56d0e86f40d36e1d00bc14c9","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"}],"url":"/accounts/:account_code/billing_info"},"body":"","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T19:47:32.787Z","excerpt":"Creates an account's Billing Information using a [token generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token). Returns the account's created Billing Information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-accounts-billing-info-token","sync_unique":"","title":"Create an Account's Billing Info (Token)","type":"post","updates":["56799b95239fac0d00c7e019"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate an Account's Billing Info (Token)

Creates an account's Billing Information using a [token generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token). Returns the account's created Billing Information.

account_code:
required
string
Your unique account identifier.
token_id:
string
A token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token)
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f72","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->first_name = 'Verena';\n  $billing_info->last_name = 'Example';\n  $billing_info->number = '4111-1111-1111-1111';\n  $billing_info->verification_value = '123';\n  $billing_info->month = 11;\n  $billing_info->year = 2017;\n  $billing_info->create();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The data or card are invalid\n  print \"Invalid data or card: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  :first_name         => 'Verena',\n  :last_name          => 'Example',\n  :number             => '4111-1111-1111-1111',\n  :verification_value => '123',\n  :month              => 11,\n  :year               => 2015\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.first_name = 'Verena'\nbilling_info.last_name = 'Example'\nbilling_info.number = '4111-1111-1111-1111'\nbilling_info.verification_value = '123'\nbilling_info.month = 11\nbilling_info.year = 2015\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.FirstName = \"Verana\";\ninfo.LastName = \"Example\";\ninfo.CreditCardNumber = \"4111-1111-1111-1111\";\ninfo.VerificationValue = \"123\";\ninfo.ExpirationMonth = 11;\ninfo.ExpirationYear = 2015;\ninfo.Create();","language":"csharp"},{"code":"<billing_info>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <number>4111-1111-1111-1111</number>\n  <verification_value>123</verification_value>\n  <month>11</month>\n  <year>2015</year>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <card_type>Visa</card_type>\n  <year type=\"integer\">2015</year>\n  <month type=\"integer\">11</month>\n  <first_six>411111</first_six>\n  <last_four>1111</last_four>\n</billing_info>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55944fab5c9eaa2300a8633c","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d09a8625220d00429e4d","ref":"","required":true,"desc":"First name","default":"","type":"string","name":"first_name"},{"_id":"5581d09a8625220d00429e4c","ref":"","required":true,"desc":"Last name","default":"","type":"string","name":"last_name"},{"_id":"5581d09a8625220d00429e42","ref":"","required":true,"desc":"Credit card number, spaces and dashes are accepted","default":"","type":"string","name":"number"},{"_id":"5581d09a8625220d00429e41","ref":"","required":true,"desc":"Expiration month","default":"","type":"string","name":"month"},{"_id":"5581d09a8625220d00429e40","ref":"","required":true,"desc":"Expiration year","default":"","type":"string","name":"year"},{"_id":"5581d09a8625220d00429e4b","ref":"","required":false,"desc":"Address line 1, recommended for address validation","default":"","type":"string","name":"address1"},{"_id":"5581d09a8625220d00429e4a","ref":"","required":false,"desc":"Address line 2.","default":"","type":"string","name":"address2"},{"_id":"5581d09a8625220d00429e49","ref":"","required":false,"desc":"City","default":"","type":"string","name":"city"},{"_id":"5581d09a8625220d00429e48","ref":"","required":false,"desc":"State","default":"","type":"string","name":"state"},{"_id":"5581d09a8625220d00429e47","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581d09a8625220d00429e46","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation","default":"","type":"string","name":"zip"},{"_id":"5581d09a8625220d00429e45","ref":"","required":false,"desc":"Phone number","default":"","type":"string","name":"phone"},{"_id":"5581d09a8625220d00429e44","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"56c3c1ce70187b17005f4395","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"},{"_id":"5581d09a8625220d00429e3f","ref":"","required":false,"desc":"Security code or CVV, 3-4 digits **STRONGLY RECOMMENDED**","default":"","type":"string","name":"verification_value"},{"_id":"5581d09a8625220d00429e43","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"}],"url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information.\n\nWhen Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request.\n\nThe required address fields will correspond to the **address requirements** configured for your site.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.\",\n  \"title\": \"Please note\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.\",\n  \"title\": \"Please note\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T19:55:06.712Z","excerpt":"Creates the account's Billing Information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-accounts-billing-info-credit-card","sync_unique":"","title":"Create an Account's Billing Info (Credit Card)","type":"post","updates":["55d336260168850d0073f054","562944f61a92870d0002c301","56bb59bae59a312b00a15bac"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate an Account's Billing Info (Credit Card)

Creates the account's Billing Information.

account_code:
required
string
Your unique account identifier.
first_name:
required
string
First name
last_name:
required
string
Last name
number:
required
string
Credit card number, spaces and dashes are accepted
month:
required
string
Expiration month
year:
required
string
Expiration year
address1:
string
Address line 1, recommended for address validation
address2:
string
Address line 2.
city:
string
City
state:
string
State
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation
phone:
string
Phone number
vat_number:
string
Customer's VAT Number
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.
verification_value:
string
Security code or CVV, 3-4 digits **STRONGLY RECOMMENDED**
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f73","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->name_on_account = 'Acme Inc.';\n  $billing_info->routing_number = '065400137';\n  $billing_info->account_number = '4444000000005555';\n  $billing_info->account_type = 'checking';\n  $billing_info->address1 = '123 Main St.';\n  $billing_info->city = 'San Francisco';\n  $billing_info->state ='CA';\n  $billing_info->country = 'US';\n  $billing_info->zip = '94105';\n  $billing_info->create();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The data or bank account are invalid\n  print \"Invalid data or card: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Account Not Found: $e\";\n}","name":""},{"language":"ruby","code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  name_on_account: 'Acme, Inc.',\n  routing_number: '065400137',\n  account_number: '4444000000005555',\n  address1: '123 Main St.',\n  city: 'San Francisco',\n  state: 'CA',\n  country: 'US',\n  zip: '94105'\n}\naccount.billing_info.save!"},{"language":"python","code":"account = Account.get('1')\nbilling_info = recurly.BillingInfo(\n  name_on_account = 'Acme, Inc.',\n  routing_number = '065400137',\n  account_number = '4444000000005555',\n  account_type = 'checking',\n  address1 = '123 Main St.',\n  city = 'San Francisco',\n  state ='CA',\n  country = 'US',\n  zip = '94105'\n  )\naccount.update_billing_info(billing_info)"},{"language":"csharp","code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.NameOnAccount = \"Acme, Inc.\";\ninfo.RoutingNumber = \"065400137\";\ninfo.AccountNumber = \"4444000000005555\";\ninfo.AccountType = BillingInfo.BankAccountType.Checking;\ninfo.Address1 = \"123 Main St.\";\ninfo.City = \"San Francisco\";\ninfo.State = \"CA\";\ninfo.Country = \"US\";\ninfo.PostalCode = \"94105\";\ninfo.Create();"},{"language":"xml","code":"<billing_info>\n  <name_on_account>Acme, Inc.</name_on_account>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <routing_number>065400137</routing_number>\n  <account_number>4444000000005555</account_number>\n  <account_type>checking</account_type>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"bank_account\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <name_on_account>Acme, Inc.</name_on_account>\n  <first_name nil=\"nil\"></first_name>\n  <last_name nil=\"nil\"></last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone></phone>\n  <vat_number></vat_number>\n  <ip_address nil=\"nil\"></ip_address>\n  <ip_address_country nil=\"nil\"></ip_address_country>\n  <account_type>checking</account_type>\n  <last_four>5555</last_four>\n  <routing_number>065400137</routing_number>\n</billing_info>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55944fbb0c33bd0d0005964b","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d1f08625220d00429e6d","ref":"","required":true,"desc":"The name associated with the account. This may be a person's full name or a business name. This field must be 1 to 50 characters and can include: letters digits space . ' & , -","default":"","type":"string","name":"name_on_account"},{"_id":"5581d1f08625220d00429e63","ref":"","required":true,"desc":"Must be a real U.S. bank account routing number. All routing numbers are 9 digits.","default":"","type":"int","name":"routing_number"},{"_id":"5581d1f08625220d00429e62","ref":"","required":true,"desc":"Bank account number between 4 and 17 digits. We do not validate this number until the first transaction, so we recommend you have the customer confirm their account number.","default":"","type":"int","name":"account_number"},{"_id":"5581d1f08625220d00429e61","ref":"","required":true,"desc":"Either 'checking' or 'savings'","default":"","type":"string","name":"account_type"},{"_id":"5581d1f08625220d00429e6c","ref":"","required":false,"desc":"Address line 1, recommended for address validation. This field has a 50 character max and can include: letters digits space . # / , -","default":"","type":"string","name":"address1"},{"_id":"5581d1f08625220d00429e6b","ref":"","required":false,"desc":"Address line 2, this field has a 50 character max and can include: letters digits space . # / , -","default":"","type":"string","name":"address2"},{"_id":"5581d1f08625220d00429e6a","ref":"","required":false,"desc":"City, this field has a 50 character max and can include: letters digits space . , -","default":"","type":"string","name":"city"},{"_id":"5581d1f08625220d00429e69","ref":"","required":false,"desc":"State, this field has a 2 character max and can be lowercase or uppercase.","default":"","type":"string","name":"state"},{"_id":"5581d1f08625220d00429e68","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements). **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581d1f08625220d00429e67","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation. This field can be just 5 digits or can have an optional additional 4 digits separated by a hyphen (e.g. 12345-6789).","default":"","type":"string","name":"zip"},{"_id":"5581d1f08625220d00429e66","ref":"","required":false,"desc":"Phone number, this field can be 10 digits.","default":"","type":"string","name":"phone"},{"_id":"5581d1f08625220d00429e65","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"5581d1f08625220d00429e64","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"}],"url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when creating Billing Information.\n\nWhen Billing Information is submitted, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request.\n\nThe required address fields will correspond to the **address requirements** configured for your site.\nIf you need to set a back dated subscription authorziation date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the \"bank_account_authorized_at\" attribute.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Please note\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T20:00:48.689Z","excerpt":"Creates the account's Billing Information with Bank Account details. You will need to have the ACH feature on your site for this call to work.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-accounts-billing-info-bank-account","sync_unique":"","title":"Create an Account's Billing Info (Bank Account)","type":"post","updates":["56ec2580df213e1700f77836"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate an Account's Billing Info (Bank Account)

Creates the account's Billing Information with Bank Account details. You will need to have the ACH feature on your site for this call to work.

account_code:
required
string
Your unique account identifier.
name_on_account:
required
string
The name associated with the account. This may be a person's full name or a business name. This field must be 1 to 50 characters and can include: letters digits space . ' & , -
routing_number:
required
integer
Must be a real U.S. bank account routing number. All routing numbers are 9 digits.
account_number:
required
integer
Bank account number between 4 and 17 digits. We do not validate this number until the first transaction, so we recommend you have the customer confirm their account number.
account_type:
required
string
Either 'checking' or 'savings'
address1:
string
Address line 1, recommended for address validation. This field has a 50 character max and can include: letters digits space . # / , -
address2:
string
Address line 2, this field has a 50 character max and can include: letters digits space . # / , -
city:
string
City, this field has a 50 character max and can include: letters digits space . , -
state:
string
State, this field has a 2 character max and can be lowercase or uppercase.
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements). **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation. This field can be just 5 digits or can have an optional additional 4 digits separated by a hyphen (e.g. 12345-6789).
phone:
string
Phone number, this field can be 10 digits.
vat_number:
string
Customer's VAT Number
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when creating Billing Information. When Billing Information is submitted, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. If you need to set a back dated subscription authorziation date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the "bank_account_authorized_at" attribute. [block:callout] { "type": "warning", "title": "Please note", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when creating Billing Information. When Billing Information is submitted, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. If you need to set a back dated subscription authorziation date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the "bank_account_authorized_at" attribute. [block:callout] { "type": "warning", "title": "Please note", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details." } [/block]
{"__v":1,"_id":"5723d8f2110e570e00486c2e","api":{"auth":"required","examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->first_name = 'Verena';\n  $billing_info->last_name = 'Example';\n  $billing_info->paypal_billing_agreement_id = 'BA-0HS87238YB688345C';\n  $billing_info->create();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The paypal billing agreement provided is invalid\n  print \"Invalid paypal billing agreement: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  :first_name         => 'Verena',\n  :last_name          => 'Example',\n  :paypal_billing_agreement_id             => 'BA-0HS87238YB688345C'\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.first_name = 'Verena'\nbilling_info.last_name = 'Example'\nbilling_info.paypal_billing_agreement_id = 'BA-0HS87238YB688345C'\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.FirstName = \"Verana\";\ninfo.LastName = \"Example\";\ninfo.PaypalBillingAgreementId = \"BA-0HS87238YB688345C\";\ninfo.Create();","language":"csharp"},{"code":"<billing_info>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <paypal_billing_agreement_id>BA-0HS87238YB688345C</paypal_billing_agreement_id>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>","language":"xml"}]},"params":[{"_id":"55944fab5c9eaa2300a8633c","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d09a8625220d00429e4d","ref":"","required":true,"desc":"First name","default":"","type":"string","name":"first_name"},{"_id":"5581d09a8625220d00429e4c","ref":"","required":true,"desc":"Last name","default":"","type":"string","name":"last_name"},{"_id":"5581d09a8625220d00429e4b","ref":"","required":false,"desc":"Address line 1, recommended for address validation","default":"","type":"string","name":"address1"},{"_id":"5581d09a8625220d00429e4a","ref":"","required":false,"desc":"Address line 2.","default":"","type":"string","name":"address2"},{"_id":"5581d09a8625220d00429e49","ref":"","required":false,"desc":"City","default":"","type":"string","name":"city"},{"_id":"5581d09a8625220d00429e48","ref":"","required":false,"desc":"State","default":"","type":"string","name":"state"},{"_id":"5581d09a8625220d00429e47","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581d09a8625220d00429e46","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation","default":"","type":"string","name":"zip"},{"_id":"5581d09a8625220d00429e45","ref":"","required":false,"desc":"Phone number","default":"","type":"string","name":"phone"},{"_id":"5723d8f2110e570e00486c2f","ref":"","required":false,"desc":"Paypal's billing agreement","default":"","type":"string","name":"paypal_billing_agreement_id"},{"_id":"5581d09a8625220d00429e44","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"56c3c1ce70187b17005f4395","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"},{"_id":"5581d09a8625220d00429e43","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"}],"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <paypal_billing_agreement_id>BA-0HS87238YB688345C</paypal_billing_agreement_id>\n</billing_info>","language":"xml","status":201}]},"settings":"","url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information.\n\nWhen Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request.\n\nThe required address fields will correspond to the **address requirements** configured for your site.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.\",\n  \"title\": \"Please note\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.\",\n  \"title\": \"Please note\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2016-04-29T21:58:10.697Z","excerpt":"Creates the account's Billing Information using external token for example: Paypal billing agreement","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-accounts-billing-info-using-external-token","sync_unique":"","title":"Create an Account's Billing Info (using external token)","type":"post","updates":[],"user":"56c3c01334df460d00c2beb3","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate an Account's Billing Info (using external token)

Creates the account's Billing Information using external token for example: Paypal billing agreement

account_code:
required
string
Your unique account identifier.
first_name:
required
string
First name
last_name:
required
string
Last name
address1:
string
Address line 1, recommended for address validation
address2:
string
Address line 2.
city:
string
City
state:
string
State
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation
phone:
string
Phone number
paypal_billing_agreement_id:
string
Paypal's billing agreement
vat_number:
string
Customer's VAT Number
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f74","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->token_id = '7z6furn4jvb9'; // From Recurly.js\n  $billing_info->update();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account or token is invalid or expired\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info.token_id = 'TOKEN_ID'\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.token_id = 'TOKEN_ID'\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.TokenId = \"TOKEN_ID\";\ninfo.Update();","language":"csharp"},{"code":"<billing_info>\n  <token_id>TOKEN_ID</token_id>\n</billing_info>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <card_type>Visa</card_type>\n  <year type=\"integer\">2015</year>\n  <month type=\"integer\">11</month>\n  <first_six>411111</first_six>\n  <last_four>1111</last_four>\n</billing_info>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944fca5c9eaa2300a8633e","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d2f8a5474a0d00d946bc","ref":"","required":true,"desc":"A token [generated by Recurly.js.](https://docs.recurly.com/js/#getting-a-token)","default":"","type":"string","name":"token_id"},{"_id":"56d0e7b07c2e100b000afa25","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"}],"url":"/accounts/:account_code/billing_info"},"body":"[Recurly.js](https://js.recurly.com/) allows you to collect customer Billing Information and tokenize it, preventing your servers from having to handle credit card information. When you send these tokens to Recurly through our API, we unpack the token and update Billing Information accordingly.\n\nWhen Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include billing info with your request.","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T20:05:12.621Z","excerpt":"Updates an account's Billing Information using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token). Returns the account's current Billing Information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-an-accounts-billing-info-token","sync_unique":"","title":"Update an Account's Billing Info (Token)","type":"put","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate an Account's Billing Info (Token)

Updates an account's Billing Information using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token). Returns the account's current Billing Information.

account_code:
required
string
Your unique account identifier.
token_id:
required
string
A token [generated by Recurly.js.](https://docs.recurly.com/js/#getting-a-token)
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.
[Recurly.js](https://js.recurly.com/) allows you to collect customer Billing Information and tokenize it, preventing your servers from having to handle credit card information. When you send these tokens to Recurly through our API, we unpack the token and update Billing Information accordingly. When Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include billing info with your request.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[Recurly.js](https://js.recurly.com/) allows you to collect customer Billing Information and tokenize it, preventing your servers from having to handle credit card information. When you send these tokens to Recurly through our API, we unpack the token and update Billing Information accordingly. When Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include billing info with your request.
{"__v":0,"_id":"56fd7e6b5a08190e00084f75","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->first_name = 'Verena';\n  $billing_info->last_name = 'Example';\n  $billing_info->number = '4111-1111-1111-1111';\n  $billing_info->verification_value = '123';\n  $billing_info->month = 11;\n  $billing_info->year = 2017;\n  $billing_info->update();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The data or card are invalid\n  print \"Invalid data or card: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  :first_name         => 'Verena',\n  :last_name          => 'Example',\n  :number             => '4111-1111-1111-1111',\n  :verification_value => '123',\n  :month              => 11,\n  :year               => 2015\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.first_name = 'Verena'\nbilling_info.last_name = 'Example'\nbilling_info.number = '4111-1111-1111-1111'\nbilling_info.verification_value = '123'\nbilling_info.month = 11\nbilling_info.year = 2015\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.FirstName = \"Verana\";\ninfo.LastName = \"Example\";\ninfo.CreditCardNumber = \"4111-111-1111-1111\";\ninfo.VerificationValue = \"123\";\ninfo.ExpirationMonth = 11;\ninfo.ExpirationYear = 2015;\ninfo.Update();","language":"csharp"},{"code":"<billing_info>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <number>4111-1111-1111-1111</number>\n  <verification_value>123</verification_value>\n  <month>11</month>\n  <year>2015</year>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <card_type>Visa</card_type>\n  <year type=\"integer\">2015</year>\n  <month type=\"integer\">11</month>\n  <first_six>411111</first_six>\n  <last_four>1111</last_four>\n</billing_info>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944fdb5c9eaa2300a8633f","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d46f8625220d00429e81","ref":"","required":false,"desc":"First name","default":"","type":"string","name":"first_name"},{"_id":"5581d46f8625220d00429e80","ref":"","required":false,"desc":"Last name","default":"","type":"string","name":"last_name"},{"_id":"5581d46f8625220d00429e7f","ref":"","required":false,"desc":"Address line 1, recommended for address validation","default":"","type":"string","name":"address1"},{"_id":"5581d46f8625220d00429e7e","ref":"","required":false,"desc":"Address line 2","default":"","type":"string","name":"address2"},{"_id":"5581d46f8625220d00429e7d","ref":"","required":false,"desc":"City","default":"","type":"string","name":"city"},{"_id":"5581d46f8625220d00429e7c","ref":"","required":false,"desc":"State","default":"","type":"string","name":"state"},{"_id":"5581d46f8625220d00429e7b","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581d46f8625220d00429e7a","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation","default":"","type":"string","name":"zip"},{"_id":"5581d46f8625220d00429e79","ref":"","required":false,"desc":"Phone number","default":"","type":"string","name":"phone"},{"_id":"5581d46f8625220d00429e78","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"5581d46f8625220d00429e76","ref":"","required":false,"desc":"Credit card number, spaces and dashes are accepted","default":"","type":"string","name":"number"},{"_id":"5581d46f8625220d00429e75","ref":"","required":false,"desc":"Expiration month","default":"","type":"string","name":"month"},{"_id":"5581d46f8625220d00429e74","ref":"","required":false,"desc":"Expiration year","default":"","type":"string","name":"year"},{"_id":"5581d46f8625220d00429e73","ref":"","required":false,"desc":"Security code or CVV, 3-4 digits **STRONGLY RECOMMENDED**","default":"","type":"string","name":"verification_value"},{"_id":"5581d46f8625220d00429e77","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"},{"_id":"56c3c273c0c4630d004e86a8","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"}],"url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when updating Billing Information. Non PCI sensitive billing info can be updated by api without re-submitting the token. This can be done in two ways: 1)Through the billing info api (docs. link: https://docs.recurly.com/api/billing-info#update-billing-info-credit-card ) whereby you submit only the information that needs to be updated. In that way, all other information remains unchanged on the account. 2) Providing the end user a unique url link to their billing info page, where they can update their own billing info securly. This link can be found in the configuration window of the subscriber's account. https://SUBDOMAIN.recurly.com/accounts/:account_code/edit. You will see a hosted billing information URL that takes the user to their billing site hosted by Recurly.\n\nWhen Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information.\n\nIf you want to create an account at the same time, you should use the [Account API](https://docs.recurly.com/api/accounts#create-account) end-point instead and include Billing Information with your request.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Please note\",\n  \"body\": \"This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details. You can, however, use this API call to update the billing address associated with an account.\",\n  \"title\": \"Please note\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T20:11:27.639Z","excerpt":"Returns the account's updated Billing Information.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-an-accounts-billing-info-credit-card","sync_unique":"","title":"Update an Account's Billing Info (Credit Card)","type":"put","updates":["55d337a4f77e6d0d00b1afab","562945ab1a92870d0002c302"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate an Account's Billing Info (Credit Card)

Returns the account's updated Billing Information.

account_code:
required
string
Your unique account identifier.
first_name:
string
First name
last_name:
string
Last name
address1:
string
Address line 1, recommended for address validation
address2:
string
Address line 2
city:
string
City
state:
string
State
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation
phone:
string
Phone number
vat_number:
string
Customer's VAT Number
number:
string
Credit card number, spaces and dashes are accepted
month:
string
Expiration month
year:
string
Expiration year
verification_value:
string
Security code or CVV, 3-4 digits **STRONGLY RECOMMENDED**
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.
Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when updating Billing Information. Non PCI sensitive billing info can be updated by api without re-submitting the token. This can be done in two ways: 1)Through the billing info api (docs. link: https://docs.recurly.com/api/billing-info#update-billing-info-credit-card ) whereby you submit only the information that needs to be updated. In that way, all other information remains unchanged on the account. 2) Providing the end user a unique url link to their billing info page, where they can update their own billing info securly. This link can be found in the configuration window of the subscriber's account. https://SUBDOMAIN.recurly.com/accounts/:account_code/edit. You will see a hosted billing information URL that takes the user to their billing site hosted by Recurly. When Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API](https://docs.recurly.com/api/accounts#create-account) end-point instead and include Billing Information with your request. [block:callout] { "type": "warning", "title": "Please note", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information." } [/block] [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details. You can, however, use this API call to update the billing address associated with an account.", "title": "Please note" } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when updating Billing Information. Non PCI sensitive billing info can be updated by api without re-submitting the token. This can be done in two ways: 1)Through the billing info api (docs. link: https://docs.recurly.com/api/billing-info#update-billing-info-credit-card ) whereby you submit only the information that needs to be updated. In that way, all other information remains unchanged on the account. 2) Providing the end user a unique url link to their billing info page, where they can update their own billing info securly. This link can be found in the configuration window of the subscriber's account. https://SUBDOMAIN.recurly.com/accounts/:account_code/edit. You will see a hosted billing information URL that takes the user to their billing site hosted by Recurly. When Billing Information is updated, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API](https://docs.recurly.com/api/accounts#create-account) end-point instead and include Billing Information with your request. [block:callout] { "type": "warning", "title": "Please note", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information." } [/block] [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details. You can, however, use this API call to update the billing address associated with an account.", "title": "Please note" } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f76","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->name_on_account = 'Acme Inc.';\n  $billing_info->routing_number = '065400137';\n  $billing_info->account_number = '4444000000005555';\n  $billing_info->account_type = 'checking';\n  $billing_info->address1 = '123 Main St.';\n  $billing_info->city = 'San Francisco';\n  $billing_info->state ='CA';\n  $billing_info->country = 'US';\n  $billing_info->zip = '94105';\n  $billing_info->update();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The data or bank account are invalid\n  print \"Invalid data or card: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Account Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  name_on_account: 'Acme, Inc.',\n  routing_number: '065400137',\n  account_number: '4444000000005555',\n  address1: '123 Main St.',\n  city: 'San Francisco',\n  state: 'CA',\n  country: 'US',\n  zip: '94105'\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.name_on_account = 'Acme, Inc.'\nbilling_info.routing_number = '065400137'\nbilling_info.account_number = '4444000000005555'\nbilling_info.account_type = 'checking'\nbilling_info.address1 = '123 Main St.'\nbilling_info.city = 'San Francisco'\nbilling_info.state ='CA'\nbilling_info.country = 'US'\nbilling_info.zip = '94105'\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = account.BillingInfo;\ninfo.NameOnAccount = \"Acme, Inc.\";\ninfo.RoutingNumber = \"065400137\";\ninfo.AccountNumber = \"4444000000005555\";\ninfo.AccountType = BillingInfo.BankAccountType.Checking;\ninfo.Address1 = \"123 Main St.\";\ninfo.City = \"San Francisco\";\ninfo.State = \"CA\";\ninfo.Country = \"US\";\ninfo.PostalCode = \"94105\";\ninfo.Update();","language":"csharp"},{"code":"<billing_info>\n  <name_on_account>Acme, Inc.</name_on_account>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <routing_number>065400137</routing_number>\n  <account_number>4444000000005555</account_number>\n  <account_type>checking</account_type>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"bank_account\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <name_on_account>Acme, Inc.</name_on_account>\n  <first_name nil=\"nil\"></first_name>\n  <last_name nil=\"nil\"></last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone></phone>\n  <vat_number></vat_number>\n  <ip_address nil=\"nil\"></ip_address>\n  <ip_address_country nil=\"nil\"></ip_address_country>\n  <account_type>checking</account_type>\n  <last_four>5555</last_four>\n  <routing_number>065400137</routing_number>\n</billing_info>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55944ff05c9eaa2300a86341","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581dafd8625220d00429ea7","ref":"","required":true,"desc":"The name associated with the account. This may be a person's full name or a business name. This field must be 1 to 50 characters and can include: letters digits space . ' & , -","default":"","type":"string","name":"name_on_account"},{"_id":"5581dafd8625220d00429e9d","ref":"","required":true,"desc":"Must be a real U.S. bank account routing number. All routing numbers are 9 digits.","default":"","type":"int","name":"routing_number"},{"_id":"5581dafd8625220d00429e9c","ref":"","required":true,"desc":"Bank account number between 4 and 17 digits. We do not validate this number until the first transaction, so we recommend you have the customer confirm their account number.","default":"","type":"int","name":"account_number"},{"_id":"5581dafd8625220d00429e9b","ref":"","required":true,"desc":"Either 'checking' or 'savings'","default":"","type":"int","name":"account_type"},{"_id":"5581dafd8625220d00429ea6","ref":"","required":false,"desc":"Address line 1, recommended for address validation. This field has a 50 character max and can include: letters digits space . # / , -","default":"","type":"string","name":"address1"},{"_id":"5581dafd8625220d00429ea5","ref":"","required":false,"desc":"Address line 2, this field has a 50 character max and can include: letters digits space . # / , -","default":"","type":"string","name":"address2"},{"_id":"5581dafd8625220d00429ea4","ref":"","required":false,"desc":"City, this field has a 50 character max and can include: letters digits space . , -","default":"","type":"string","name":"city"},{"_id":"5581dafd8625220d00429ea3","ref":"","required":false,"desc":"State, this field has a 2 character max and can be lowercase or uppercase.","default":"","type":"string","name":"state"},{"_id":"5581dafd8625220d00429ea2","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements). **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581dafd8625220d00429ea1","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation. This field can be just 5 digits or can have an optional additional 4 digits separated by a hyphen (e.g. 12345-6789).","default":"","type":"string","name":"zip"},{"_id":"5581dafd8625220d00429ea0","ref":"","required":false,"desc":"Phone number, this field can be 10 digits.","default":"","type":"string","name":"phone"},{"_id":"5581dafd8625220d00429e9f","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"5581dafd8625220d00429e9e","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"}],"url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when updating Billing Information.\n\nWhen Billing Information is updated, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request.\n\nIf you need to set a back dated subscription authorization date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the \"bank_account_authorized_at\" attribute.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details. You can, however, use this API call to update the billing address associated with an account.\",\n  \"title\": \"Please note\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T20:39:25.270Z","excerpt":"Returns the account's updated Billing Information. You will need to have the ACH feature on your site for this call to work.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":7,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-an-accounts-billing-info-bank-account","sync_unique":"","title":"Update an Account's Billing Info (Bank Account)","type":"put","updates":["55d336d80168850d0073f056","55d33926f77e6d0d00b1afb5"],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate an Account's Billing Info (Bank Account)

Returns the account's updated Billing Information. You will need to have the ACH feature on your site for this call to work.

account_code:
required
string
Your unique account identifier.
name_on_account:
required
string
The name associated with the account. This may be a person's full name or a business name. This field must be 1 to 50 characters and can include: letters digits space . ' & , -
routing_number:
required
integer
Must be a real U.S. bank account routing number. All routing numbers are 9 digits.
account_number:
required
integer
Bank account number between 4 and 17 digits. We do not validate this number until the first transaction, so we recommend you have the customer confirm their account number.
account_type:
required
integer
Either 'checking' or 'savings'
address1:
string
Address line 1, recommended for address validation. This field has a 50 character max and can include: letters digits space . # / , -
address2:
string
Address line 2, this field has a 50 character max and can include: letters digits space . # / , -
city:
string
City, this field has a 50 character max and can include: letters digits space . , -
state:
string
State, this field has a 2 character max and can be lowercase or uppercase.
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements). **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation. This field can be just 5 digits or can have an optional additional 4 digits separated by a hyphen (e.g. 12345-6789).
phone:
string
Phone number, this field can be 10 digits.
vat_number:
string
Customer's VAT Number
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when updating Billing Information. When Billing Information is updated, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. If you need to set a back dated subscription authorization date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the "bank_account_authorized_at" attribute. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details. You can, however, use this API call to update the billing address associated with an account.", "title": "Please note" } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full bank account and address information when updating Billing Information. When Billing Information is updated, it is only saved if the required fields are provided and they meet the field validation requirements. If the account has a past due invoice, the outstanding balance will be collected when the Billing Information is updated. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. If you need to set a back dated subscription authorization date for the NACHA three year re-authorization rule, do so on the Create Subscription call using the "bank_account_authorized_at" attribute. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's bank account details. You can, however, use this API call to update the billing address associated with an account.", "title": "Please note" } [/block]
{"__v":1,"_id":"5723d958110e570e00486c31","api":{"auth":"required","examples":{"codes":[{"name":"","code":"try {\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->account_code = 'b6f5783';\n  $billing_info->first_name = 'Verena';\n  $billing_info->last_name = 'Example';\n  $billing_info->paypal_billing_agreement_id = 'BA-0HS87238YB688345C';\n  $billing_info->create();\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_ValidationError $e) {\n  // The paypal billing agreement provided is invalid\n  print \"Invalid paypal billing agreement: $e\";\n} catch (Recurly_NotFoundError $e) {\n  // Could not find account\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.billing_info = {\n  :first_name         => 'Verena',\n  :last_name          => 'Example',\n  :paypal_billing_agreement_id             => 'BA-0HS87238YB688345C'\n}\naccount.billing_info.save!","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nbilling_info.first_name = 'Verena'\nbilling_info.last_name = 'Example'\nbilling_info.paypal_billing_agreement_id = 'BA-0HS87238YB688345C'\nbilling_info.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar info = new BillingInfo(account);\ninfo.FirstName = \"Verana\";\ninfo.LastName = \"Example\";\ninfo.PaypalBillingAgreementId = \"BA-0HS87238YB688345C\";\ninfo.Create();","language":"csharp"},{"code":"<billing_info>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <paypal_billing_agreement_id>BA-0HS87238YB688345C</paypal_billing_agreement_id>\n  <ip_address>127.0.0.1</ip_address>\n</billing_info>","language":"xml"}]},"params":[{"_id":"55944fab5c9eaa2300a8633c","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"},{"_id":"5581d09a8625220d00429e4d","ref":"","required":true,"desc":"First name","default":"","type":"string","name":"first_name"},{"_id":"5581d09a8625220d00429e4c","ref":"","required":true,"desc":"Last name","default":"","type":"string","name":"last_name"},{"_id":"5581d09a8625220d00429e4b","ref":"","required":false,"desc":"Address line 1, recommended for address validation","default":"","type":"string","name":"address1"},{"_id":"5581d09a8625220d00429e4a","ref":"","required":false,"desc":"Address line 2.","default":"","type":"string","name":"address2"},{"_id":"5581d09a8625220d00429e49","ref":"","required":false,"desc":"City","default":"","type":"string","name":"city"},{"_id":"5581d09a8625220d00429e48","ref":"","required":false,"desc":"State","default":"","type":"string","name":"state"},{"_id":"5581d09a8625220d00429e47","ref":"","required":false,"desc":"Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**","default":"","type":"string","name":"country"},{"_id":"5581d09a8625220d00429e46","ref":"","required":false,"desc":"Zip or postal code, recommended for address validation","default":"","type":"string","name":"zip"},{"_id":"5581d09a8625220d00429e45","ref":"","required":false,"desc":"Phone number","default":"","type":"string","name":"phone"},{"_id":"5723d8f2110e570e00486c2f","ref":"","required":false,"desc":"Paypal's billing agreement","default":"","type":"string","name":"paypal_billing_agreement_id"},{"_id":"5581d09a8625220d00429e44","ref":"","required":false,"desc":"Customer's VAT Number","default":"","type":"string","name":"vat_number"},{"_id":"56c3c1ce70187b17005f4395","ref":"","required":false,"desc":"Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.","default":"","type":"string","name":"currency"},{"_id":"5581d09a8625220d00429e43","ref":"","required":false,"desc":"Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**","default":"","type":"string","name":"ip_address"}],"results":{"codes":[{"name":"","code":"<billing_info href=\"http://api.test.host/v2/accounts/1/billing_info\" type=\"credit_card\">\n  <account href=\"http://api.test.host/v2/accounts/1\"/>\n  <first_name>Verena</first_name>\n  <last_name>Example</last_name>\n  <company nil=\"nil\"></company>\n  <address1>123 Main St.</address1>\n  <address2 nil=\"nil\"></address2>\n  <city>San Francisco</city>\n  <state>CA</state>\n  <zip>94105</zip>\n  <country>US</country>\n  <phone nil=\"nil\"></phone>\n  <paypal_billing_agreement_id>BA-0HS87238YB688345C</paypal_billing_agreement_id>\n</billing_info>","language":"xml","status":201}]},"settings":"","url":"/accounts/:account_code/billing_info"},"body":"Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information.\n\nWhen Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information.\n\nIf you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request.\n\nThe required address fields will correspond to the **address requirements** configured for your site.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.\",\n  \"title\": \"Please note\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.\",\n  \"title\": \"Please note\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4c","createdAt":"2016-04-29T21:59:52.047Z","excerpt":"Updates the account's Billing Information using external token for example: Paypal billing agreement","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":8,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-an-accounts-billing-info-using-external-token","sync_unique":"","title":"Update an Account's Billing Info (using external token)","type":"put","updates":[],"user":"56c3c01334df460d00c2beb3","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate an Account's Billing Info (using external token)

Updates the account's Billing Information using external token for example: Paypal billing agreement

account_code:
required
string
Your unique account identifier.
first_name:
required
string
First name
last_name:
required
string
Last name
address1:
string
Address line 1, recommended for address validation
address2:
string
Address line 2.
city:
string
City
state:
string
State
country:
string
Country, [2-letter ISO code](http://www.iso.org/iso/country_names_and_code_elements) **STRONGLY RECOMMENDED**
zip:
string
Zip or postal code, recommended for address validation
phone:
string
Phone number
paypal_billing_agreement_id:
string
Paypal's billing agreement
vat_number:
string
Customer's VAT Number
currency:
string
Currency in which invoices will be posted. Only applicable if this account is enrolled in a plan has a different currency than your site's default.
ip_address:
string
Customer's IP address when updating their Billing Information **STRONGLY RECOMMENDED**
Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



Instead of using a token generated by Recurly.js, you can instead submit full credit card and address information when creating Billing Information. When Billing Information is submitted, it is only saved if valid. If the account has a past due invoice, the outstanding balance will be collected to validate the Billing Information. If you want to create an account at the same time, you should use the [Account API end-point](https://docs.recurly.com/api/accounts#create-account) instead and include Billing Information with your request. The required address fields will correspond to the **address requirements** configured for your site. [block:callout] { "type": "warning", "body": "Recurly strongly recommends using a token [generated by Recurly.js](https://docs.recurly.com/js/#getting-a-token) rather than directly handling your customer's credit card details.", "title": "Please note" } [/block] [block:callout] { "type": "warning", "body": "This API end-point may be used to import Billing Information without security codes (CVV). Recurly recommends requiring CVV from your customers when collecting new or updated Billing Information.", "title": "Please note" } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f77","api":{"examples":{"codes":[{"name":"","code":"try {\n  $billing_info = Recurly_BillingInfo::get('b6f5783');\n  $billing_info->delete();\n\n  // Or, in a single API request:\n  // Recurly_BillingInfo::deleteForAccount('b6f5783');\n\n  print \"Billing Info: $billing_info\";\n} catch (Recurly_NotFoundError $e) {\n  // Account not found or account does not have billing info\n  print \"Not Found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\nif billing_info = account.billing_info\n  billing_info.destroy\nend","language":"ruby"},{"code":"account = Account.get('1')\nbilling_info = account.billing_info\nif billing_info\n  billing_info.delete()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\naccount.DeleteBillingInfo();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"Status: 204 No Content","language":"json","status":204}]},"settings":"","auth":"required","params":[{"_id":"55944ffb0c33bd0d0005964c","ref":"","required":true,"desc":"Your unique account identifier.","default":"","type":"string","name":"account_code"}],"url":"/accounts/:account_code/billing_info"},"body":"","category":"56fd7e6b5a08190e00084f4c","createdAt":"2015-06-17T20:40:02.831Z","excerpt":"You may remove any stored billing information for an account. If the account has a subscription, the renewal will go into past due unless you update the billing info before the renewal occurs.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":9,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"clear-an-accounts-billing-info","sync_unique":"","title":"Clear an Account's Billing Info","type":"delete","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteClear an Account's Billing Info

You may remove any stored billing information for an account. If the account has a subscription, the renewal will go into past due unless you update the billing info before the renewal occurs.

account_code:
required
string
Your unique account identifier.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084fa9","api":{"examples":{"codes":[{"name":"","code":"$coupons = Recurly_CouponList::get();\nforeach ($coupons as $coupon) {\n  print \"Coupon: $coupon\\n\";\n}","language":"php"},{"code":"Recurly::Coupon.find_each do |coupon|\n  puts \"Coupon: #{coupon.inspect}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\ncoupons = Coupon.all()\nwhile coupons:\n    for coupon in coupons:\n        print 'Coupon: %s' % coupon\n    try:\n        coupons = coupons.next_page()\n    except PageError:\n        coupons = ()\n\n#client version 2.1.6+\nfor coupon in Coupon.all():\n    print 'Coupon: %s' % coupon","language":"python"},{"code":"using System.Linq;\n\nvar coupons = Coupons.List();\nwhile (coupons.Any())\n{\n\tforeach (var coupon in coupons)\n\t\tConsole.WriteLine(\"Coupon: \" + coupon);\n\tcoupons = coupons.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<coupons type=\"array\">\n  <coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\">\n    <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/special/redemptions\"/>\n    <coupon_code>special</coupon_code>\n    <name>Special 10% off</name>\n    <state>redeemable</state>\n    <discount_type>percent</discount_type>\n    <discount_percent type=\"integer\">10</discount_percent>\n    <redeem_by_date type=\"datetime\">2014-01-01T07:00:00Z</redeem_by_date>\n    <single_use type=\"boolean\">false</single_use>\n    <applies_for_months nil=\"nil\"></applies_for_months>\n    <max_redemptions type=\"integer\">10</max_redemptions>\n    <applies_to_all_plans type=\"boolean\">false</applies_to_all_plans>\n    <created_at type=\"datetime\">2011-04-10T07:00:00Z</created_at>\n    <duration>temporal</duration>\n    <temporal_unit>day</temporal_unit>\n    <temporal_amount type=\"integer\">28</temporal_amount>\n    <plan_codes type=\"array\">\n      <plan_code>gold</plan_code>\n      <plan_code>platinum</plan_code>\n    </plan_codes>\n    <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/special/redeem\" method=\"post\"/>\n  </coupon>\n  <!-- Continued... -->\n</coupons>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"5581f3c38625220d00429ee7","ref":"","required":false,"desc":"The state of coupons to return: \"redeemable\", \"expired\", \"maxed_out\", or \"inactive\".","default":"all","type":"string","name":"state"},{"_id":"5581f3c38625220d00429ee6","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"5581f3c38625220d00429ee5","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"int","name":"per_page"}],"url":"/coupons"},"body":"","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-06-17T22:25:07.292Z","excerpt":"Returns a list of all the coupons.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-active-coupons","sync_unique":"","title":"List Active Coupons","type":"get","updates":[],"user":"55648cf93b87582b003ab8b1","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Active Coupons

Returns a list of all the coupons.

state:
stringall
The state of coupons to return: "redeemable", "expired", "maxed_out", or "inactive".
cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
integer50
Number of records to return per page, up to a maximum of 200.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":1,"_id":"56fd7e6b5a08190e00084faa","api":{"examples":{"codes":[{"name":"","code":"<?php\ntry {\n  $coupon = Recurly_Coupon::get('special');\n  print \"Coupon: $coupon\\n\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Coupon does not exist\";\n}\n?>","language":"php"},{"code":"coupon = Recurly::Coupon.find('special')","language":"ruby"},{"code":"coupon = Coupon.get('special')","language":"python"},{"code":"var coupon = Coupons.Get(\"special\");","language":"csharp"}]},"results":{"codes":[{"status":200,"language":"xml","code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\">\n  <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/special/redemptions\"/>\n  <coupon_code>special</coupon_code>\n  <name>Special 10% off</name>\n  <state>redeemable</state>\n  <hosted_description>10% off coupon</hosted_description>\n  <discount_type>percent</discount_type>\n  <discount_percent type=\"integer\">10</discount_percent>\n  <redeem_by_date type=\"datetime\">2014-01-01T07:00:00Z</redeem_by_date>\n  <single_use type=\"boolean\">false</single_use>\n  <applies_for_months nil=\"nil\"></applies_for_months>\n  <max_redemptions type=\"integer\">10</max_redemptions>\n  <applies_to_all_plans type=\"boolean\">false</applies_to_all_plans>\n  <created_at type=\"datetime\">2011-04-10T07:00:00Z</created_at>\n  <duration>temporal</duration>\n  <temporal_unit>day</temporal_unit>\n  <temporal_amount type=\"integer\">28</temporal_amount>\n  <plan_codes type=\"array\">\n    <plan_code>gold</plan_code>\n    <plan_code>platinum</plan_code>\n  </plan_codes>\n  <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/special/redeem\" method=\"post\"/>\n</coupon>","name":"Single Code"},{"code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/sprintdemos347\">\n  <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/redemptions\"/>\n  <unique_coupon_codes href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/unique_coupon_codes\"/>\n  <coupon_code>savemore</coupon_code>\n  <name>Save More Annual Sale</name>\n  <state>redeemable</state>\n  <description nil=\"nil\"></description>\n  <discount_type>dollars</discount_type>\n  <discount_in_cents>\n  \t<USD type=\"integer\">2000</USD>\n  </discount_in_cents>\n  <invoice_description nil=\"nil\"></invoice_description>\n  <redeem_by_date nil=\"nil\"></redeem_by_date>\n  <single_use type=\"boolean\">false</single_use>\n  <applies_for_months nil=\"nil\"></applies_for_months>\n  <max_redemptions nil=\"nil\"></max_redemptions>\n  <applies_to_all_plans type=\"boolean\">true</applies_to_all_plans>\n  <created_at type=\"datetime\">2015-10-05T16:42:50Z</created_at>\n  <duration>temporal</duration>\n  <temporal_unit>day</temporal_unit>\n  <temporal_amount type=\"integer\">28</temporal_amount>\n  <applies_to_non_plan_charges type=\"boolean\">false</applies_to_non_plan_charges>\n  <redemption_resource>account</redemption_resource>\n  <max_redemptions_per_account type=\"integer\">1</max_redemptions_per_account>\n  <coupon_type>bulk</coupon_type>\n  <unique_code_template>'savemore'99999999</unique_code_template>\n  <deleted_at nil=\"nil\"></deleted_at>\n  <unique_coupon_codes_count type=\"integer\">100</unique_coupon_codes_count>\n  <plan_codes type=\"array\"></plan_codes>\n  <a name=\"generate\" href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/generate\" method=\"post\"/>\n</coupon>","language":"xml","status":200,"name":"Bulk Coupon"},{"code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/savemore28945343\">\n  <bulk_coupon href=\"https://your-subdomain.recurly.com/v2/coupons/savemore\"/>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/coupons/savemore28945343/redemption\"/>\n  <coupon_code>savemore28945343</coupon_code>\n  <name>Save More Annual Sale</name>\n  <state>maxed_out</state>\n  <description></description>\n  <discount_type>dollar</discount_type>\n  <discount_percent type=\"integer\">2000</discount_percent>\n  <invoice_description></invoice_description>\n  <redeem_by_date nil=\"nil\"></redeem_by_date>\n  <single_use type=\"boolean\">true</single_use>\n  <applies_for_months nil=\"nil\"></applies_for_months>\n  <max_redemptions nil=\"nil\"></max_redemptions>\n  <applies_to_all_plans type=\"boolean\">false</applies_to_all_plans>\n  <created_at type=\"datetime\">2015-10-05T16:42:50Z</created_at>\n  <duration>temporal</duration>\n  <temporal_unit>day</temporal_unit>\n  <temporal_amount type=\"integer\">28</temporal_amount>\n  <applies_to_non_plan_charges type=\"boolean\">false</applies_to_non_plan_charges>\n  <redemption_resource>account</redemption_resource>\n  <max_redemptions_per_account type=\"integer\">1</max_redemptions_per_account>\n  <coupon_type>unique_code</coupon_type>\n  <redeemed_at type=\"datetime\">2015-10-07T18:48:12Z</redeemed_at>\n  <deleted_at nil=\"nil\"></deleted_at>\n  <plan_codes type=\"array\"></plan_codes>\n  <a name=\"restore\" href=\"https://your-subdomain.recurly.com/v2/coupons/savemore28945343/restore\" method=\"put\"/>\n</coupon>","language":"xml","status":200,"name":"Unique Code"}]},"settings":"","auth":"required","params":[],"url":"/coupons/:coupon_code"},"body":"","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-06-17T22:55:45.346Z","excerpt":"Returns information about an active coupon.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-a-coupon","sync_unique":"","title":"Lookup a Coupon","type":"get","updates":["5654b5aa48b4df0d00f67d9d","570fc426277cba22000c87d4"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup a Coupon

Returns information about an active coupon.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084fab","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $coupon = new Recurly_Coupon();\n  $coupon->coupon_code = 'gorby1';\n  $coupon->redeem_by_date = '2016-07-04';\n  $coupon->duration = 'single_use';\n\t$coupon->redemption_resource = 'subscription';\n\t$coupon->max_redemptions_per_account = 1;\n\t$coupon->applies_to_non_plan_charges = true;\n\n  // $2 off...\n  $coupon->name = 'Special $2 off coupon';\n  $coupon->discount_type = 'dollars';\n  $coupon->discount_in_cents->addCurrency('USD',200); // $2.00 discount\n\n  // ...or 10% off.\n  $coupon->name = 'Special 10% off';\n  $coupon->discount_type = 'percent';\n  $coupon->discount_percent = 10;\n\n  // Limit to gold and platinum plans only.\n  $coupon->applies_to_all_plans = false;\n  $coupon->plan_codes = array('gold', 'platinum');\n\n  $coupon->create();\n\n  print \"Coupon: $coupon\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid data: $e\";\n}","name":""},{"language":"ruby","code":"coupon = Recurly::Coupon.new(\n  :coupon_code    => 'special',\n  :redeem_by_date => Date.new(2014, 1, 1),\n  :duration     => 'single_use'\n)\n\n# $2 off...\ncoupon.name = 'Special $2 off coupon'\ncoupon.discount_type = 'dollars'\ncoupon.discount_in_cents = 2_00\n\n# ...or 10% off.\ncoupon.name = 'Special 10% off'\ncoupon.discount_type = 'percent'\ncoupon.discount_percent = 10\n\n# Limit to gold and platinum plans only.\ncoupon.applies_to_all_plans = false\ncoupon.plan_codes = %w(gold platinum)\n\n# Limit redemption to specific subscription on account.\ncoupon.redemption_resource = 'subscription'\n\n# Limit redemptions per account to a specific number.\ncoupon.max_redemptions_per_account = 1\n\n# Discount should include one-time charges.\ncoupon.applies_to_non_plan_charges = true\n\ncoupon.save"},{"language":"python","code":"coupon = Coupon(\n  coupon_code='special',\n  redeem_by_date=datetime.date(2014, 1, 1),\n  duration='single_use'\n)\n\n# $2 off...\ncoupon.name = 'Special $2 off coupon'\ncoupon.discount_type = 'dollars'\ncoupon.discount_in_cents = Money(200)\n\n# ...or 10% off.\ncoupon.name = 'Special 10% off'\ncoupon.discount_type = 'percent'\ncoupon.discount_percent = 10\n\n# Limit to gold and platinum plans only.\ncoupon.applies_to_all_plans = False\ncoupon.plan_codes = ['gold', 'platinum']\n\n# Limit redemption to specific subscription on account.\ncoupon.redemption_resource = 'subscription'\n\n# Limit redemptions per account to a specific number.\ncoupon.max_redemptions_per_account = 1\n\n# Discount should include one-time charges.\ncoupon.applies_to_non_plan_charges = True\n\ncoupon.save()"},{"language":"csharp","code":"// new Coupon(<code>, <name>, <discount>)\n\n// $2 off...\nvar coupon = new Coupon(\"special\",\n        \"Special $2 off coupon\", new Dictionary<string, int>() { { \"USD\", 200 } });\n\n// ... or 10% off...\nvar coupon = new Coupon(\"special\",\n        \"Special 10% off coupon\", 10);\n\ncoupon.RedeemByDate = new DateTime(2017, 1, 1);\ncoupon.SingleUse = true;\n\n// Limit to gold and platinum plans only.\ncoupon.AppliesToAllPlans = false;\ncoupon.Plans.Add(\"gold\");\ncoupon.Plans.Add(\"silver\");\n\n// Other properties\ncoupon.RedeemByDate = new DateTime(2014, 1, 1);\ncoupon.SingleUse = true;\ncoupon.RedemptionResource = Coupon.RedemptionResourceType.Subscription;\ncoupon.MaxRedemptionsPerAccount = 1;\ncoupon.AppliesToNonPlanCharges = true;\n\ncoupon.Create();"},{"name":"XML","language":"xml","code":"// Request for all plans:\n<coupon>\n  <coupon_code>special</coupon_code>\n  <name>Special $2 off coupon</name>\n  <discount_type>dollars</discount_type>\n    <discount_in_cents>\n    <USD>200</USD>\n  </discount_in_cents>\n  <redeem_by_date>2015-12-31</redeem_by_date>\n  <duration>temporal</duration>\n  <temporal_unit>day</temporal_unit>\n  <temporal_amount>28</temporal_amount>\n  <max_redemptions>200</max_redemptions>\n  <max_redemptions_per_account>1</max_redemptions_per_account>\n  <applies_to_all_plans>true</applies_to_all_plans>\n</coupon>\n\n\n// Request for $2 coupon:\n<coupon>\n  <coupon_code>special</coupon_code>\n  <name>Special 10% off</name>\n  <discount_type>percent</discount_type>\n  <discount_percent>10</discount_percent>\n  <redeem_by_date>2015-12-31</redeem_by_date>\n  <duration>single_use</duration>\n  <max_redemptions>200</max_redemptions>\n  <applies_to_all_plans>false</applies_to_all_plans>\n  <plan_codes>\n    <plan_code>gold</plan_code>\n    <plan_code>platinum</plan_code>\n  </plan_codes>\n</coupon>"}]},"results":{"codes":[{"status":201,"language":"xml","code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\">\n  <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/special/redemptions\"/>\n  <coupon_code>special</coupon_code>\n  <name>Special 10% off</name>\n  <state>redeemable</state>\n  <discount_type>percent</discount_type>\n  <discount_percent type=\"integer\">10</discount_percent>\n  <redeem_by_date type=\"datetime\">2015-12-31T07:00:00Z</redeem_by_date>\n  <single_use type=\"boolean\">false</single_use>\n  <applies_for_months nil=\"nil\"></applies_for_months>\n  <max_redemptions type=\"integer\">200</max_redemptions>\n  <applies_to_all_plans type=\"boolean\">false</applies_to_all_plans>\n  <created_at type=\"datetime\">2011-04-10T07:00:00Z</created_at>\n  <duration>temporal</duration>\n  <temporal_unit>day</temporal_unit>\n  <temporal_amount type=\"integer\">28</temporal_amount>\n  <plan_codes type=\"array\">\n    <plan_code>gold</plan_code>\n    <plan_code>platinum</plan_code>\n  </plan_codes>\n  <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/special/redeem\" method=\"post\"/>\n</coupon>","name":""}]},"settings":"","auth":"required","params":[{"_id":"5581fc9c8625220d00429f13","ref":"","required":true,"desc":"Unique code to identify and redeem the coupon. This code may only contain the following characters: [a-z A-Z 0-9 + - _ ]. Max of 50 characters.","default":"","type":"string","name":"coupon_code"},{"_id":"5581fc9c8625220d00429f12","ref":"","required":true,"desc":"Coupon name","default":"","type":"string","name":"name"},{"_id":"5581fc9c8625220d00429f11","ref":"","required":false,"desc":"Description of the coupon on the hosted payment pages","default":"","type":"string","name":"description"},{"_id":"5581fc9c8625220d00429f0a","ref":"","required":true,"desc":"\"percent\" or \"dollars\"","default":"","type":"string","name":"discount_type"},{"_id":"5581fc9c8625220d00429f08","ref":"","required":false,"desc":"Mapping of discount amounts by currency if discount_type is \"dollars\". Max 10000000.","default":"","type":"int","name":"discount_in_cents"},{"_id":"5581fc9c8625220d00429f09","ref":"","required":false,"desc":"Discount percentage if discount_type is \"percent\"","default":"","type":"int","name":"discount_percent"},{"_id":"5581fc9c8625220d00429f10","ref":"","required":false,"desc":"Description of the coupon on the invoice","default":"","type":"string","name":"invoice_description"},{"_id":"5581fc9c8625220d00429f0f","ref":"","required":false,"desc":"Last date to redeem the coupon, defaults to no date","default":"","type":"datetime","name":"redeem_by_date"},{"_id":"5581fc9c8625220d00429f0e","ref":"","required":false,"desc":"DEPRECATED: Please use \"duration\". If true, the coupon applies to the first invoice only.","default":"","type":"boolean","name":"single_use"},{"_id":"5581fc9c8625220d00429f0d","ref":"","required":false,"desc":"DEPRECATED: Please use \"temporal_unit\" and \"temporal_amount\". Number of months after redemption that the coupon is valid, defaults to no date","default":"","type":"int","name":"applies_for_months"},{"_id":"5581fc9c8625220d00429f0c","ref":"","required":false,"desc":"Maximum number of accounts that may use the coupon before it can no longer be redeemed","default":"","type":"int","name":"max_redemptions"},{"_id":"5581fc9c8625220d00429f0b","ref":"","required":false,"desc":"The coupon is valid for all plans if true, defaults to true","default":"","type":"boolean","name":"applies_to_all_plans"},{"_id":"55babe051b0d663700781631","ref":"","required":true,"desc":"\"forever\"(default), \"single_use\", or \"temporal\".  If \"single_use\", the coupon applies to the first invoice only.  If \"temporal\" the coupon will apply to invoices for the duration determined by the temporal_unit and temporal_amount attributes.","default":"forever","type":"string","name":"duration"},{"_id":"55babe051b0d663700781630","ref":"","required":false,"desc":"\"day\", \"week\", \"month\", or \"year\".  If duration is \"temporal\" than temporal_unit is multiplied by temporal_amount to define the duration that the coupon will be applied to invoices for.","default":"","type":"string","name":"temporal_unit"},{"_id":"55babe051b0d66370078162f","ref":"","required":false,"desc":"If duration is \"temporal\" than temporal_amount is an integer which is multiplied by temporal_unit to define the duration that the coupon will be applied to invoices for.","default":"","type":"int","name":"temporal_amount"},{"_id":"5612aac709bdc51700697025","ref":"","required":false,"desc":"The coupon is valid for one-time, non-plan charges if true, defaults to false.","default":"false","type":"boolean","name":"applies_to_non_plan_charges"},{"_id":"5612aac709bdc51700697024","ref":"","required":false,"desc":"Whether the discount is for all eligible charges on the account, or only a specific subscription. Values are \"account\" or \"subscription\".","default":"account","type":"string","name":"redemption_resource"},{"_id":"5612aac709bdc51700697023","ref":"","required":false,"desc":"The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.","default":"","type":"int","name":"max_redemptions_per_account"},{"_id":"5612aac709bdc51700697022","ref":"","required":false,"desc":"Whether the coupon is \"single_code\" or \"bulk\". Bulk coupons will require a unique_code_template and will generate unique codes through the /generate endpoint.","default":"single_code","type":"string","name":"coupon_type"},{"_id":"5612aac709bdc51700697021","ref":"","required":false,"desc":"The template for generating unique codes. See rules below for creating unique code templates.","default":"","type":"string","name":"unique_code_template"},{"_id":"5581fc9c8625220d00429f07","ref":"","required":false,"desc":"Array of plan_codes the coupon applies to, if applies_to_all_plans is false","default":"","type":"array_string","name":"plan_codes"}],"url":"/coupons"},"body":"**DISCOUNT IN DOLLARS**\nWhen specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example:\n```\n<discount_type>dollars</discount_type>\n<discount_in_cents>\n  <USD>500</USD>\n  <EUR>400</EUR>\n  <GBP>300</GBP>\n</discount_in_cents>\n```\n**DISCOUNT IN PERCENTAGE**\nPercentage discounts only need to specify the discount percentage. For example:\n```\n<discount_type>percent</discount_type>\n<discount_percent>10</discount_percent>\n```\n**LIMITING TO SPECIFIC PLANS**\nIf a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example:\n```\n<applies_to_all_plans>false</applies_to_all_plans>\n<plan_codes>\n  <plan_code>silver</plan_code>\n  <plan_code>gold</plan_code>\n</plan_codes>\n```\n**CREATING UNIQUE CODE TEMPLATES**\nIf you are creating a bulk coupon, you will need to create a unique_code_template. Here are the rules:\n1. You must start the template with your coupon_code wrapped in single quotes.\n2. Outside of single quotes, use a 9 for a character that you want to be a random number.\n3. Outside of single quotes, use an \"x\" for a character that you want to be a random letter.\n4. Outside of single quotes, use an * for a character that you want to be a random number or letter.\n5. Use single quotes ' ' for characters that you want to remain static. These strings can be alphanumeric and may contain a - _ or +.\n\n```\n<coupon_code>thankyou</coupon_code>\n<coupon_type>bulk</coupon_type>\n<unique_code_template>'thankyou'99999999</unique_code_template>\n```\nThis example will create a unique code like: thankyou41863675","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-06-17T23:02:52.933Z","excerpt":"Creates a new coupon. Please note: coupons cannot be updated after being created.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-coupon","sync_unique":"","title":"Create Coupon","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate Coupon

Creates a new coupon. Please note: coupons cannot be updated after being created.

coupon_code:
required
string
Unique code to identify and redeem the coupon. This code may only contain the following characters: [a-z A-Z 0-9 + - _ ]. Max of 50 characters.
name:
required
string
Coupon name
description:
string
Description of the coupon on the hosted payment pages
discount_type:
required
string
"percent" or "dollars"
discount_in_cents:
integer
Mapping of discount amounts by currency if discount_type is "dollars". Max 10000000.
discount_percent:
integer
Discount percentage if discount_type is "percent"
invoice_description:
string
Description of the coupon on the invoice
redeem_by_date:
datetime
Last date to redeem the coupon, defaults to no date
single_use:
boolean
DEPRECATED: Please use "duration". If true, the coupon applies to the first invoice only.
applies_for_months:
integer
DEPRECATED: Please use "temporal_unit" and "temporal_amount". Number of months after redemption that the coupon is valid, defaults to no date
max_redemptions:
integer
Maximum number of accounts that may use the coupon before it can no longer be redeemed
applies_to_all_plans:
boolean
The coupon is valid for all plans if true, defaults to true
duration:
required
stringforever
"forever"(default), "single_use", or "temporal". If "single_use", the coupon applies to the first invoice only. If "temporal" the coupon will apply to invoices for the duration determined by the temporal_unit and temporal_amount attributes.
temporal_unit:
string
"day", "week", "month", or "year". If duration is "temporal" than temporal_unit is multiplied by temporal_amount to define the duration that the coupon will be applied to invoices for.
temporal_amount:
integer
If duration is "temporal" than temporal_amount is an integer which is multiplied by temporal_unit to define the duration that the coupon will be applied to invoices for.
applies_to_non_plan_charges:
booleanfalse
The coupon is valid for one-time, non-plan charges if true, defaults to false.
redemption_resource:
stringaccount
Whether the discount is for all eligible charges on the account, or only a specific subscription. Values are "account" or "subscription".
max_redemptions_per_account:
integer
The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.
coupon_type:
stringsingle_code
Whether the coupon is "single_code" or "bulk". Bulk coupons will require a unique_code_template and will generate unique codes through the /generate endpoint.
unique_code_template:
string
The template for generating unique codes. See rules below for creating unique code templates.
plan_codes:
array of strings
Array of plan_codes the coupon applies to, if applies_to_all_plans is false
**DISCOUNT IN DOLLARS** When specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example: ``` <discount_type>dollars</discount_type> <discount_in_cents> <USD>500</USD> <EUR>400</EUR> <GBP>300</GBP> </discount_in_cents> ``` **DISCOUNT IN PERCENTAGE** Percentage discounts only need to specify the discount percentage. For example: ``` <discount_type>percent</discount_type> <discount_percent>10</discount_percent> ``` **LIMITING TO SPECIFIC PLANS** If a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example: ``` <applies_to_all_plans>false</applies_to_all_plans> <plan_codes> <plan_code>silver</plan_code> <plan_code>gold</plan_code> </plan_codes> ``` **CREATING UNIQUE CODE TEMPLATES** If you are creating a bulk coupon, you will need to create a unique_code_template. Here are the rules: 1. You must start the template with your coupon_code wrapped in single quotes. 2. Outside of single quotes, use a 9 for a character that you want to be a random number. 3. Outside of single quotes, use an "x" for a character that you want to be a random letter. 4. Outside of single quotes, use an * for a character that you want to be a random number or letter. 5. Use single quotes ' ' for characters that you want to remain static. These strings can be alphanumeric and may contain a - _ or +. ``` <coupon_code>thankyou</coupon_code> <coupon_type>bulk</coupon_type> <unique_code_template>'thankyou'99999999</unique_code_template> ``` This example will create a unique code like: thankyou41863675

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



**DISCOUNT IN DOLLARS** When specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example: ``` <discount_type>dollars</discount_type> <discount_in_cents> <USD>500</USD> <EUR>400</EUR> <GBP>300</GBP> </discount_in_cents> ``` **DISCOUNT IN PERCENTAGE** Percentage discounts only need to specify the discount percentage. For example: ``` <discount_type>percent</discount_type> <discount_percent>10</discount_percent> ``` **LIMITING TO SPECIFIC PLANS** If a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example: ``` <applies_to_all_plans>false</applies_to_all_plans> <plan_codes> <plan_code>silver</plan_code> <plan_code>gold</plan_code> </plan_codes> ``` **CREATING UNIQUE CODE TEMPLATES** If you are creating a bulk coupon, you will need to create a unique_code_template. Here are the rules: 1. You must start the template with your coupon_code wrapped in single quotes. 2. Outside of single quotes, use a 9 for a character that you want to be a random number. 3. Outside of single quotes, use an "x" for a character that you want to be a random letter. 4. Outside of single quotes, use an * for a character that you want to be a random number or letter. 5. Use single quotes ' ' for characters that you want to remain static. These strings can be alphanumeric and may contain a - _ or +. ``` <coupon_code>thankyou</coupon_code> <coupon_type>bulk</coupon_type> <unique_code_template>'thankyou'99999999</unique_code_template> ``` This example will create a unique code like: thankyou41863675
{"__v":0,"_id":"56fd7e6b5a08190e00084fac","api":{"examples":{"codes":[{"name":"","code":"<coupon>\n\t<number_of_unique_codes>200</number_of_unique_codes>\n</coupon>","language":"text"}]},"results":{"codes":[{"name":"Request Too High","code":"<error>\n    <symbol>number_of_unique_codes</symbol>\n    <description>You are limited to generating 200 at a time</description>\n</error>","language":"xml","status":400},{"name":"Request In Progress","code":"<error>\n    <symbol>number_of_unique_codes</symbol>\n    <description>Number of unique codes cannot be generated; unique code creation is in progress, please wait for it to finish and try again</description>\n</error>","language":"xml","status":400},{"code":"<error>\n    <symbol>number_of_unique_codes</symbol>\n    <description>Number of unique codes can only generate a total of 100000 codes</description>\n</error>","language":"xml","status":400,"name":"Max Reached"},{"code":"<error>\n    <symbol>number_of_unique_codes</symbol>\n    <description>Coupon must be of type bulk to generate unique codes</description>\n</error>","language":"xml","status":400,"name":"Not Bulk Coupon"}]},"settings":"","auth":"required","params":[{"_id":"5618a0ab9420c40d00510833","ref":"","required":false,"desc":"Number of unique codes you want to generate for the bulk coupon. Must be between 1 and 200.","default":"","type":"int","name":"number_of_unique_codes"}],"url":"/coupons/:coupon_code/generate"},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"View Unique Codes\"\n}\n[/block]\nThe response will include the location of the unique codes as link in the header:\n\n```\nhttps://your-subdomain.recurly.com/v2/coupons/savemore/unique_coupon_codes?cursor=1792526747654056328&per_page=200\n```","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-10-10T05:22:51.540Z","excerpt":"Create unique codes for a bulk coupon. A bulk coupon can have up to 100,000 unique codes total. The generate endpoint allows up to 200 unique codes at a time. The endpoint can be called multiple times to create then number of unique codes you need.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"generate-unique-codes","sync_unique":"","title":"Generate Unique Codes","type":"post","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postGenerate Unique Codes

Create unique codes for a bulk coupon. A bulk coupon can have up to 100,000 unique codes total. The generate endpoint allows up to 200 unique codes at a time. The endpoint can be called multiple times to create then number of unique codes you need.

number_of_unique_codes:
integer
Number of unique codes you want to generate for the bulk coupon. Must be between 1 and 200.
[block:api-header] { "type": "basic", "title": "View Unique Codes" } [/block] The response will include the location of the unique codes as link in the header: ``` https://your-subdomain.recurly.com/v2/coupons/savemore/unique_coupon_codes?cursor=1792526747654056328&per_page=200 ```

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:api-header] { "type": "basic", "title": "View Unique Codes" } [/block] The response will include the location of the unique codes as link in the header: ``` https://your-subdomain.recurly.com/v2/coupons/savemore/unique_coupon_codes?cursor=1792526747654056328&per_page=200 ```
{"__v":0,"_id":"56fd7e6b5a08190e00084fad","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $coupon = Recurly_Coupon::get('special');\n  $coupon->delete();\n\n  print \"Coupon: $coupon\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Coupon not found: $e\";\n}","name":""},{"language":"ruby","code":"coupon = Recurly::Coupon.find('special')\ncoupon.destroy"},{"language":"python","code":"coupon = Coupon.get('special')\ncoupon.delete()"},{"language":"csharp","code":"var coupon = Coupons.Get(\"special\");\ncoupon.Deactivate();"}]},"results":{"codes":[{"code":"Status: 204 No Content","language":"xml","status":204}]},"settings":"","auth":"required","params":[],"url":"/coupons/:coupon_code"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Bulk Unique Coupons\",\n  \"body\": \"Use the coupon_code of the main coupon campaign, also known as the prefix, to expire all not yet redeemed unique codes in the campaign. Use the unique code's coupon_code in order to expire just the specific unique code.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-06-17T23:28:22.499Z","excerpt":"Expire the coupon so customers can no longer redeem the coupon.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"deactivate-coupon","sync_unique":"","title":"Expire Coupon","type":"delete","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteExpire Coupon

Expire the coupon so customers can no longer redeem the coupon.

[block:callout] { "type": "info", "title": "Bulk Unique Coupons", "body": "Use the coupon_code of the main coupon campaign, also known as the prefix, to expire all not yet redeemed unique codes in the campaign. Use the unique code's coupon_code in order to expire just the specific unique code." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "title": "Bulk Unique Coupons", "body": "Use the coupon_code of the main coupon campaign, also known as the prefix, to expire all not yet redeemed unique codes in the campaign. Use the unique code's coupon_code in order to expire just the specific unique code." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084fae","api":{"examples":{"codes":[{"name":"","code":"<coupon>\n  <name>New Coupon Name</name>\n  <description>New coupon description for the hosted pages.</description>\n  <invoice_description>New coupon description for the invoice.</invoice_description>\n  <redeem_by_date>2015-12-31</redeem_by_date>\n  <max_redemptions>500</max_redemptions>\n  <max_redemptions_per_account>1</max_redemptions_per_account>\n</coupon>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/sprintdemos3456\">\n    <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/redemptions\"/>\n    <coupon_code>savemore</coupon_code>\n    <name>New Coupon Name</name>\n    <state>redeemable</state>\n    <description>New coupon description for the hosted pages.</description>\n    <discount_type>percent</discount_type>\n    <discount_percent type=\"integer\">10</discount_percent>\n    <invoice_description>New coupon description for the invoice.</invoice_description>\n    <redeem_by_date type=\"datetime\">2015-12-31T00:00:00Z</redeem_by_date>\n    <single_use type=\"boolean\">false</single_use>\n    <applies_for_months nil=\"nil\"></applies_for_months>\n    <max_redemptions type=\"integer\">500</max_redemptions>\n    <applies_to_all_plans type=\"boolean\">true</applies_to_all_plans>\n    <created_at type=\"datetime\">2015-10-05T16:42:32Z</created_at>\n    <duration>forever</duration>\n    <temporal_unit nil=\"nil\"></temporal_unit>\n    <temporal_amount nil=\"nil\"></temporal_amount>\n    <applies_to_non_plan_charges type=\"boolean\">false</applies_to_non_plan_charges>\n    <redemption_resource>account</redemption_resource>\n    <max_redemptions_per_account type=\"integer\">1</max_redemptions_per_account>\n    <coupon_type>single_code</coupon_type>\n    <deleted_at nil=\"nil\"></deleted_at>\n    <plan_codes type=\"array\"></plan_codes>\n    <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/redeem\" method=\"post\"/>\n</coupon>","language":"xml","status":200},{"name":"Field Not Editable","code":"<error>\n    <symbol>attributes_not_allowed</symbol>\n    <description>You are not allowed to edit attributes discount_type.</description>\n</error>","language":"xml","status":400}]},"settings":"","auth":"required","params":[{"_id":"561738644d9e4a17002a0de5","ref":"","required":false,"desc":"Coupon name","default":"","type":"string","name":"name"},{"_id":"561738644d9e4a17002a0de4","ref":"","required":false,"desc":"Description of the coupon on the hosted payment pages","default":"","type":"string","name":"description"},{"_id":"561738644d9e4a17002a0de3","ref":"","required":false,"desc":"Description of the coupon on the invoice","default":"","type":"string","name":"invoice_description"},{"_id":"561738644d9e4a17002a0de2","ref":"","required":false,"desc":"Last date to redeem the coupon, defaults to no date","default":"","type":"datetime","name":"redeem_by_date"},{"_id":"561738644d9e4a17002a0de1","ref":"","required":false,"desc":"Maximum number of accounts that may use the coupon before it can no longer be redeemed","default":"","type":"int","name":"max_redemptions"},{"_id":"561738644d9e4a17002a0de0","ref":"","required":false,"desc":"The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.","default":"","type":"int","name":"max_redemptions_per_account"}],"url":"/coupons/:coupon_code"},"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Editing Bulk Coupons and Unique Codes\"\n}\n[/block]\nYou can edit a bulk coupon to change the rules of the campaign, but you cannot edit a unique code within the campaign.","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-10-09T03:45:40.895Z","excerpt":"Edit a redeemable coupon to extend redemption rules. Only redeemable coupons can be edited and only the below params are editable.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"edit-coupon","sync_unique":"","title":"Edit Coupon","type":"put","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putEdit Coupon

Edit a redeemable coupon to extend redemption rules. Only redeemable coupons can be edited and only the below params are editable.

name:
string
Coupon name
description:
string
Description of the coupon on the hosted payment pages
invoice_description:
string
Description of the coupon on the invoice
redeem_by_date:
datetime
Last date to redeem the coupon, defaults to no date
max_redemptions:
integer
Maximum number of accounts that may use the coupon before it can no longer be redeemed
max_redemptions_per_account:
integer
The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.
[block:api-header] { "type": "basic", "title": "Editing Bulk Coupons and Unique Codes" } [/block] You can edit a bulk coupon to change the rules of the campaign, but you cannot edit a unique code within the campaign.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:api-header] { "type": "basic", "title": "Editing Bulk Coupons and Unique Codes" } [/block] You can edit a bulk coupon to change the rules of the campaign, but you cannot edit a unique code within the campaign.
{"__v":0,"_id":"56fd7e6b5a08190e00084faf","api":{"examples":{"codes":[{"name":"","code":"<coupon>\n  <name>New Coupon Name</name>\n  <description>New coupon description for the hosted pages.</description>\n  <invoice_description>New coupon description for the invoice.</invoice_description>\n  <redeem_by_date>2015-12-31</redeem_by_date>\n  <max_redemptions>500</max_redemptions>\n  <max_redemptions_per_account>1</max_redemptions_per_account>\n</coupon>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/sprintdemos3456\">\n    <redemptions href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/redemptions\"/>\n    <coupon_code>savemore</coupon_code>\n    <name>New Coupon Name</name>\n    <state>redeemable</state>\n    <description>New coupon description for the hosted pages.</description>\n    <discount_type>percent</discount_type>\n    <discount_percent type=\"integer\">10</discount_percent>\n    <invoice_description>New coupon description for the invoice.</invoice_description>\n    <redeem_by_date type=\"datetime\">2015-12-31T00:00:00Z</redeem_by_date>\n    <single_use type=\"boolean\">false</single_use>\n    <applies_for_months nil=\"nil\"></applies_for_months>\n    <max_redemptions type=\"integer\">500</max_redemptions>\n    <applies_to_all_plans type=\"boolean\">true</applies_to_all_plans>\n    <created_at type=\"datetime\">2015-10-05T16:42:32Z</created_at>\n    <duration>forever</duration>\n    <temporal_unit nil=\"nil\"></temporal_unit>\n    <temporal_amount nil=\"nil\"></temporal_amount>\n    <applies_to_non_plan_charges type=\"boolean\">false</applies_to_non_plan_charges>\n    <redemption_resource>account</redemption_resource>\n    <max_redemptions_per_account type=\"integer\">1</max_redemptions_per_account>\n    <coupon_type>single_code</coupon_type>\n    <deleted_at nil=\"nil\"></deleted_at>\n    <plan_codes type=\"array\"></plan_codes>\n    <a name=\"redeem\" href=\"https://your-subdomain.recurly.com/v2/coupons/savemore/redeem\" method=\"post\"/>\n</coupon>","language":"json","status":200},{"name":"Field Not Editable","code":"<error>\n    <symbol>attributes_not_allowed</symbol>\n    <description>You are not allowed to edit attributes discount_type.</description>\n</error>","language":"xml","status":400},{"code":"<error>\n    <symbol>active_coupon</symbol>\n    <description>Restoring an active coupon is not allowed</description>\n</error>","language":"xml","status":400,"name":"Active Coupon"}]},"settings":"","auth":"required","params":[{"_id":"5617ed9f26e3db230054fc1c","ref":"","required":false,"desc":"Coupon name","default":"","type":"string","name":"name"},{"_id":"5617ed9f26e3db230054fc1b","ref":"","required":false,"desc":"Description of the coupon on the hosted payment pages","default":"","type":"string","name":"description"},{"_id":"5617ed9f26e3db230054fc1a","ref":"","required":false,"desc":"Description of the coupon on the invoice","default":"","type":"string","name":"invoice_description"},{"_id":"5617ed9f26e3db230054fc19","ref":"","required":false,"desc":"Last date to redeem the coupon, defaults to no date","default":"","type":"datetime","name":"redeem_by_date"},{"_id":"5617ed9f26e3db230054fc18","ref":"","required":false,"desc":"Maximum number of accounts that may use the coupon before it can no longer be redeemed","default":"","type":"int","name":"max_redemptions"},{"_id":"5617ed9f26e3db230054fc17","ref":"","required":false,"desc":"The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.","default":"","type":"int","name":"max_redemptions_per_account"}],"url":"/coupons/:coupon_code/restore"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"If you aren't going to change anything in the restore action, include the coupon parameter: <coupon/>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Restore Coupon That Reached Redeem By Date\"\n}\n[/block]\nIf your coupon has a redeem by date in the past, you must remove the date or change it to a future date, otherwise you will get this error:\n\n```\n<errors>\n    <error field=\"coupon.redeem_by_date\" symbol=\"in_past\">must be in the future</error>\n</errors>\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Restore Coupon That Reached Max Redemptions\"\n}\n[/block]\nIf your coupon has reached it's max redemptions, you must remove the max redemptions or change it to a greater number. You cannot set max redemptions to anything less than the number of redemptions you have. If you do not update max redemptions in this case, you will get this error.\n\n```\n<errors>\n    <error field=\"coupon.max_redemptions\" symbol=\"too_low\">must be greater than 100</error>\n</errors>\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Restoring Bulk Coupons or Unique Codes\"\n}\n[/block]\nRestoring a bulk coupon will restore the coupon campaign and all unique codes that have not been redeemed or individually expired.\n\nYou can restore an individual unique code if the bulk coupon is active by using the unique code's coupon code in the call.","category":"56fd7e6b5a08190e00084f4d","createdAt":"2015-10-09T16:38:55.663Z","excerpt":"Make an expired coupon redeemable again. You can change editable fields in this call.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":7,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"restore-coupon","sync_unique":"","title":"Restore Coupon","type":"put","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putRestore Coupon

Make an expired coupon redeemable again. You can change editable fields in this call.

name:
string
Coupon name
description:
string
Description of the coupon on the hosted payment pages
invoice_description:
string
Description of the coupon on the invoice
redeem_by_date:
datetime
Last date to redeem the coupon, defaults to no date
max_redemptions:
integer
Maximum number of accounts that may use the coupon before it can no longer be redeemed
max_redemptions_per_account:
integer
The number of times the coupon can be redeemed on a specific account. Null is the default and means unlimited.
[block:callout] { "type": "info", "body": "If you aren't going to change anything in the restore action, include the coupon parameter: <coupon/>" } [/block] [block:api-header] { "type": "basic", "title": "Restore Coupon That Reached Redeem By Date" } [/block] If your coupon has a redeem by date in the past, you must remove the date or change it to a future date, otherwise you will get this error: ``` <errors> <error field="coupon.redeem_by_date" symbol="in_past">must be in the future</error> </errors> ``` [block:api-header] { "type": "basic", "title": "Restore Coupon That Reached Max Redemptions" } [/block] If your coupon has reached it's max redemptions, you must remove the max redemptions or change it to a greater number. You cannot set max redemptions to anything less than the number of redemptions you have. If you do not update max redemptions in this case, you will get this error. ``` <errors> <error field="coupon.max_redemptions" symbol="too_low">must be greater than 100</error> </errors> ``` [block:api-header] { "type": "basic", "title": "Restoring Bulk Coupons or Unique Codes" } [/block] Restoring a bulk coupon will restore the coupon campaign and all unique codes that have not been redeemed or individually expired. You can restore an individual unique code if the bulk coupon is active by using the unique code's coupon code in the call.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "body": "If you aren't going to change anything in the restore action, include the coupon parameter: <coupon/>" } [/block] [block:api-header] { "type": "basic", "title": "Restore Coupon That Reached Redeem By Date" } [/block] If your coupon has a redeem by date in the past, you must remove the date or change it to a future date, otherwise you will get this error: ``` <errors> <error field="coupon.redeem_by_date" symbol="in_past">must be in the future</error> </errors> ``` [block:api-header] { "type": "basic", "title": "Restore Coupon That Reached Max Redemptions" } [/block] If your coupon has reached it's max redemptions, you must remove the max redemptions or change it to a greater number. You cannot set max redemptions to anything less than the number of redemptions you have. If you do not update max redemptions in this case, you will get this error. ``` <errors> <error field="coupon.max_redemptions" symbol="too_low">must be greater than 100</error> </errors> ``` [block:api-header] { "type": "basic", "title": "Restoring Bulk Coupons or Unique Codes" } [/block] Restoring a bulk coupon will restore the coupon campaign and all unique codes that have not been redeemed or individually expired. You can restore an individual unique code if the bulk coupon is active by using the unique code's coupon code in the call.
{"__v":0,"_id":"56fd7e6b5a08190e00084f78","api":{"examples":{"codes":[{"name":"","code":"try {\n  $account = Recurly_Account::get('b6f5783');\n  if ($account->redemptions) {\n    $redemptions = $account->redemptions->get();\n    print \"Redemptions: $redemptions\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Account not found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\nredemptions = account.redemptions","language":"ruby"},{"code":"account = Account.get('1')\nredemptions = account.redemptions()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar redemptions = account.GetActiveRedemptions();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<redemptions type=\"array\">\n\t<redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemptions/316a4213e8fa9e97390aff4995bda9e6\">\n  \t<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\"/>\n  \t<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/315fbd7a25b04f1333ea9f4418994fb5\"/>\n    <uuid>316a4213e8fa9e97390aff4995bda9e6</uuid>\n \t \t<single_use type=\"boolean\">false</single_use>\n \t \t<total_discounted_in_cents type=\"integer\">0</total_discounted_in_cents>\n  \t<currency>USD</currency>\n  \t<state>active</state>\n \t \t<created_at type=\"datetime\">2015-09-23T17:13:30Z</created_at>\n\t</redemption>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemptions/3169fd6127ff82ccbfa08a442188d575\">\n  \t<coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\"/>\n  \t<account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <uuid>3169fd6127ff82ccbfa08a442188d575</uuid>\n \t \t<single_use type=\"boolean\">false</single_use>\n \t \t<total_discounted_in_cents type=\"integer\">1500</total_discounted_in_cents>\n  \t<currency>USD</currency>\n  \t<state>active</state>\n \t \t<created_at type=\"datetime\">2011-06-27T12:34:56Z</created_at>\n\t</redemption>\n</redemptions>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"5612b8160157131900b458c2","ref":"","required":false,"desc":"The unique id of the coupon redemption","default":"","type":"string","name":"uuid"},{"_id":"558206aba5474a0d00d94777","ref":"","required":false,"desc":"DEPRECATED: True if the coupon is valid for one use only","default":"","type":"boolean","name":"single_use"},{"_id":"558206aba5474a0d00d94776","ref":"","required":false,"desc":"Total discount amount the redemption has created on the account so far","default":"","type":"int","name":"total_discounted_in_cents"},{"_id":"558206aba5474a0d00d94775","ref":"","required":false,"desc":"Currency of the redemption","default":"","type":"string","name":"currency"},{"_id":"558206aba5474a0d00d94774","ref":"","required":false,"desc":"State of the redemption","default":"","type":"string","name":"state"},{"_id":"558206aba5474a0d00d94773","ref":"","required":false,"desc":"Date the coupon was redeemed","default":"","type":"timestamp","name":"created_at"}],"url":"/accounts/:account_code/redemptions"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"If you use the singular, \\\"redemption\\\", in the endpoint, you will only see the most recently redeemed redemption.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4e","createdAt":"2015-06-17T23:45:47.017Z","excerpt":"Lookup information about the coupon redemptions on an account. Active and naturally expired limited  duration redemptions will be returned. Redemptions removed from the account or expired single use coupons will not be returned.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-a-coupon-redemption-on-an-account","sync_unique":"","title":"Lookup a Coupon Redemption on an Account","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup a Coupon Redemption on an Account

Lookup information about the coupon redemptions on an account. Active and naturally expired limited duration redemptions will be returned. Redemptions removed from the account or expired single use coupons will not be returned.

uuid:
string
The unique id of the coupon redemption
single_use:
boolean
DEPRECATED: True if the coupon is valid for one use only
total_discounted_in_cents:
integer
Total discount amount the redemption has created on the account so far
currency:
string
Currency of the redemption
state:
string
State of the redemption
created_at:
timestamp
Date the coupon was redeemed
[block:callout] { "type": "warning", "body": "If you use the singular, \"redemption\", in the endpoint, you will only see the most recently redeemed redemption." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "If you use the singular, \"redemption\", in the endpoint, you will only see the most recently redeemed redemption." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f79","api":{"examples":{"codes":[{"name":"","code":"$invoice = Recurly_Invoice::get('1');\nif($invoice->redemptions) {\n  $redemptions = $invoice->redemptions->get();\n}","language":"php"},{"code":"invoice = Recurly::Invoice.find('1')\nredemptions = invoice.redemptions","language":"ruby"},{"code":"invoice = Invoice.get('1')\nredemptions = invoice.redemptions()","language":"python"},{"code":"var invoice = Invoices.Get(1);\nvar redemptions = invoice.GetRedemptions();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<redemptions type=\"array\">\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemptions/316a4213e8fa9e97390aff4995bda9e6\">\n    <coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\"/>\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/315fbd7a25b04f1333ea9f4418994fb5\"/>\n    <uuid>316a4213e8fa9e97390aff4995bda9e6</uuid>\n    <single_use type=\"boolean\">false</single_use>\n    <total_discounted_in_cents type=\"integer\">100</total_discounted_in_cents>\n    <currency>USD</currency>\n    <state>active</state>\n    <created_at type=\"datetime\">2015-09-23T17:13:30Z</created_at>\n  </redemption>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemptions/3169fd6127ff82ccbfa08a442188d575\">\n    <coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\"/>\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <uuid>3169fd6127ff82ccbfa08a442188d575</uuid>\n    <single_use type=\"boolean\">false</single_use>\n    <total_discounted_in_cents type=\"integer\">1500</total_discounted_in_cents>\n    <currency>USD</currency>\n    <state>active</state>\n    <created_at type=\"datetime\">2011-06-27T12:34:56Z</created_at>\n  </redemption>\n</redemptions>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"5612b9086b598823008f3042","ref":"","required":false,"desc":"The unique id of the coupon redemption","default":"","type":"string","name":"uuid"},{"_id":"5582080e8625220d00429f3d","ref":"","required":false,"desc":"DEPRECATED: True if the coupon is valid for one use only","default":"","type":"boolean","name":"single_use"},{"_id":"5582080e8625220d00429f3c","ref":"","required":false,"desc":"Total discount amount the redemption created on the invoice","default":"","type":"int","name":"total_discounted_in_cents"},{"_id":"5582080e8625220d00429f3b","ref":"","required":false,"desc":"Currency of the redemption","default":"","type":"string","name":"currency"},{"_id":"5582080e8625220d00429f3a","ref":"","required":false,"desc":"State of the redemption","default":"","type":"string","name":"state"},{"_id":"5582080e8625220d00429f39","ref":"","required":false,"desc":"Date the coupon was redeemed","default":"","type":"timestamp","name":"created_at"}],"url":"/invoices/:invoice_number/redemptions"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"If you use the singular, \\\"redemption\\\", in the endpoint, you will only see the first redemption applied to the invoice.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4e","createdAt":"2015-06-17T23:51:42.344Z","excerpt":"Returns all coupon redemptions that discounted the invoice.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-a-coupon-redemption-on-an-invoice","sync_unique":"","title":"Lookup a Coupon Redemption on an Invoice","type":"get","updates":["569fc5bf1082520d005c7096"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup a Coupon Redemption on an Invoice

Returns all coupon redemptions that discounted the invoice.

uuid:
string
The unique id of the coupon redemption
single_use:
boolean
DEPRECATED: True if the coupon is valid for one use only
total_discounted_in_cents:
integer
Total discount amount the redemption created on the invoice
currency:
string
Currency of the redemption
state:
string
State of the redemption
created_at:
timestamp
Date the coupon was redeemed
[block:callout] { "type": "warning", "body": "If you use the singular, \"redemption\", in the endpoint, you will only see the first redemption applied to the invoice." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "If you use the singular, \"redemption\", in the endpoint, you will only see the first redemption applied to the invoice." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f7a","api":{"examples":{"codes":[{"name":"","code":"<?php\n$coupon = Recurly_Coupon::get('special');\n$redemption = $coupon->redeemCoupon('1', 'USD');\n?>","language":"php"},{"code":"account = Recurly::Account.find('1')\ncoupon = Recurly::Coupon.find('special')\nredemption = coupon.redeem(account)","language":"ruby"},{"code":"coupon = Coupon.get('special')\nredemption = Redemption(account_code='1', currency='USD')\n\n# new redemption object returned from this method will contain the updates\n# so we overwrite the redemption variable\nredemption = coupon.redeem(redemption)","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar redemption = account.RedeemCoupon(\"special\", \"USD\");","language":"csharp"},{"code":"<redemption>\n  <account_code>1</account_code>\n  <currency>USD</currency>\n</redemption>","language":"xml"}]},"results":{"codes":[{"status":201,"language":"xml","code":"<redemption href=\"https://your-subdomain.recurly.com/v2/accounts/1/redemptions/316a4213e8fa9e97390aff4995bda9e6\">\n    <coupon href=\"https://your-subdomain.recurly.com/v2/coupons/special\"/>\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/315fbd7a25b04f1333ea9f4418994fb5\"/>\n    <uuid>316a4213e8fa9e97390aff4995bda9e6</uuid>\n    <single_use type=\"boolean\">false</single_use>\n    <total_discounted_in_cents type=\"integer\">0</total_discounted_in_cents>\n    <currency>USD</currency>\n    <state>active</state>\n    <created_at type=\"datetime\">2015-09-23T17:13:30Z</created_at>\n  </redemption>","name":""},{"name":"Expired/Invalid","status":400,"language":"xml","code":"<error>\n    <symbol>not_found</symbol>\n    <description lang=\"en-US\">Couldn't find Coupon with coupon_code = savemore</description>\n</error>"}]},"settings":"","auth":"required","params":[{"_id":"55820401a5474a0d00d94750","ref":"","required":true,"desc":"Account code to apply redemption","default":"","type":"int","name":"account_code"},{"_id":"55820401a5474a0d00d9474f","ref":"","required":true,"desc":"Currency for the redemption","default":"","type":"string","name":"currency"},{"_id":"5612ba16cb0e892300d89229","ref":"","required":false,"desc":"If the coupon has a redemption_resource of subscription, you will need to specify the uuid of an existing subscription on the account, which you want to tie the redemption to","default":"","type":"string","name":"subscription_uuid"}],"url":"/coupons/:coupon_code/redeem"},"body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"If you want the coupon redemption to be rejected if a subscription signup fails, you must redeem the coupon within the Create Subscription call, not in the Redeem on Account call.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Redeeming Multiple Coupons\"\n}\n[/block]\nIf you have Multiple Coupons Per Account enabled in Coupon Settings, you can have multiple active redemptions on an account. Call this redeem endpoint multiple times to redeem more than one coupon.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Maxed Out Error\"\n}\n[/block]\nIf a coupon can only be redeemed on an account a specific number of times and you have already redeemed the coupon that number of times on the account, you will see a maxed out error letting you know the coupon can no longer be redeemed on the account.\n\n```\n<errors>\n    <error field=\"coupon.base\" symbol=\"maxed_out_for_account\">Coupon has reached max redemptions for this account</error>\n</errors>\n```\n\n The only way you would be able to redeem this coupon again on the account would be to update the main coupon campaign to allow more redemptions per account.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Subscription-Level Redemption\"\n}\n[/block]\nIf the coupon is subscription-level, meaning it has a redemption_resource of \"subscription\", you must specify the subscription_uuid of an existing subscription on the account that you want to tie the redemption to. Otherwise you will get this error:\n\n```\n<errors>\n    <error field=\"coupon.subscription\" symbol=\"must_be_present\">must be redeemed on a subscription</error>\n</errors>\n```\n\nIf the subscription_uuid you provide is for a subscription with a plan not eligible for the coupon, you will see this error:\n\n```\n<errors>\n    <error field=\"coupon.subscription_uuid\" symbol=\"not_valid_for_redemption\">not valid for this coupon</error>\n</errors>\n```","category":"56fd7e6b5a08190e00084f4e","createdAt":"2015-06-17T23:34:25.304Z","excerpt":"Redeem a coupon on an existing customer's account to apply to their next invoice.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"redeem-a-coupon-before-or-after-a-subscription","sync_unique":"","title":"Redeem a Coupon on an Account","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postRedeem a Coupon on an Account

Redeem a coupon on an existing customer's account to apply to their next invoice.

account_code:
required
integer
Account code to apply redemption
currency:
required
string
Currency for the redemption
subscription_uuid:
string
If the coupon has a redemption_resource of subscription, you will need to specify the uuid of an existing subscription on the account, which you want to tie the redemption to
[block:callout] { "type": "danger", "body": "If you want the coupon redemption to be rejected if a subscription signup fails, you must redeem the coupon within the Create Subscription call, not in the Redeem on Account call." } [/block] [block:api-header] { "type": "basic", "title": "Redeeming Multiple Coupons" } [/block] If you have Multiple Coupons Per Account enabled in Coupon Settings, you can have multiple active redemptions on an account. Call this redeem endpoint multiple times to redeem more than one coupon. [block:api-header] { "type": "basic", "title": "Maxed Out Error" } [/block] If a coupon can only be redeemed on an account a specific number of times and you have already redeemed the coupon that number of times on the account, you will see a maxed out error letting you know the coupon can no longer be redeemed on the account. ``` <errors> <error field="coupon.base" symbol="maxed_out_for_account">Coupon has reached max redemptions for this account</error> </errors> ``` The only way you would be able to redeem this coupon again on the account would be to update the main coupon campaign to allow more redemptions per account. [block:api-header] { "type": "basic", "title": "Subscription-Level Redemption" } [/block] If the coupon is subscription-level, meaning it has a redemption_resource of "subscription", you must specify the subscription_uuid of an existing subscription on the account that you want to tie the redemption to. Otherwise you will get this error: ``` <errors> <error field="coupon.subscription" symbol="must_be_present">must be redeemed on a subscription</error> </errors> ``` If the subscription_uuid you provide is for a subscription with a plan not eligible for the coupon, you will see this error: ``` <errors> <error field="coupon.subscription_uuid" symbol="not_valid_for_redemption">not valid for this coupon</error> </errors> ```

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "danger", "body": "If you want the coupon redemption to be rejected if a subscription signup fails, you must redeem the coupon within the Create Subscription call, not in the Redeem on Account call." } [/block] [block:api-header] { "type": "basic", "title": "Redeeming Multiple Coupons" } [/block] If you have Multiple Coupons Per Account enabled in Coupon Settings, you can have multiple active redemptions on an account. Call this redeem endpoint multiple times to redeem more than one coupon. [block:api-header] { "type": "basic", "title": "Maxed Out Error" } [/block] If a coupon can only be redeemed on an account a specific number of times and you have already redeemed the coupon that number of times on the account, you will see a maxed out error letting you know the coupon can no longer be redeemed on the account. ``` <errors> <error field="coupon.base" symbol="maxed_out_for_account">Coupon has reached max redemptions for this account</error> </errors> ``` The only way you would be able to redeem this coupon again on the account would be to update the main coupon campaign to allow more redemptions per account. [block:api-header] { "type": "basic", "title": "Subscription-Level Redemption" } [/block] If the coupon is subscription-level, meaning it has a redemption_resource of "subscription", you must specify the subscription_uuid of an existing subscription on the account that you want to tie the redemption to. Otherwise you will get this error: ``` <errors> <error field="coupon.subscription" symbol="must_be_present">must be redeemed on a subscription</error> </errors> ``` If the subscription_uuid you provide is for a subscription with a plan not eligible for the coupon, you will see this error: ``` <errors> <error field="coupon.subscription_uuid" symbol="not_valid_for_redemption">not valid for this coupon</error> </errors> ```
{"__v":0,"_id":"56fd7e6b5a08190e00084f7b","api":{"examples":{"codes":[{"name":"","code":"<?php\n$redemption = Recurly_CouponRedemption::get('account_code');\n$redemption->delete();\n?>","language":"php"},{"code":"account = Recurly::Account.find('1')\nredemption = account.redemption\nredemption.destroy","language":"ruby"},{"code":"account = Account.get('1')\nredemption = account.redemption()\nredemption.delete()","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar redemption = account.GetActiveRedemption();\nredemption.Delete();","language":"csharp"}]},"results":{"codes":[{"status":204,"language":"xml","code":"Status: 204 No Content"}]},"settings":"","auth":"required","params":[],"url":"/accounts/:account_code/redemptions/:uuid"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Specify the specific redemption uuid if you are allowing multiple active coupon redemptions on an account at a time. Otherwise, you can do a simple /redemption and automatically remove the most recent redemption on the account.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4e","createdAt":"2015-06-17T23:48:14.667Z","excerpt":"Manually expire a coupon redemption on an account. Please note: the coupon redemption will still count towards the \"maximum redemption total\" of the coupon.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"remove-a-coupon-from-an-account","sync_unique":"","title":"Remove a Coupon Redemption from an Account","type":"delete","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteRemove a Coupon Redemption from an Account

Manually expire a coupon redemption on an account. Please note: the coupon redemption will still count towards the "maximum redemption total" of the coupon.

[block:callout] { "type": "info", "body": "Specify the specific redemption uuid if you are allowing multiple active coupon redemptions on an account at a time. Otherwise, you can do a simple /redemption and automatically remove the most recent redemption on the account." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "body": "Specify the specific redemption uuid if you are allowing multiple active coupon redemptions on an account at a time. Otherwise, you can do a simple /redemption and automatically remove the most recent redemption on the account." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f65","api":{"examples":{"codes":[{"name":"","code":"$invoices = Recurly_InvoiceList::get();\nforeach ($invoices as $invoice) {\n  print \"Invoice: $invoice\\n\";\n}","language":"php"},{"language":"ruby","code":"Recurly::Invoice.find_each do |invoice|\n  puts \"Invoice: #{invoice.inspect}\"\nend"},{"language":"python","code":"#client version <= 2.1.5\ninvoices = Invoice.all()\nwhile invoices:\n    for invoice in invoices:\n        print 'Invoice: %s' % invoice\n    try:\n        invoices = invoices.next_page()\n    except PageError:\n        invoices = ()\n# ...or...\npast_due = Invoice.all_past_due()\n\n#client version 2.1.6+\nfor invoice in Invoice.all():\n    print 'Invoice: %s' % invoice"},{"language":"csharp","code":"using System.Linq;\n\nvar invoices = Invoices.List();\nwhile (invoices.Any())\n{\n\tforeach (var invoice in invoices)\n\t\tConsole.WriteLine(\"Invoice: \" + invoice);\n\tinvoices = invoices.Next;\n}"}]},"results":{"codes":[{"status":200,"language":"xml","code":"<invoices type=\"array\">\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1005\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <address>\n        <address1>400 Alabama St.</address1>\n        <address2></address2>\n        <city>San Francisco</city>\n        <state>CA</state>\n        <zip>94110</zip>\n        <country>US</country>\n        <phone></phone>\n    </address>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n    <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n    <state>open</state>\n    <invoice_number_prefix></invoice_number_prefix> <!-- Only populated for VAT Country Invoice Sequencing. Shows a country code. -->\n    <invoice_number type=\"integer\">1005</invoice_number>\n    <po_number nil=\"nil\"></po_number>\n    <vat_number nil=\"nil\"></vat_number>\n    <subtotal_in_cents type=\"integer\">1200</subtotal_in_cents>\n    <tax_in_cents type=\"integer\">0</tax_in_cents>\n    <total_in_cents type=\"integer\">1200</total_in_cents>\n    <currency>USD</currency>\n    <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n    <closed_at nil=\"nil\"></closed_at>\n    <terms_and_conditions></terms_and_conditions>\n    <customer_notes></customer_notes>\n    <vat_reverse_charge_notes></vat_reverse_charge_notes> <!-- Only shows if reverse charge invoice -->\n    <tax_type>usst</tax_type> <!-- Only shows if tax on invoice -->\n\t\t<tax_region>CA</tax_region> <!-- Only shows if tax on invoice -->\n    <tax_rate type=\"float\">0</tax_rate> <!-- Only shows if tax on invoice -->\n    <net_terms type=\"integer\">0</net_terms>\n    <collection_method>automatic</collection_method>\n    <redemptions href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemptions\"/>\n    <line_items type=\"array\">\n      <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\">\n        <!-- Detail. -->\n      </adjustment>\n    </line_items>\n    <transactions type=\"array\">\n    </transactions>\n  </invoice>\n  <!-- Continued... -->\n</invoices>","name":""}]},"settings":"","auth":"required","params":[{"_id":"5582f2ae81672a3900bb4fe3","ref":"","required":false,"desc":"The state of invoices to return: \"open\", \"collected\", \"failed\", or \"past_due\".","default":"all","type":"string","name":"state"},{"_id":"5582f2ae81672a3900bb4fe2","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"int","name":"cursor"},{"_id":"5582f2ae81672a3900bb4fe1","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"int","name":"per_page"}],"url":"/invoices"},"body":"**INVOICE STATES**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"State\",\n    \"h-1\": \"Description\",\n    \"0-1\": \"Open, pending collection\",\n    \"0-0\": \"`open`\",\n    \"null-0\": \"`\",\n    \"1-0\": \"`collected`\",\n    \"1-1\": \"Collection completed successfully\",\n    \"2-0\": \"`failed`\",\n    \"2-1\": \"Failed to collect\",\n    \"3-0\": \"`past_due`\",\n    \"3-1\": \"Initial collection failed, still attempting collection\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Please note: an invoice will only be in one state.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T16:32:46.758Z","excerpt":"Returns a list of all invoices.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-invoices","sync_unique":"","title":"List Invoices","type":"get","updates":["55b1055eb2405537003cd938"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Invoices

Returns a list of all invoices.

state:
stringall
The state of invoices to return: "open", "collected", "failed", or "past_due".
cursor:
integer
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
integer50
Number of records to return per page, up to a maximum of 200.
**INVOICE STATES** [block:parameters] { "data": { "h-0": "State", "h-1": "Description", "0-1": "Open, pending collection", "0-0": "`open`", "null-0": "`", "1-0": "`collected`", "1-1": "Collection completed successfully", "2-0": "`failed`", "2-1": "Failed to collect", "3-0": "`past_due`", "3-1": "Initial collection failed, still attempting collection" }, "cols": 2, "rows": 4 } [/block] [block:callout] { "type": "warning", "body": "Please note: an invoice will only be in one state." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



**INVOICE STATES** [block:parameters] { "data": { "h-0": "State", "h-1": "Description", "0-1": "Open, pending collection", "0-0": "`open`", "null-0": "`", "1-0": "`collected`", "1-1": "Collection completed successfully", "2-0": "`failed`", "2-1": "Failed to collect", "3-0": "`past_due`", "3-1": "Initial collection failed, still attempting collection" }, "cols": 2, "rows": 4 } [/block] [block:callout] { "type": "warning", "body": "Please note: an invoice will only be in one state." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f66","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoices = Recurly_InvoiceList::getForAccount('b6f5783');\n  foreach ($invoices as $invoice) {\n    print \"Invoice: {$invoice}\\n\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Account not found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.invoices.find_each do |invoice|\n  puts \"Invoice: #{invoice.inspect}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\naccount = Account.get('1')\ninvoices = account.invoices()\nwhile invoices:\n    for invoice in invoices:\n        print 'Invoice: %s' % invoice\n    try:\n        invoices = invoices.next_page()\n    except PageError:\n        invoices = ()\n\n#client version 2.1.6+\naccount = Account.get('1')\nfor invoices in account.invoices():\n    print 'Invoice: %s' % invoice","language":"python"},{"code":"using System.Linq;\n\n// Get the list of invoices through the Account\nvar account = Accounts.Get(\"1\");\nvar invoices = account.GetInvoices();\n\n// OR directly through Invoices\nvar invoices = Invoices.List(\"1\"); // account code\n\nwhile (invoices.Any())\n{\n\tforeach (var invoice in invoices)\n\t\tConsole.WriteLine(\"Invoice: \" + invoice);\n\tinvoices = invoices.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<invoices type=\"array\">\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1005\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <address>\n    \t<address1></address1>\n      <address2></address2>\n      <city></city>\n      <state></state>\n      <zip></zip>\n      <country></country>\n      <phone></phone>\n    </address>\n    <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n    <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n    <state>open</state>\n    <invoice_number_prefix></invoice_number_prefix> <!-- Only populated for VAT Country Invoice Sequencing. Shows a country code. -->\n    <invoice_number type=\"integer\">1005</invoice_number>\n    <po_number nil=\"nil\"></po_number>\n    <vat_number nil=\"nil\"></vat_number>\n    <subtotal_in_cents type=\"integer\">1200</subtotal_in_cents>\n    <tax_in_cents type=\"integer\">0</tax_in_cents>\n    <total_in_cents type=\"integer\">1200</total_in_cents>\n    <currency>USD</currency>\n    <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n    <closed_at nil=\"nil\"></closed_at>\n    <terms_and_conditions></terms_and_conditions>\n    <customer_notes></customer_notes>\n    <vat_reverse_charge_notes></vat_reverse_charge_notes> <!-- Only shows if reverse charge invoice -->\n    <tax_type>usst</tax_type> <!-- Only shows if tax on invoice -->\n\t\t<tax_region>CA</tax_region> <!-- Only shows if tax on invoice -->\n    <tax_rate type=\"float\">0</tax_rate> <!-- Only shows if tax on invoice -->\n    <net_terms type=\"integer\">0</net_terms>\n    <collection_method>automatic</collection_method>\n    <redemptions href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemptions\"/>\n    <line_items type=\"array\">\n      <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\"/>\n        <!-- Detail. -->\n      </adjustment>\n    </line_items>\n    <transactions type=\"array\">\n    </transactions>\n  </invoice>\n  <!-- Continued... -->\n</invoices>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"5582f72aea39a939002242f5","ref":"","required":false,"desc":"The state of invoices to return: \"open\", \"collected\", \"failed\", or \"past_due\".","default":"all","type":"string","name":"state"},{"_id":"5582f72aea39a939002242f4","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"5582f72aea39a939002242f3","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"int","name":"per_page"}],"url":"/accounts/:account_code/invoices"},"body":"","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T16:51:54.366Z","excerpt":"Returns a list of all the invoices.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-an-accounts-invoices","sync_unique":"","title":"List an Account's Invoices","type":"get","updates":["55b103aab3a7e037008ac0d7"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList an Account's Invoices

Returns a list of all the invoices.

state:
stringall
The state of invoices to return: "open", "collected", "failed", or "past_due".
cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
integer50
Number of records to return per page, up to a maximum of 200.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f67","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoice = Recurly_Invoice::get('1001');\n  print \"Invoice: $invoice\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice not found: $e\";\n}","language":"php"},{"code":"invoice = Recurly::Invoice.find('1005')","language":"ruby"},{"code":"invoice = Invoice.get('1005')","language":"python"},{"code":"var invoice = Invoices.Get(1005);","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1402\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <address>\n      <address1>400 Alabama St.</address1>\n      <address2></address2>\n      <city>San Francisco</city>\n      <state>CA</state>\n      <zip>94110</zip>\n      <country>US</country>\n      <phone></phone>\n    </address>\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>open</state>\n  <invoice_number_prefix></invoice_number_prefix> <!-- Only populated for VAT Country Invoice Sequencing. Shows a country code. -->\n  <invoice_number type=\"integer\">1402</invoice_number>\n  <po_number nil=\"nil\"></po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">9900</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">9900</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <terms_and_conditions></terms_and_conditions>\n  <customer_notes></customer_notes>\n  <vat_reverse_charge_notes></vat_reverse_charge_notes> <!-- Only shows if reverse charge invoice -->\n  <tax_type>usst</tax_type> <!-- Only shows if tax on invoice -->\n\t<tax_region>CA</tax_region> <!-- Only shows if tax on invoice -->\n  <tax_rate type=\"float\">0</tax_rate> <!-- Only shows if tax on invoice -->\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <redemptions href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemptions\"/>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\"/>\n      <!-- Detail. -->\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/invoices/:invoice_number"},"body":"**PAYMENTS**\nRecurly returns an array of payments applied to an Invoice. At the moment, there is usually only one successful payment per invoice. The API only returns successful payments—it does not return failed payment attempts on an invoice nor does it return refunds on payments made to an invoice.","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T16:56:30.329Z","excerpt":"Lookup an invoice to retrieve detailed information about its line items and payments.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-invoice-details","sync_unique":"","title":"Lookup Invoice Details","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup Invoice Details

Lookup an invoice to retrieve detailed information about its line items and payments.

**PAYMENTS** Recurly returns an array of payments applied to an Invoice. At the moment, there is usually only one successful payment per invoice. The API only returns successful payments—it does not return failed payment attempts on an invoice nor does it return refunds on payments made to an invoice.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



**PAYMENTS** Recurly returns an array of payments applied to an Invoice. At the moment, there is usually only one successful payment per invoice. The API only returns successful payments—it does not return failed payment attempts on an invoice nor does it return refunds on payments made to an invoice.
{"__v":0,"_id":"56fd7e6b5a08190e00084f68","api":{"examples":{"codes":[{"name":"","code":"try {\n  $pdf = Recurly_Invoice::getInvoicePdf('1005');\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice not found: $e\";\n}","language":"php"},{"code":"begin\n  pdf = Recurly::Invoice.find(\n    'invoice_number', :format => 'pdf'\n  )\nrescue Recurly::Resource::NotFound => e\n  puts 'Invoice not found.'\nend","language":"ruby"},{"code":"with open('invoice.pdf', 'w') as invoice_file:\n    invoice_file.write(recurly.Invoice.pdf('invoice_number'))","language":"python"},{"code":"var invoice = Invoices.Get(1005);\nbyte[] pdf = invoice.GetPdf();","language":"csharp"}]},"results":{"codes":[{"code":"","language":"text"}]},"settings":"","auth":"required","params":[{"_id":"55c8d2fb71d7580d0063a5f1","ref":"","required":true,"desc":"Instructs the API to return the invoice as a PDF.","default":"","type":"string","name":"Accept"},{"_id":"55c8d2fb71d7580d0063a5f0","ref":"","required":false,"desc":"An [ISO-639-1 abbreviation](http://www.loc.gov/standards/iso639-2/php/code_list.php) of a [language supported by Recurly](https://docs.recurly.com/hosted-payment-pages#internationalized_hosted_payment_pages) The language that the PDF will be translated into. If this header is not used, the PDF returned will be in English.","default":"English","type":"string","name":"Accept-Language"}],"url":"/invoices/:invoice_number"},"body":"","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:02:18.864Z","excerpt":"To retrieve a PDF invoice, modify the headers to request the `Accept` as `application/pdf`.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"retrieve-a-pdf-invoice","sync_unique":"","title":"Retrieve a PDF Invoice","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getRetrieve a PDF Invoice

To retrieve a PDF invoice, modify the headers to request the `Accept` as `application/pdf`.

Accept:
required
string
Instructs the API to return the invoice as a PDF.
Accept-Language:
stringEnglish
An [ISO-639-1 abbreviation](http://www.loc.gov/standards/iso639-2/php/code_list.php) of a [language supported by Recurly](https://docs.recurly.com/hosted-payment-pages#internationalized_hosted_payment_pages) The language that the PDF will be translated into. If this header is not used, the PDF returned will be in English.

Definition

{{ api_url }}{{ page_api_url }}

Examples



{"__v":0,"_id":"56fd7e6b5a08190e00084f69","api":{"examples":{"codes":[{"name":"","code":"account = Recurly::Account.find('1')\ninvoice = account.build_invoice","language":"ruby"}]},"results":{"codes":[{"name":"","code":"<invoice href=\"\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <address>\n    <address1>123 Main St</address1>\n    <address2></address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>12345</zip>\n    <country>US</country>\n    <phone></phone>\n  </address>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>open</state>\n  <invoice_number type=\"integer\">1005</invoice_number>\n  <po_number nil=\"nil\"></po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">1200</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">1200</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0</tax_rate>\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\"/>\n      <!-- Detail. -->\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/accounts/:account_code/invoices/preview"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:07:20.716Z","excerpt":"Preview allows you to display the invoice details, including estimated tax, before you post it.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"preview-an-invoice","sync_unique":"","title":"Preview an Invoice","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postPreview an Invoice

Preview allows you to display the invoice details, including estimated tax, before you post it.

[block:callout] { "type": "warning", "body": "This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f6a","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoice = Recurly_Invoice::invoicePendingCharges('b6f5783');\n\n  print \"Invoice: $invoice\";\n} catch (Recurly_ValidationError $e) {\n  print \"No Charges to invoice: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Account not found: $e\";\n}","language":"php"},{"code":"account = Recurly::Account.find('1')\n\n# invoice! takes invoice attributes as an optional argument\ninvoice = account.invoice!(terms_and_conditions: 't and c', customer_notes: 'notes')","language":"ruby"},{"code":"account = Account.get('1')\n\n# invoice() takes invoice attributes as optional kwargs\ninvoice = account.invoice(terms_and_conditions=\"t and c\", customer_notes=\"notes\")","language":"python"},{"code":"var account = Accounts.Get(\"1\");\nvar invoice = account.InvoicePendingCharges();","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1005\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>open</state>\n  <invoice_number type=\"integer\">1005</invoice_number>\n  <po_number nil=\"nil\">34A-B324</po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">1200</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">1200</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0</tax_rate>\n  <net_terms type=\"integer\">30</net_terms>\n  <collection_method>manual</collection_method>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemption\"/>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\"/>\n      <!-- Detail. -->\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55c8c16d229b981900ed5fd6","ref":"","required":false,"desc":"Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.","default":"","type":"string","name":"terms_and_conditions"},{"_id":"55c8c16d229b981900ed5fd5","ref":"","required":false,"desc":"Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add Customer Notes. Custom notes made on an invoice for a one time charge will not carry over to subsequent invoices.","default":"","type":"string","name":"customer_notes"},{"_id":"55c8c16d229b981900ed5fd4","ref":"","required":false,"desc":"VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. Specify custom notes with this tag to add or override VAT Reverse Charge Notes. Custom notes will stay with a subscription on all renewals.","default":"","type":"string","name":"vat_reverse_charge_notes"},{"_id":"55c8c16d229b981900ed5fd3","ref":"","required":false,"desc":"Can be either 'automatic' or 'manual'.","default":"automatic","type":"string","name":"collection_method"},{"_id":"55c8c16d229b981900ed5fd2","ref":"","required":false,"desc":"Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours after it’s created. If an invoice is due net 30, it will become past due at 31 days exactly.","default":"","type":"int","name":"net_terms"},{"_id":"55c8c16d229b981900ed5fd1","ref":"","required":false,"desc":"Optional notes field. Attach a PO number to the invoice.","default":"","type":"string","name":"po_number"}],"url":"/accounts/:account_code/invoices"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:12:51.925Z","excerpt":"When you post one-time charges to an account, these will remain pending until they are invoiced. An account is automatically invoiced when the subscription renews. However, there are times when it is appropriate to invoice an account before the renewal. If the subscriber has a yearly subscription, you might want to collect the one-time charges well before the renewal.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"post-an-invoice-invoice-pending-charges-on-an-acco","sync_unique":"","title":"Post an Invoice: Invoice Pending Charges on an Account","type":"post","updates":["563a80604cc3621900ac27f0"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postPost an Invoice: Invoice Pending Charges on an Account

When you post one-time charges to an account, these will remain pending until they are invoiced. An account is automatically invoiced when the subscription renews. However, there are times when it is appropriate to invoice an account before the renewal. If the subscriber has a yearly subscription, you might want to collect the one-time charges well before the renewal.

terms_and_conditions:
string
Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.
customer_notes:
string
Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add Customer Notes. Custom notes made on an invoice for a one time charge will not carry over to subsequent invoices.
vat_reverse_charge_notes:
string
VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. Specify custom notes with this tag to add or override VAT Reverse Charge Notes. Custom notes will stay with a subscription on all renewals.
collection_method:
stringautomatic
Can be either 'automatic' or 'manual'.
net_terms:
integer
Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours after it’s created. If an invoice is due net 30, it will become past due at 31 days exactly.
po_number:
string
Optional notes field. Attach a PO number to the invoice.
[block:callout] { "type": "warning", "body": "This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "This API call will return the new invoice's details on success. If there are no pending charges, it will return an HTTP status code of `422 Unprocessable Entity`." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f6b","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $invoice = Recurly_Invoice::get('1327');\n  $invoice->markSuccessful();\n\n  print \"Invoice: $invoice\";\n} catch (Recurly_ValidationError $e) {\n  print \"Could not mark paid: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice not found: $e\";\n}","name":""},{"language":"ruby","code":"invoice = Recurly::Invoice.find('1402')\ninvoice.mark_successful"},{"language":"python","code":"invoice = Invoice.get('1402')\ninvoice.mark_successful()"},{"language":"csharp","code":"var invoice = Invoices.Get(1005);\ninvoice.MarkSuccessful();"}]},"results":{"codes":[{"code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1402\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <address>\n      <address1>400 Alabama St.</address1>\n      <address2></address2>\n      <city>San Francisco</city>\n      <state>CA</state>\n      <zip>94110</zip>\n      <country>US</country>\n      <phone></phone>\n    </address>\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>collected</state>\n  <invoice_number_prefix></invoice_number_prefix> <!-- Only populated for VAT Country Invoice Sequencing. Shows a country code. -->\n  <invoice_number type=\"integer\">1402</invoice_number>\n  <po_number nil=\"nil\"></po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">9900</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">9900</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0</tax_rate>\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemption\"/>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\"/>\n      <!-- Detail. -->\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/invoices/:invoice_number/mark_successful"},"body":"","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:16:11.429Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":7,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"mark-an-invoice-as-paid-successfully","sync_unique":"","title":"Mark an Invoice as Paid Successfully","type":"put","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putMark an Invoice as Paid Successfully


Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f6c","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoice = Recurly_Invoice::get('1340');\n  $invoice->markFailed();\n\n  print \"Invoice: $invoice\";\n} catch (Recurly_ValidationError $e) {\n  print \"Could not mark failed: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice not found: $e\";\n}","language":"php"},{"code":"invoice = Recurly::Invoice.find('e3f0a9e084a2468480d00ee61b090d4d')\ninvoice.mark_failed","language":"ruby"},{"code":"invoice = Invoice.get('e3f0a9e084a2468480d00ee61b090d4d')\ninvoice.mark_failed()","language":"python"},{"code":"var invoice = Invoices.Get(1005);\ninvoice.MarkFailed();","language":"csharp"}]},"results":{"codes":[{"status":200,"language":"xml","code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1001\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <address>\n      <address1>400 Alabama St.</address1>\n      <address2></address2>\n      <city>San Francisco</city>\n      <state>CA</state>\n      <zip>94110</zip>\n      <country>US</country>\n      <phone></phone>\n    </address>\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/17caaca1716f33572edc8146e0aaefde\"/>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>failed</state>\n  <invoice_number_prefix></invoice_number_prefix> <!-- Only populated for VAT Country Invoice Sequencing. Shows a country code. -->\n  <invoice_number type=\"integer\">1402</invoice_number>\n  <po_number nil=\"nil\"></po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">9900</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">9900</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0</tax_rate>\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <redemption href=\"https://your-subdomain.recurly.com/v2/invoices/e3f0a9e084a2468480d00ee61b090d4d/redemption\"/>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\"/>\n      <!-- Detail. -->\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>"}]},"settings":"","auth":"required","params":[],"url":"/invoices/:invoice_number/mark_failed"},"body":"","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:16:28.049Z","excerpt":"","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":8,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"mark-an-invoice-as-failed-collection","sync_unique":"","title":"Mark an Invoice as Failed Collection","type":"put","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putMark an Invoice as Failed Collection


Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f6d","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoice = Recurly_Invoice::get('1341'); // get some invoice\n  $line_items = $invoice->line_items;      // get line items\n\n  // use Recurly_Adjustment->toRefundAttributes() to\n  // turn the line items you want into refund objects\n  // you can optionally pass in `prorated` and `quantity`\n  $adjustments = array_map(\n    function($line_item) { return $line_item->toRefundAttributes(); },\n    $invoice->line_items\n  );\n\n  // pass the refund attributes to the refund() method\n  // returns a new Recurly_Invoice\n  $refund_invoice = $invoice->refund($adjustments, 'transaction');\n  $refund_invoice->subtotal_in_cents; // -1000\n\n  print \"Refund Invoice: $refund_invoice\";\n} catch (Recurly_ValidationError $e) {\n  // There is a problem with the data or the invoice can't be refunded\n  print \"Validation Error: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice not found: $e\";\n}\n\nThere is an alternative way to call refund directly on an adjustment\ntry {\n  // grab some adjustment\n  $adjustment = Recurly_Adjustment::get('2fe89a073a31318cab377e464cb811b4');\n\n  // you can optionally pass in the same arguments as toRefundAttributes\n  // return Recurly_Invoice\n  $refund_invoice = $adjustment->refund();\n  $refund_invoice->subtotal_in_cents; // -1000\n\n  print \"Refund Invoice: $refund_invoice\";\n} catch (Recurly_ValidationError $e) {\n  // There is a problem with the data or the invoice can't be refunded\n  print \"Validation Error: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Adjustment not found: $e\";\n}","language":"php"},{"code":"invoice = Invoice.find(1005)\nadjustments = invoice.line_items.values.map do |adjustment|\n  { adjustment: adjustment, quantity: 1, prorate: false }\nend\n\ninvoice.refund adjustments, 'credit'","language":"ruby"},{"code":"invoice = Invoice.get('1005')\nline_items = list({'adjustment' : adjustment, 'quantity' : 1, 'prorate' : False} for adjustment in invoice.line_items)\n\nrefund_invoice = invoice.refund(line_items, 'credit')","language":"python"},{"code":"// refund a single adjustment\nvar invoice = Invoices.Get(1005);\nvar adjustment = invoice.Adjustments.First(x => x.Uuid == \"e1234245132465\");\ninvoice = invoice.Refund(adjustment, false, 1); // adjustment, prorate, quantity\n\n// refund multiple adjustments\nvar invoice = Invoices.Get(1005);\ninvoice.Refund(invoice.Adjustments, refundPriority: Invoice.RefundOrderPriority.Credit);","language":"csharp"},{"code":"<invoice>\n  <line_items>\n    <adjustment>\n      <uuid>2bc33a7469dc1458f455634212acdcd6</uuid>\n      <quantity>1</quantity>\n      <prorate>false</prorate>\n    </adjustment>\n    <adjustment>\n      <uuid>2bc33a746a89d867df47024fd6b261b6</uuid>\n      <quantity>1</quantity>\n      <prorate>true</prorate>\n    </adjustment>\n  </line_items>\n  <refund_apply_order>credit</refund_apply_order>\n</invoice>","language":"xml"}]},"results":{"codes":[{"status":201,"language":"xml","code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1010\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <uuid>2bc3cf4cbe357b7525eac5424292b445</uuid>\n  <state>collected</state>\n  <invoice_number type=\"integer\">1010</invoice_number>\n  <po_number nil=\"nil\"/>\n  <vat_number nil=\"nil\"/>\n  <subtotal_in_cents type=\"integer\">-9771</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">-9771</total_in_cents>\n  <currency>GBP</currency>\n  <created_at type=\"datetime\">2014-12-16T21:32:16Z</created_at>\n  <closed_at type=\"datetime\">2014-12-16T21:32:16Z</closed_at>\n  <terms_and_conditions nil=\"nil\"/>\n  <customer_notes nil=\"nil\"/>\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/2bc3cf4cb513049c6aec1b419c97b508\" type=\"charge\">\n      <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n      <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1010\"/>\n      <uuid>2bc3cf4cb513049c6aec1b419c97b508</uuid>\n      <state>invoiced</state>\n      <description>Refund for Setup fee: IP Addresses</description>\n      <accounting_code nil=\"nil\"/>\n      <product_code>ipaddresses</product_code>\n      <origin>setup_fee</origin>\n      <unit_amount_in_cents type=\"integer\">900</unit_amount_in_cents>\n      <quantity type=\"integer\">-1</quantity>\n      <quantity_remaining type=\"integer\">0</quantity_remaining>\n      <discount_in_cents type=\"integer\">0</discount_in_cents>\n      <tax_in_cents type=\"integer\">0</tax_in_cents>\n      <total_in_cents type=\"integer\">-900</total_in_cents>\n      <currency>GBP</currency>\n      <taxable type=\"boolean\">false</taxable>\n      <tax_exempt type=\"boolean\">false</tax_exempt>\n      <tax_code nil=\"nil\"/>\n      <start_date type=\"datetime\">2014-12-16T18:49:41Z</start_date>\n      <end_date nil=\"nil\"/>\n      <created_at type=\"datetime\">2014-12-16T21:32:16Z</created_at>\n    </adjustment>\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/2bc3cf4cb615aea5540bb54d4c9fc814\" type=\"charge\">\n      <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n      <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1010\"/>\n      <uuid>2bc3cf4cb615aea5540bb54d4c9fc814</uuid>\n      <state>invoiced</state>\n      <description>Refund for IP Addresses</description>\n      <accounting_code nil=\"nil\"/>\n      <product_code>ipaddresses</product_code>\n      <origin>plan</origin>\n      <unit_amount_in_cents type=\"integer\">8871</unit_amount_in_cents>\n      <quantity type=\"integer\">-1</quantity>\n      <quantity_remaining type=\"integer\">0</quantity_remaining>\n      <discount_in_cents type=\"integer\">0</discount_in_cents>\n      <tax_in_cents type=\"integer\">0</tax_in_cents>\n      <total_in_cents type=\"integer\">-8871</total_in_cents>\n      <currency>GBP</currency>\n      <taxable type=\"boolean\">false</taxable>\n      <tax_exempt type=\"boolean\">false</tax_exempt>\n      <tax_code nil=\"nil\"/>\n      <start_date type=\"datetime\">2014-12-16T21:32:16Z</start_date>\n      <end_date type=\"datetime\">2015-01-16T18:49:41Z</end_date>\n      <created_at type=\"datetime\">2014-12-16T21:32:16Z</created_at>\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n    <!-- Omitted -->\n  </transactions>\n</invoice>","name":""}]},"settings":"","auth":"required","params":[],"url":"/invoices/:invoice_number/refund"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"An invoice with a processed line item refund cannot accept refunds of an open amount.\\n\\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI.\"\n}\n[/block]\n**REFUND ATTRIBUTES**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"`uuid`\",\n    \"0-1\": \"Unique adjustment ID.**`required`**\",\n    \"1-0\": \"`quantity`\",\n    \"1-1\": \"Quantity of the line item to refund.**`required`**\",\n    \"2-0\": \"`prorate`\",\n    \"2-1\": \"Toggle to prorate the line item to refund. Set as `true` or `false`. Only applicable to subscription line items still in the current billing cycle. Proration is not allowed on invoices with an associated transaction that has not settled, due to the full amount needed in order to void the transaction.\",\n    \"3-0\": \"`refund_apply_order`\",\n    \"3-1\": \"If credit line items exist on the invoice, this parameter specifies which refund method to use first. Most relevant in a partial refunds, you can chose to refund credit back to the account first or a transaction giving money back to the customer first. If not specified, the default is credit back to the account. Set as `credit` or `transaction`.\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:20:32.509Z","excerpt":"Allows specific invoice line items and/or quantities to be refunded and generates a refund invoice. Full amount line item refunds of invoices with an unsettled transaction will void the transaction and generate a void invoice.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":9,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"line-item-refunds","sync_unique":"","title":"Line Item Refunds/Voids","type":"post","updates":["55b66ee1f8105a2f00c34f37"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postLine Item Refunds/Voids

Allows specific invoice line items and/or quantities to be refunded and generates a refund invoice. Full amount line item refunds of invoices with an unsettled transaction will void the transaction and generate a void invoice.

[block:callout] { "type": "warning", "body": "An invoice with a processed line item refund cannot accept refunds of an open amount.\n\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI." } [/block] **REFUND ATTRIBUTES** [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`uuid`", "0-1": "Unique adjustment ID.**`required`**", "1-0": "`quantity`", "1-1": "Quantity of the line item to refund.**`required`**", "2-0": "`prorate`", "2-1": "Toggle to prorate the line item to refund. Set as `true` or `false`. Only applicable to subscription line items still in the current billing cycle. Proration is not allowed on invoices with an associated transaction that has not settled, due to the full amount needed in order to void the transaction.", "3-0": "`refund_apply_order`", "3-1": "If credit line items exist on the invoice, this parameter specifies which refund method to use first. Most relevant in a partial refunds, you can chose to refund credit back to the account first or a transaction giving money back to the customer first. If not specified, the default is credit back to the account. Set as `credit` or `transaction`." }, "cols": 2, "rows": 4 } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "An invoice with a processed line item refund cannot accept refunds of an open amount.\n\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI." } [/block] **REFUND ATTRIBUTES** [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Description", "0-0": "`uuid`", "0-1": "Unique adjustment ID.**`required`**", "1-0": "`quantity`", "1-1": "Quantity of the line item to refund.**`required`**", "2-0": "`prorate`", "2-1": "Toggle to prorate the line item to refund. Set as `true` or `false`. Only applicable to subscription line items still in the current billing cycle. Proration is not allowed on invoices with an associated transaction that has not settled, due to the full amount needed in order to void the transaction.", "3-0": "`refund_apply_order`", "3-1": "If credit line items exist on the invoice, this parameter specifies which refund method to use first. Most relevant in a partial refunds, you can chose to refund credit back to the account first or a transaction giving money back to the customer first. If not specified, the default is credit back to the account. Set as `credit` or `transaction`." }, "cols": 2, "rows": 4 } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f6e","api":{"examples":{"codes":[{"name":"","code":"try {\n  $invoice = Recurly_Invoice::get('1346');\n  $refund_invoice = $invoice->refundAmount(1000, 'transaction'); // refund in cents, returns a  Recurly_Invoice\n  $refund_invoice->amount_in_cents; // -1000\n\n  print \"Refund Invoice: $refund_invoice\";\n} catch (Recurly_ValidationError $e) {\n  // Data is invalid or the invoice could not be refunded\n  print \"Invoice could not be refunded: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Invoice Not Found: $e\";\n}","language":"php"},{"code":"invoice = Invoice.find(1005)\ninvoice.refund_amount 10_00, 'credit'","language":"ruby"},{"code":"invoice = Invoice.get('1001')\nrefund_invoice = invoice.refund_amount(1000, 'credit')","language":"python"},{"code":"var invoice = Invoices.Get(1005);\nvar refundInvoice = invoice.RefundAmount(1000, Invoice.RefundOrderPriority.Credit);","language":"csharp"},{"code":"<invoice>\n  <amount_in_cents>1000</amount_in_cents>\n  <refund_apply_order>credit</refund_apply_order>\n</invoice>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1010\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <address>\n    <address1>400 Alabama Street</address1>\n    <address2>Suite 202</address2>\n    <city>San Francisco</city>\n    <state>CA</state>\n    <zip>94110</zip>\n    <country>US</country>\n    <phone></phone>\n  </address>\n  <original_invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1005\"/>\n  <uuid>421f7b7d414e4c6792938e7c49d552e9</uuid>\n  <state>collected</state>\n  <invoice_number type=\"integer\">1010</invoice_number>\n  <po_number nil=\"nil\"></po_number>\n  <vat_number nil=\"nil\"></vat_number>\n  <subtotal_in_cents type=\"integer\">-1000</subtotal_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <total_in_cents type=\"integer\">-1000</total_in_cents>\n  <currency>USD</currency>\n  <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n  <closed_at nil=\"nil\"></closed_at>\n  <net_terms type=\"integer\">0</net_terms>\n  <collection_method>automatic</collection_method>\n  <amount_remaining_in_cents type=\"integer\">9000</amount_remaining_in_cents>\n  <line_items type=\"array\">\n    <adjustment href=\"https://your-subdomain.recurly.com/v2/adjustments/05a4bbdeda2a47348185270021e6087b\" type=\"charge\">\n      <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n      <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1010\"/>\n      <uuid>2529f8eeec94a858bd8268461f8f1b30</uuid>\n      <state>invoiced</state>\n      <description>Refund for Invoice #1009</description>\n      <accounting_code></accounting_code>\n      <product_code>ipaddresses</product_code>\n      <origin>add_on</origin>\n      <unit_amount_in_cents type=\"integer\">1000</unit_amount_in_cents>\n      <quantity type=\"integer\">-1</quantity>\n      <quantity_remaining type=\"integer\">0</quantity_remaining>\n      <discount_in_cents type=\"integer\">0</discount_in_cents>\n      <tax_in_cents type=\"integer\">0</tax_in_cents>\n      <total_in_cents type=\"integer\">-1000</total_in_cents>\n      <currency>USD</currency>\n      <tax_exempt type=\"boolean\">false</tax_exempt>\n      <start_date type=\"datetime\">2011-08-25T12:00:00Z</start_date>\n      <end_date nil=\"nil\"></end_date>\n      <created_at type=\"datetime\">2011-08-25T12:00:00Z</created_at>\n    </adjustment>\n  </line_items>\n  <transactions type=\"array\">\n  </transactions>\n</invoice>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55c8c72071d7580d0063a5c8","ref":"","required":false,"desc":"The specific amount to be refunded from the original invoice. If left empty, the remaining refundable amount will be refunded.","default":"","type":"int","name":"amount_in_cents"},{"_id":"55c8c72071d7580d0063a5c7","ref":"","required":false,"desc":"If credit line items exist on the invoice, this parameter specifies which refund method to use first. Most relevant in a partial refunds, you can chose to refund credit back to the account first or a transaction giving money back to the customer first. Set as `credit` or `transaction`.","default":"credit","type":"string","name":"refund_apply_order"}],"url":"/invoices/:invoice_number/refund"},"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"An invoice with a processed open amount refund cannot accept [line item](/v2.0/docs/line-item-refunds) refunds.\\n\\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T17:31:15.021Z","excerpt":"Allows custom invoice amounts to be refunded and generates a refund invoice. Full open amount refunds of invoices with an unsettled transaction will void the transaction and generate a void invoice.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":10,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"open-amount-refunds","sync_unique":"","title":"Open Amount Refunds/Voids","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postOpen Amount Refunds/Voids

Allows custom invoice amounts to be refunded and generates a refund invoice. Full open amount refunds of invoices with an unsettled transaction will void the transaction and generate a void invoice.

amount_in_cents:
integer
The specific amount to be refunded from the original invoice. If left empty, the remaining refundable amount will be refunded.
refund_apply_order:
stringcredit
If credit line items exist on the invoice, this parameter specifies which refund method to use first. Most relevant in a partial refunds, you can chose to refund credit back to the account first or a transaction giving money back to the customer first. Set as `credit` or `transaction`.
[block:callout] { "type": "warning", "body": "An invoice with a processed open amount refund cannot accept [line item](/v2.0/docs/line-item-refunds) refunds.\n\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "warning", "body": "An invoice with a processed open amount refund cannot accept [line item](/v2.0/docs/line-item-refunds) refunds.\n\nThis endpoint will not void an ACH bank account transaction. ACH voids are only allowed through the UI." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f6f","api":{"examples":{"codes":[{"language":"xml","code":"<transaction>\n <payment_method>check</payment_method>\n <collected_at>2011-08-25T12:00:00Z</collected_at>\n <amount_in_cents>1000</amount_in_cents>\n <description>Paid with a check</description>\n</transaction>","name":""},{"code":"invoice = Recurly::Invoice.find('1001')\ninvoice.enter_offline_payment(\n  :payment_method => 'check',\n  :amount_in_cents => 1000,\n  :description => 'Paid with check',\n  :collected_at => Time.utc(2011, 08, 25)\n)","language":"ruby"}]},"results":{"codes":[{"status":201,"language":"xml","code":"<transaction href=\"https://your-subdomain.recurly.com/v2/transactions/a13acd8fe4294916b79aec87b7ea441f\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n  <uuid>a13acd8fe4294916b79aec87b7ea441f</uuid>\n  <action>purchase</action>\n  <amount_in_cents type=\"integer\">1000</amount_in_cents>\n  <tax_in_cents type=\"integer\">0</tax_in_cents>\n  <currency>USD</currency>\n  <status>success</status>\n  <payment_method>check</payment_method>\n  <reference nil=\"nil\"/>\n  <source>transaction</source>\n  <recurring type=\"boolean\">false</recurring>\n  <test type=\"boolean\">true</test>\n  <voidable type=\"boolean\">true</voidable>\n  <refundable type=\"boolean\">true</refundable>\n  <ip_address nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-06-19T03:01:33Z</created_at>\n  <details>\n    <account>\n      <account_code>1</account_code>\n      <first_name nil=\"nil\"/>\n      <last_name nil=\"nil\"/>\n        <address1>123 Main St.</address1>\n        <address2 nil=\"nil\"/>\n        <city>San Francisco</city>\n        <state>CA</state>\n        <zip>94105</zip>\n        <country>US</country>\n        <phone nil=\"nil\"/>\n        <vat_number nil=\"nil\"/>\n      </billing_info>\n    </account>\n  </details>\n  <a name=\"refund\" href=\"https://your-subdomain.recurly.com/v2/transactions/a13acd8fe4294916b79aec87b7ea441f\" method=\"delete\"/>\n</transaction>","name":""}]},"settings":"","auth":"required","params":[{"_id":"55c547c77136a60d002aa88f","ref":"","required":true,"desc":"The method of payment. \"credit_card\", \"paypal\", \"eft\", \"wire_transfer\", \"money_order\", \"check\", or \"other\".","default":"","type":"string","name":"payment_method"},{"_id":"55c547c77136a60d002aa88e","ref":"","required":false,"desc":"Date payment was collected.","default":"","type":"string","name":"collected_at"},{"_id":"55c547c77136a60d002aa88d","ref":"","required":false,"desc":"The amount paid in cents.","default":"","type":"string","name":"amount_in_cents"},{"_id":"55c547c77136a60d002aa88c","ref":"","required":false,"desc":"Note for the manual payment. Max 50 characters.","default":"","type":"string","name":"description"}],"url":"/invoices/:invoice_number/transactions"},"body":"","category":"56fd7e6b5a08190e00084f4f","createdAt":"2015-06-18T18:24:39.853Z","excerpt":"Allows you to enter an offline payment for a manual invoice, such as a check or money order.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":11,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"enter-an-offline-payment-for-a-manual-invoice-beta","sync_unique":"","title":"Enter an Offline Payment for a Manual Invoice","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postEnter an Offline Payment for a Manual Invoice

Allows you to enter an offline payment for a manual invoice, such as a check or money order.

payment_method:
required
string
The method of payment. "credit_card", "paypal", "eft", "wire_transfer", "money_order", "check", or "other".
collected_at:
string
Date payment was collected.
amount_in_cents:
string
The amount paid in cents.
description:
string
Note for the manual payment. Max 50 characters.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f8c","api":{"examples":{"codes":[{"name":"","code":"$plans = Recurly_PlanList::get();\nforeach ($plans as $plan) {\n  print \"Plan: $plan\\n\";\n}","language":"php"},{"code":"Recurly::Plan.find_each do |plan|\n  puts \"Plan: #{plan.inspect}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\nplans = Plan.all()\nwhile plans:\n    for plan in plans:\n        print 'Plan: %s' % plan\n    try:\n        plans = plans.next_page()\n    except PageError:\n        plans = ()\n\n#client version 2.1.6+\nfor plan in Plan.all():\n    print 'Plan: %s' % plan","language":"python"},{"code":"using System.Linq;\n\nvar plans = Plans.List();\nwhile (plans.Any())\n{\n\tforeach (var plan in plans)\n\t\tConsole.WriteLine(\"Plan: \" + plan);\n\tplans = plans.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<plans type=\"array\">\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n    <add_ons href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons\"/>\n    <plan_code>gold</plan_code>\n    <name>Gold plan</name>\n    <description nil=\"nil\"/>\n    <success_url nil=\"nil\"/>\n    <cancel_url nil=\"nil\"/>\n    <display_donation_amounts type=\"boolean\">false</display_donation_amounts>\n    <display_quantity type=\"boolean\">false</display_quantity>\n    <display_phone_number type=\"boolean\">false</display_phone_number>\n    <bypass_hosted_confirmation type=\"boolean\">false</bypass_hosted_confirmation>\n    <unit_name>unit</unit_name>\n    <payment_page_tos_link nil=\"nil\"/>\n    <plan_interval_length type=\"integer\">1</plan_interval_length>\n    <plan_interval_unit>months</plan_interval_unit>\n    <trial_interval_length type=\"integer\">0</trial_interval_length>\n    <trial_interval_unit>days</trial_interval_unit>\n    <total_billing_cycles nil=\"nil\"/>\n    <accounting_code nil=\"nil\"/>\n    <created_at type=\"datetime\">2015-05-29T17:38:15Z</created_at>\n    <tax_exempt type=\"boolean\">false</tax_exempt>\n    <tax_code nil=\"nil\"/>\n    <unit_amount_in_cents>\n      <USD type=\"integer\">6000</USD>\n      <EUR type=\"integer\">4500</EUR>\n    </unit_amount_in_cents>\n    <setup_fee_in_cents>\n      <USD type=\"integer\">1000</USD>\n      <EUR type=\"integer\">800</EUR>\n    </setup_fee_in_cents>\n  </plan>\n  <!-- Continued... -->\n</plans>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55830ff6b806360d0024496c","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"55830ff6b806360d0024496b","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"int","name":"per_page"}],"url":"/plans"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"The client library will automatically fetch the next page of the results. There may be a slight delay when fetching the next page.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f50","createdAt":"2015-06-18T18:37:42.850Z","excerpt":"Lists all your active subscription plans.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-plans","sync_unique":"","title":"List Plans","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Plans

Lists all your active subscription plans.

cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
integer50
Number of records to return per page, up to a maximum of 200.
[block:callout] { "type": "info", "body": "The client library will automatically fetch the next page of the results. There may be a slight delay when fetching the next page." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "body": "The client library will automatically fetch the next page of the results. There may be a slight delay when fetching the next page." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f8d","api":{"examples":{"codes":[{"name":"","code":"try {\n  $plan = Recurly_Plan::get('gold');\n  print \"Plan: $plan\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan not found\";\n}","language":"php"},{"code":"plan = Recurly::Plan.find('gold')","language":"ruby"},{"code":"plan = Plan.get('gold')","language":"python"},{"code":"var plan = Plans.Get(\"gold\");","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n  <add_ons href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons\"/>\n  <plan_code>gold</plan_code>\n  <name>Gold plan</name>\n  <description nil=\"nil\"/>\n  <success_url nil=\"nil\"/>\n  <cancel_url nil=\"nil\"/>\n  <display_donation_amounts type=\"boolean\">false</display_donation_amounts>\n  <display_quantity type=\"boolean\">false</display_quantity>\n  <display_phone_number type=\"boolean\">false</display_phone_number>\n  <bypass_hosted_confirmation type=\"boolean\">false</bypass_hosted_confirmation>\n  <unit_name>unit</unit_name>\n  <payment_page_tos_link nil=\"nil\"/>\n  <plan_interval_length type=\"integer\">1</plan_interval_length>\n  <plan_interval_unit>months</plan_interval_unit>\n  <trial_interval_length type=\"integer\">0</trial_interval_length>\n  <trial_interval_unit>days</trial_interval_unit>\n  <total_billing_cycles nil=\"nil\"/>\n  <accounting_code nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-05-29T17:38:15Z</created_at>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <tax_code nil=\"nil\"/>\n  <unit_amount_in_cents>\n    <EUR type=\"integer\">4500</EUR>\n    <USD type=\"integer\">6000</USD>\n  </unit_amount_in_cents>\n  <setup_fee_in_cents>\n    <EUR type=\"integer\">800</EUR>\n    <USD type=\"integer\">1000</USD>\n  </setup_fee_in_cents>\n</plan>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/plans/:plan_code"},"body":"","category":"56fd7e6b5a08190e00084f50","createdAt":"2015-06-18T18:41:50.557Z","excerpt":"Lookup a plan's details.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-plan-details","sync_unique":"","title":"Lookup Plan Details","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup Plan Details

Lookup a plan's details.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f8e","api":{"examples":{"codes":[{"name":"","code":"try {\n  $plan = new Recurly_Plan();\n  $plan->plan_code = 'gold';\n  $plan->name = \"Gold plan\";\n  $plan->unit_amount_in_cents->addCurrency('USD', 1000); // USD 10.00 month\n  $plan->unit_amount_in_cents->addCurrency('EUR', 800);  // EUR 8.00 month\n  $plan->setup_fee_in_cents->addCurrency('USD', 6000); // USD 60.00 setup fee\n  $plan->setup_fee_in_cents->addCurrency('EUR', 4500); // EUR 45.00 setup fee\n  $plan->plan_interval_length = 1;\n  $plan->plan_interval_unit = 'months';\n  $plan->tax_exempt = false;\n  $plan->create();\n\n  print \"Plan: $plan\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Data: $e\";\n}","language":"php"},{"code":"plan = Recurly::Plan.create(\n  :plan_code            => 'gold',\n  :name                 => 'Gold plan',\n  :unit_amount_in_cents => { 'USD' => 10_00, 'EUR' => 8_00 },\n  :setup_fee_in_cents   => { 'USD' => 60_00, 'EUR' => 45_00 },\n  :plan_interval_length => 1,\n  :plan_interval_unit   => 'months'\n  :tax_exempt           => false\n)","language":"ruby"},{"code":"plan = Plan(plan_code='gold', name='Gold plan')\nplan.unit_amount_in_cents = Money(USD=1000, EUR=800)\nplan.setup_fee_in_cents = Money(USD=6000, EUR=4500)\nplan.plan_interval_length = 1\nplan.plan_interval_unit = 'months'\nplan.tax_exempt = False\nplan.save()","language":"python"},{"code":"var plan = new Plan(\"gold\", \"Gold plan\"); // plan code, name\nplan.UnitAmountInCents.Add(\"USD\", 1000);\nplan.UnitAmountInCents.Add(\"EUR\", 800);\nplan.SetupFeeInCents.Add(\"USD\", 6000);\nplan.SetupFeeInCents.Add(\"EUR\", 4500);\nplan.PlanIntervalLength = 1;\nplan.PlanIntervalUnit = Plan.IntervalUnit.Month;\nplan.TaxExempt = false;\nplan.Create();","language":"csharp"},{"code":"<plan>\n  <plan_code>gold</plan_code>\n  <name>Gold plan</name>\n  <unit_amount_in_cents>\n    <USD>6000</USD>\n    <EUR>4500</EUR>\n  </unit_amount_in_cents>\n  <setup_fee_in_cents>\n    <USD>1000</USD>\n    <EUR>800</EUR>\n  </setup_fee_in_cents>\n  <plan_interval_length>1</plan_interval_length>\n  <plan_interval_unit>months</plan_interval_unit>\n  <tax_exempt>false</tax_exempt>\n</plan>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n  <add_ons href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons\"/>\n  <plan_code>gold</plan_code>\n  <name>Gold plan</name>\n  <description nil=\"nil\"/>\n  <success_url nil=\"nil\"/>\n  <cancel_url nil=\"nil\"/>\n  <display_donation_amounts type=\"boolean\">false</display_donation_amounts>\n  <display_quantity type=\"boolean\">false</display_quantity>\n  <display_phone_number type=\"boolean\">false</display_phone_number>\n  <bypass_hosted_confirmation type=\"boolean\">false</bypass_hosted_confirmation>\n  <unit_name>unit</unit_name>\n  <payment_page_tos_link nil=\"nil\"/>\n  <plan_interval_length type=\"integer\">1</plan_interval_length>\n  <plan_interval_unit>months</plan_interval_unit>\n  <trial_interval_length type=\"integer\">0</trial_interval_length>\n  <trial_interval_unit>days</trial_interval_unit>\n  <total_billing_cycles nil=\"nil\"/>\n  <accounting_code nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-05-29T17:38:15Z</created_at>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <tax_code nil=\"nil\"/>\n  <unit_amount_in_cents>\n    <USD type=\"integer\">6000</USD>\n    <EUR type=\"integer\">4500</EUR>\n  </unit_amount_in_cents>\n  <setup_fee_in_cents>\n    <USD type=\"integer\">1000</USD>\n    <EUR type=\"integer\">800</EUR>\n  </setup_fee_in_cents>\n</plan>","language":"xml","status":201}]},"settings":"","auth":"required","params":[{"_id":"55831249ea39a9390022435b","ref":"","required":true,"desc":"Unique code to identify the plan. This code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 50 characters.","default":"","type":"string","name":"plan_code"},{"_id":"55831249ea39a9390022435a","ref":"","required":true,"desc":"Plan name. Max of 255 characters.","default":"","type":"string","name":"name"},{"_id":"55831249ea39a93900224352","ref":"","required":true,"desc":"Array of currency objects, see example below. Max 10000000.","default":"","type":"int","name":"unit_amount_in_cents"},{"_id":"55831249ea39a93900224359","ref":"","required":false,"desc":"Optional plan description, not displayed","default":"","type":"string","name":"description"},{"_id":"55831249ea39a93900224358","ref":"","required":false,"desc":"Accounting code for related invoice line items, code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"55831249ea39a93900224357","ref":"","required":false,"desc":"\"days\", or \"months\", defaults to \"months\"","default":"","type":"string","name":"plan_interval_unit"},{"_id":"55831249ea39a93900224356","ref":"","required":false,"desc":"Plan interval length, defaults to 1","default":"1","type":"int","name":"plan_interval_length"},{"_id":"55831249ea39a93900224355","ref":"","required":false,"desc":"days\", or \"months\", defaults to \"months\"","default":"months","type":"string","name":"trial_interval_unit"},{"_id":"55831249ea39a93900224354","ref":"","required":false,"desc":"Defaults to zero, or no trial","default":"0","type":"int","name":"trial_interval_length"},{"_id":"55831249ea39a93900224353","ref":"","required":false,"desc":"Array of currency objects, see examples. Max 10000000.","default":"","type":"array_int","name":"setup_fee_in_cents"},{"_id":"55d7617bf662951900fc0e76","ref":"","required":false,"desc":"Accounting code for a Setup Fee, code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 20 characters.","default":"","type":"string","name":"setup_fee_accounting_code"},{"_id":"55831249ea39a93900224351","ref":"","required":false,"desc":"Number of billing cycles before the plan stops renewing, defaults to null for continuous auto renewal.","default":"null","type":"string","name":"total_billing_cycles"},{"_id":"55831249ea39a93900224350","ref":"","required":false,"desc":"** Deprecated** Unit description for the quantity, e.g. \"users\".","default":"","type":"string","name":"unit_name"},{"_id":"55831249ea39a9390022434f","ref":"","required":false,"desc":"Display the quantity field on the hosted payment page if true, defaults to false.","default":"false","type":"boolean","name":"display_quantity"},{"_id":"55831249ea39a9390022434e","ref":"","required":false,"desc":"URL to redirect to after signup on the hosted payment pages.","default":"","type":"string","name":"success_url"},{"_id":"55831249ea39a9390022434d","ref":"","required":false,"desc":"** Deprecated** URL to redirect to on canceled signup on the hosted payment pages.","default":"","type":"string","name":"cancel_url"},{"_id":"55831249ea39a9390022434c","ref":"","required":false,"desc":"`true` exempts tax on the plan, `false` applies tax on the plan. If not defined, then defaults to the Plan and Site settings.","default":"","type":"boolean","name":"tax_exempt"},{"_id":"55831249ea39a9390022434b","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"}],"url":"/plans"},"body":"","category":"56fd7e6b5a08190e00084f50","createdAt":"2015-06-18T18:47:37.527Z","excerpt":"Create a new subscription plan.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-plan","sync_unique":"","title":"Create Plan","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate Plan

Create a new subscription plan.

plan_code:
required
string
Unique code to identify the plan. This code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 50 characters.
name:
required
string
Plan name. Max of 255 characters.
unit_amount_in_cents:
required
integer
Array of currency objects, see example below. Max 10000000.
description:
string
Optional plan description, not displayed
accounting_code:
string
Accounting code for related invoice line items, code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 20 characters.
plan_interval_unit:
string
"days", or "months", defaults to "months"
plan_interval_length:
integer1
Plan interval length, defaults to 1
trial_interval_unit:
stringmonths
days", or "months", defaults to "months"
trial_interval_length:
integer0
Defaults to zero, or no trial
setup_fee_in_cents:
array of integers
Array of currency objects, see examples. Max 10000000.
setup_fee_accounting_code:
string
Accounting code for a Setup Fee, code may only contain the following characters: [a-z 0-9 @ - _ .]. Max of 20 characters.
total_billing_cycles:
stringnull
Number of billing cycles before the plan stops renewing, defaults to null for continuous auto renewal.
unit_name:
string
** Deprecated** Unit description for the quantity, e.g. "users".
display_quantity:
booleanfalse
Display the quantity field on the hosted payment page if true, defaults to false.
success_url:
string
URL to redirect to after signup on the hosted payment pages.
cancel_url:
string
** Deprecated** URL to redirect to on canceled signup on the hosted payment pages.
tax_exempt:
boolean
`true` exempts tax on the plan, `false` applies tax on the plan. If not defined, then defaults to the Plan and Site settings.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f8f","api":{"examples":{"codes":[{"name":"","code":"try {\n  $plan = Recurly_Plan::get('gold');\n  $plan->unit_amount_in_cents['EUR'] = 5000; // EUR 50.00 monthly fee\n  $plan->setup_fee_in_cents['EUR'] = 5000; // EUR 50.00 setup fee\n  $plan->update();\n\n  print \"Plan: $plan\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Data: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan Not Found: $e\";\n}","language":"php"},{"code":"plan = Recurly::Plan.find('gold')\nplan.setup_fee_in_cents['EUR'] = 50_00\nplan.save","language":"ruby"},{"code":"plan = Plan.get('gold')\nplan.setup_fee_in_cents['EUR'] = 5000\nplan.save()","language":"python"},{"code":"var plan = Plans.Get(\"gold\");\nplan.SetupFeeInCents[\"EUR\"] = 5000;\nplan.Update();","language":"csharp"},{"code":"<plan>\n  <setup_fee_in_cents>\n    <USD>6000</USD>\n    <EUR>5000</EUR>\n  </setup_fee_in_cents>\n</plan>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n  <add_ons href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons\"/>\n  <plan_code>gold</plan_code>\n  <name>Gold plan</name>\n  <description nil=\"nil\"/>\n  <success_url nil=\"nil\"/>\n  <cancel_url nil=\"nil\"/>\n  <display_donation_amounts type=\"boolean\">false</display_donation_amounts>\n  <display_quantity type=\"boolean\">false</display_quantity>\n  <display_phone_number type=\"boolean\">false</display_phone_number>\n  <bypass_hosted_confirmation type=\"boolean\">false</bypass_hosted_confirmation>\n  <unit_name>unit</unit_name>\n  <payment_page_tos_link nil=\"nil\"/>\n  <plan_interval_length type=\"integer\">1</plan_interval_length>\n  <plan_interval_unit>months</plan_interval_unit>\n  <trial_interval_length type=\"integer\">0</trial_interval_length>\n  <trial_interval_unit>days</trial_interval_unit>\n  <total_billing_cycles nil=\"nil\"/>\n  <accounting_code nil=\"nil\"/>\n  <created_at type=\"datetime\">2015-05-29T17:38:15Z</created_at>\n  <tax_exempt type=\"boolean\">false</tax_exempt>\n  <tax_code nil=\"nil\"/>\n  <unit_amount_in_cents>\n    <EUR type=\"integer\">4500</EUR>\n    <USD type=\"integer\">6000</USD>\n  </unit_amount_in_cents>\n  <setup_fee_in_cents>\n    <EUR type=\"integer\">5000</EUR>\n    <USD type=\"integer\">6000</USD>\n  </setup_fee_in_cents>\n</plan>","language":"xml","status":200}]},"settings":"","auth":"required","params":[],"url":"/plans/:plan_code"},"body":"","category":"56fd7e6b5a08190e00084f50","createdAt":"2015-06-18T18:50:40.401Z","excerpt":"Update the pricing or details for a plan. Existing subscriptions will remain at the previous renewal amounts.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-plan","sync_unique":"","title":"Update Plan","type":"put","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate Plan

Update the pricing or details for a plan. Existing subscriptions will remain at the previous renewal amounts.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f90","api":{"examples":{"codes":[{"language":"php","code":"try {\n  $plan = Recurly_Plan::get('gold');\n  $plan->delete();\n\n  print \"Plan: $plan\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan Not Found: $e\";\n}","name":""},{"language":"ruby","code":"plan = Recurly::Plan.find('gold')\nplan.destroy"},{"language":"python","code":"plan = Plan.get('gold')\nplan.delete()"},{"language":"csharp","code":"var plan = Plans.Get(\"gold\");\nplan.Deactivate();"}]},"results":{"codes":[{"code":"Status: 204 No Content","language":"xml","status":204}]},"settings":"","auth":"required","params":[],"url":"/plans/:plan_code"},"body":"","category":"56fd7e6b5a08190e00084f50","createdAt":"2015-06-18T18:52:18.177Z","excerpt":"Deleting a plan makes it inactive. New subscriptions cannot be created from the plan.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"delete-plan","sync_unique":"","title":"Delete Plan","type":"delete","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteDelete Plan

Deleting a plan makes it inactive. New subscriptions cannot be created from the plan.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":2,"_id":"5724165b2ad0bc1700122780","api":{"auth":"required","examples":{"codes":[]},"params":[{"_id":"57242ce72ad0bc17001227ab","ref":"","required":false,"desc":"The URL of the plan the add-on is in","default":"","type":"string","name":"plan"},{"_id":"57242ce72ad0bc17001227aa","ref":"","required":false,"desc":"Visible if Usage-Based Billing Beta enabled on your site: If the add-on is usage-based, this is the URL of the measured unit associated with the add-on.","default":"","type":"string","name":"measured_unit"},{"_id":"57242ce72ad0bc17001227a9","ref":"","required":false,"desc":"The add-on code. Max of 50 characters.","default":"","type":"string","name":"add_on_code"},{"_id":"57242ce72ad0bc17001227a8","ref":"","required":false,"desc":"The add-on name. Max of 255 characters.","default":"","type":"string","name":"name"},{"_id":"57242ce72ad0bc17001227a7","ref":"","required":false,"desc":"Default quantity for the hosted pages, defaults to 1.","default":"1","type":"int","name":"default_quantity"},{"_id":"57242ce72ad0bc17001227a6","ref":"","required":false,"desc":"If true, displays a quantity field on the hosted pages for the add-on.","default":"false","type":"boolean","name":"display_quantity_on_hosted_page"},{"_id":"57242ce72ad0bc17001227a5","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara's tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"57242ce72ad0bc17001227a4","ref":"","required":false,"desc":"Array of unit amounts with their currency code. Max 10000000. Ex. $5.00 USD would be <USD>500</USD>","default":"","type":"array_int","name":"unit_amount_in_cents"},{"_id":"57242ce72ad0bc17001227a3","ref":"","required":false,"desc":"Accounting code for invoice line items for the add-on. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"57242ce72ad0bc17001227a2","ref":"","required":false,"desc":"Visible if Usage-Based Billing Beta enabled on your site: Whether the add-on is Fixed-Price (fixed), or Usage-Based (usage).","default":"fixed","type":"string","name":"add_on_type"},{"_id":"57242ce72ad0bc17001227a1","ref":"","required":false,"desc":"Visible if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.","default":"true","type":"boolean","name":"optional"},{"_id":"57242ce72ad0bc17001227a0","ref":"","required":false,"desc":"Visible if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you will see usage_type, which can be \"price\" or \"percentage\". If price, the price is defined in unit_amount_in_cents. If percentage, the percentage is defined in usage_percentage.","default":"","type":"string","name":"usage_type"},{"_id":"57242ce72ad0bc170012279f","ref":"","required":false,"desc":"Visible if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you will see usage_percentage, which can have a value if usage_type = percentage. Must be between 0.0000 and 100.0000.","default":"","type":"string","name":"usage_percentage"},{"_id":"57242ce72ad0bc170012279e","ref":"","required":false,"desc":"When the add-on was created in the plan","default":"","type":"datetime","name":"created_at"}],"results":{"codes":[{"name":"","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<add_ons type=\"array\">\n\t\t<add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/premium_support\">\n        <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n        <add_on_code>premium_support</add_on_code>\n        <name>Premium Support</name>\n        <default_quantity type=\"integer\">1</default_quantity>\n        <display_quantity_on_hosted_page type=\"boolean\">true</display_quantity_on_hosted_page>\n        <tax_code>unknown</tax_code>\n        <unit_amount_in_cents>\n            <AUD type=\"integer\">13000</AUD>\n            <EUR type=\"integer\">9000</EUR>\n            <USD type=\"integer\">10000</USD>\n        </unit_amount_in_cents>\n        <accounting_code>SP1000234</accounting_code>\n        <add_on_type>fixed</add_on_type>\n        <optional type=\"boolean\">false</optional>\n        <created_at type=\"datetime\">2016-02-05T21:28:39Z</created_at>\n    </add_on>\n    <add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/email_blasts\">\n        <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n        <measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/7607\"/>\n        <add_on_code>email_blasts</add_on_code>\n        <name>Email Blasts</name>\n        <default_quantity type=\"integer\">1</default_quantity>\n        <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n        <tax_code>unknown</tax_code>\n        <unit_amount_in_cents>\n            <AUD type=\"integer\">50</AUD>\n            <EUR type=\"integer\">30</EUR>\n          \t<USD type=\"integer\">40</USD>\n        </unit_amount_in_cents>\n        <accounting_code></accounting_code>\n        <add_on_type>usage</add_on_type>\n        <optional type=\"boolean\">true</optional>\n        <usage_type>price</usage_type>\n        <usage_percentage nil=\"nil\"></usage_percentage>\n      \t<created_at type=\"datetime\">2016-02-05T21:28:39Z</created_at>\n    </add_on>\n    <add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/donations\">\n        <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n        <measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/7610\"/>\n        <add_on_code>donations</add_on_code>\n        <name>Donations</name>\n        <default_quantity type=\"integer\">1</default_quantity>\n        <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n        <tax_code>unknown</tax_code>\n        <unit_amount_in_cents></unit_amount_in_cents>\n        <accounting_code></accounting_code>\n        <add_on_type>usage</add_on_type>\n        <optional type=\"boolean\">false</optional>\n        <usage_type>percentage</usage_type>\n        <usage_percentage type=\"float\">2.25</usage_percentage>\n        <created_at type=\"datetime\">2016-02-05T21:28:39Z</created_at>\n    </add_on>\n</add_ons>","language":"xml","status":200}]},"settings":"","url":"/plans/:plan_code/add_ons"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2016-04-30T02:20:11.931Z","excerpt":"Plan add-ons are additional products in your plan that recur. Add-ons can be Fixed-Priced, where they are charged upfront, or Usage-Based, where usage is measured and billed in arrears. Add-ons can be optional or required in the plan.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"plan-add-ons-object","sync_unique":"","title":"Plan Add-On Object","type":"get","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getPlan Add-On Object

Plan add-ons are additional products in your plan that recur. Add-ons can be Fixed-Priced, where they are charged upfront, or Usage-Based, where usage is measured and billed in arrears. Add-ons can be optional or required in the plan.

plan:
string
The URL of the plan the add-on is in
measured_unit:
string
Visible if Usage-Based Billing Beta enabled on your site: If the add-on is usage-based, this is the URL of the measured unit associated with the add-on.
add_on_code:
string
The add-on code. Max of 50 characters.
name:
string
The add-on name. Max of 255 characters.
default_quantity:
integer1
Default quantity for the hosted pages, defaults to 1.
display_quantity_on_hosted_page:
booleanfalse
If true, displays a quantity field on the hosted pages for the add-on.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara's tax codes to assign custom tax rules.
unit_amount_in_cents:
array of integers
Array of unit amounts with their currency code. Max 10000000. Ex. $5.00 USD would be <USD>500</USD>
accounting_code:
string
Accounting code for invoice line items for the add-on. Max of 20 characters.
add_on_type:
stringfixed
Visible if Usage-Based Billing Beta enabled on your site: Whether the add-on is Fixed-Price (fixed), or Usage-Based (usage).
optional:
booleantrue
Visible if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.
usage_type:
string
Visible if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you will see usage_type, which can be "price" or "percentage". If price, the price is defined in unit_amount_in_cents. If percentage, the percentage is defined in usage_percentage.
usage_percentage:
string
Visible if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you will see usage_percentage, which can have a value if usage_type = percentage. Must be between 0.0000 and 100.0000.
created_at:
datetime
When the add-on was created in the plan

Definition

{{ api_url }}{{ page_api_url }}

Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084fa3","api":{"examples":{"codes":[{"name":"","code":"try {\n  $plan = Recurly_Plan::get('gold');\n  $add_ons = $plan->add_ons->get();\n  // Or, in 1 API request:\n  // $add_ons = Recurly_AddonList::get('gold');\n  foreach ($add_ons as $add_on) {\n    print \"Add-on: $add_on\\n\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan Not Found: $e\";\n}","language":"php"},{"code":"plan = Recurly::Plan.find('gold')\nplan.add_ons.find_each do |add_on|\n  puts \"Add-on: #{add_on.inspect}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\nplan = Plan.get('gold')\nadd_ons = plan.add_ons()\nwhile add_ons:\n    for add_on in add_ons:\n        print 'Add-on: %s' % add_on\n    try:\n        add_ons = add_ons.next_page()\n    except PageError:\n        add_ons = ()\n\n#client version 2.1.6+\nplan = Plan.get('gold')\nfor add_on in plan.add_ons():\n    print 'Add-on: %s' % add_on","language":"python"},{"code":"using System.Linq;\n\nvar plan = Plans.Get(\"gold\");\nvar addons = plan.AddOns;\nwhile (addons.Any())\n{\n\tforeach (var addon in addons)\n\t\tConsole.WriteLine(\"Addon: \" + addon);\n\taddons = addons.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<add_ons type=\"array\">\n  <add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/ipaddresses\">\n    <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n    <add_on_code>ipaddresses</add_on_code>\n    <name>IP Addresses</name>\n    <default_quantity type=\"integer\">1</default_quantity>\n    <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n    <tax_code>digital</tax_code>\n    <unit_amount_in_cents>\n      <USD type=\"integer\">200</USD>\n    </unit_amount_in_cents>\n    <accounting_code>abc123</accounting_code>\n    <created_at type=\"datetime\">2011-06-28T12:34:56Z</created_at>\n  </add_on>\n  <!-- Continued... -->\n</add_ons>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"55831de9ea39a9390022439e","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"55831de9ea39a9390022439d","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"string","name":"per_page"}],"url":"/plans/:plan_code/add_ons"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2015-06-18T19:37:13.453Z","excerpt":"Returns a list of all the add-ons for a plan.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-add-ons-for-a-plan","sync_unique":"","title":"List Add-Ons in a Plan","type":"get","updates":["564a4d724fa1460d00780c1d"],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Add-Ons in a Plan

Returns a list of all the add-ons for a plan.

cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
string50
Number of records to return per page, up to a maximum of 200.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":2,"_id":"56fd7e6b5a08190e00084fa4","api":{"auth":"required","examples":{"codes":[{"name":"","code":"var plan = Plans.Get(\"gold\");\nvar addon = plan.GetAddOn(\"addOnCode\");","language":"csharp"}]},"params":[{"_id":"57242f592887bb0e00bb9daf","ref":"","required":false,"desc":"The unique add-on code","default":"","type":"string","name":"add_on_code"}],"results":{"codes":[{"name":"","code":"<add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/ipaddresses\">\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n  <add_on_code>ipaddresses</add_on_code>\n  <name>IP Addresses</name>\n  <default_quantity type=\"integer\">1</default_quantity>\n  <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n  <tax_code>digital</tax_code>\n  <unit_amount_in_cents>\n    <USD type=\"integer\">200</USD>\n  </unit_amount_in_cents>\n  <accounting_code>abc123</accounting_code>\n  <created_at type=\"datetime\">2011-06-28T12:34:56Z</created_at>\n</add_on>","language":"xml","status":200}]},"settings":"","url":"/:plan_code/add_ons/:add_on_code"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2015-06-18T19:47:37.395Z","excerpt":"Returns information about an add-on.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":3,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-an-add-on","sync_unique":"","title":"Lookup a Plan Add-On","type":"get","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup a Plan Add-On

Returns information about an add-on.

add_on_code:
string
The unique add-on code

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":1,"_id":"56fd7e6b5a08190e00084fa5","api":{"auth":"required","examples":{"codes":[{"name":"","code":"try {\n  $add_on = new Recurly_Addon();\n  $add_on->plan_code = 'gold';\n  $add_on->add_on_code = 'ipaddresses';\n  $add_on->name = 'Extra IP Addresses';\n  $add_on->unit_amount_in_cents->addCurrency('USD', 200);\n  $add_on->create();\n\n  print \"Addon: $add_on\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Addon data: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan Not Found: $e\";\n}\n","language":"php"},{"code":"plan = Recurly::Plan.find('gold')\nadd_on = plan.add_ons.create(\n  :add_on_code          => 'ipaddresses',\n  :name                 => 'Extra IP Addresses',\n  :unit_amount_in_cents => 2_00\n)\n\n# Create a usage-based add-on\nadd_on = plan.add_ons.create!(\n  add_on_code: 'marketing_emails',\n  name: 'Marketing Emails',\n  unit_amount_in_cents: 5,\n  add_on_type: :usage,\n  optional: false,\n  usage_type: :price,\n  measured_unit_id: 18783,\n)","language":"ruby"},{"code":"plan = Plan.get('gold')\naddon = AddOn(\n  add_on_code='ipaddresses',\n  name='Extra IP Addresses',\n  unit_amount_in_cents=200\n)\nplan.create_add_on(addon)","language":"python"},{"code":"var plan = Plans.Get(\"gold\");\nvar addon = plan.NewAddOn(\"ipaddresses\", \"Extra IP Addresses\"); // add-on code, name\naddon.UnitAmountInCents.Add(\"USD\", 200);\naddon.DefaultQuantity = 1;\naddon.DisplayQuantityOnHostedPage = true;\naddon.Create();\n\n// accounting_code not yet supported.\n// Please contact us if you need this.","language":"csharp"},{"code":"<add_on>\n  <add_on_code>ipaddresses</add_on_code>\n  <name>Extra IP Addresses</name>\n  <unit_amount_in_cents>\n    <USD>200</USD>\n  </unit_amount_in_cents>\n</add_on>","language":"xml"}]},"params":[{"_id":"55c548635c5d9f0d004969c6","ref":"","required":false,"desc":"Add On Code. Max of 50 characters.","default":"","type":"string","name":"add_on_code"},{"_id":"55c548635c5d9f0d004969c5","ref":"","required":false,"desc":"Add-on name. Max of 255 characters.","default":"","type":"string","name":"name"},{"_id":"55c548635c5d9f0d004969c4","default":"","desc":"Array of unit amounts with their currency code. Max 10000000.","name":"unit_amount_in_cents","ref":"","required":false,"type":"array_int"},{"_id":"55c548635c5d9f0d004969c3","default":"1","desc":"Default quantity for the hosted pages","name":"default_quantity","ref":"","required":false,"type":"int"},{"_id":"55c548635c5d9f0d004969c2","default":"false","desc":"If true, display a quantity field on the hosted pages for the add-on","name":"display_quantity_on_hosted_page","ref":"","required":false,"type":"boolean"},{"_id":"55c548635c5d9f0d004969c1","ref":"","required":false,"desc":"Accounting code for invoice line items for the add-on, defaults to add_on_code. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"55c548635c5d9f0d004969c0","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"5724313c4255580e00593861","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is Fixed-Price (fixed), or Usage-Based (usage).","default":"","type":"string","name":"add_on_type"},{"_id":"5724313c4255580e00593860","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: The id of the measured unit on your site associated with the add-on.","default":"","type":"string","name":"measured_unit_id"},{"_id":"5724313c4255580e0059385f","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.","default":"true","type":"boolean","name":"optional"},{"_id":"5724313c4255580e0059385e","default":"","desc":"Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you must set a usage_type, which can be \"price\" or \"percentage\". If price, the price is defined in unit_amount_in_cents. If percentage, the percentage is defined in usage_percentage.","name":"usage_type","ref":"","required":false,"type":"string"},{"_id":"5724313c4255580e0059385d","default":"","desc":"Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage and usage_type = percentage, you must set a usage_percentage. Must be between 0.0000 and 100.0000.","name":"usage_percentage","ref":"","required":false,"type":"string"}],"results":{"codes":[{"status":201,"language":"xml","code":"<add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/ipaddresses\">\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n  <add_on_code>ipaddresses</add_on_code>\n  <name>Extra IP Addresses</name>\n  <default_quantity type=\"integer\">1</default_quantity>\n  <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n  <tax_code nil=\"nil\"/>\n  <unit_amount_in_cents>\n    <USD type=\"integer\">200</USD>\n  </unit_amount_in_cents>\n  <accounting_code nil=\"nil\"/>\n  <created_at type=\"datetime\">2011-06-28T12:34:56Z</created_at>\n</add_on>","name":""}]},"settings":"","url":"/plans/:plan_code/add_ons"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2015-06-18T19:50:44.924Z","excerpt":"Add an add-on to a plan. Only one add-on can be created in a single request.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":4,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"create-an-add-on","sync_unique":"","title":"Create a Plan Add-On","type":"post","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate a Plan Add-On

Add an add-on to a plan. Only one add-on can be created in a single request.

add_on_code:
string
Add On Code. Max of 50 characters.
name:
string
Add-on name. Max of 255 characters.
unit_amount_in_cents:
array of integers
Array of unit amounts with their currency code. Max 10000000.
default_quantity:
integer1
Default quantity for the hosted pages
display_quantity_on_hosted_page:
booleanfalse
If true, display a quantity field on the hosted pages for the add-on
accounting_code:
string
Accounting code for invoice line items for the add-on, defaults to add_on_code. Max of 20 characters.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.
add_on_type:
string
Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is Fixed-Price (fixed), or Usage-Based (usage).
measured_unit_id:
string
Allowed if Usage-Based Billing Beta enabled on your site: The id of the measured unit on your site associated with the add-on.
optional:
booleantrue
Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.
usage_type:
string
Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage, you must set a usage_type, which can be "price" or "percentage". If price, the price is defined in unit_amount_in_cents. If percentage, the percentage is defined in usage_percentage.
usage_percentage:
string
Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage and usage_type = percentage, you must set a usage_percentage. Must be between 0.0000 and 100.0000.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":2,"_id":"56fd7e6b5a08190e00084fa6","api":{"auth":"required","examples":{"codes":[{"name":"","code":"try {\n  $add_on = Recurly_Addon::get('gold', 'ipaddresses'); // (plan_code, addon_code)\n  $add_on->unit_amount_in_cents['USD']->amount_in_cents = 1200; // $12.00.\n  $add_on->update();\n\n  print \"Addon: $add_on\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Addon data: $e\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan or Addon Not Found: $e\";\n}","language":"php"},{"code":"plan = Recurly::Plan.find('gold')\nadd_on = plan.add_ons.find('ipaddresses')\nadd_on.update_attributes :unit_amount_in_cents => 12_00","language":"ruby"},{"code":"plan = Plan.get('gold')\nadd_on = plan.get_add_on('ipaddresses')\nadd_on.unit_amount_in_cents = 200\nadd_on.save()","language":"python"},{"code":"var plan = Plans.Get(\"gold\");\nvar addon = plan.GetAddOn(\"ipaddresses\");\naddon.UnitAmountInCents[\"USD\"] = 200;\naddon.Update();\n ","language":"csharp"},{"code":"<add_on>\n  <unit_amount_in_cents>\n    <USD>1200</USD>\n  </unit_amount_in_cents>\n</add_on>","language":"xml"}]},"params":[{"_id":"5724334f2887bb0e00bb9dbd","ref":"","required":false,"desc":"Add On Code. Max of 50 characters.","default":"","type":"string","name":"add_on_code"},{"_id":"5724334f2887bb0e00bb9dbc","ref":"","required":false,"desc":"Add-on name. Max of 255 characters.","default":"","type":"string","name":"name"},{"_id":"5724334f2887bb0e00bb9dbb","ref":"","required":false,"desc":"Array of unit amounts with their currency code. Max 10000000.","default":"","type":"array_int","name":"unit_amount_in_cents"},{"_id":"5724334f2887bb0e00bb9dba","ref":"","required":false,"desc":"Default quantity for the hosted pages","default":"","type":"int","name":"default_quantity"},{"_id":"5724334f2887bb0e00bb9db9","ref":"","required":false,"desc":"If true, display a quantity field on the hosted pages for the add-on","default":"","type":"string","name":"display_quantity_on_hosted_page"},{"_id":"5724334f2887bb0e00bb9db8","ref":"","required":false,"desc":"Accounting code for invoice line items for the add-on, defaults to add_on_code. Max of 20 characters.","default":"","type":"string","name":"accounting_code"},{"_id":"5724334f2887bb0e00bb9db7","ref":"","required":false,"desc":"Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.","default":"","type":"string","name":"tax_code"},{"_id":"5724334f2887bb0e00bb9db6","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: The id of the measured unit on your site associated with the add-on.","default":"","type":"string","name":"measured_unit_id"},{"_id":"5724334f2887bb0e00bb9db5","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.","default":"true","type":"boolean","name":"optional"},{"_id":"5724334f2887bb0e00bb9db4","ref":"","required":false,"desc":"Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage and usage_type = percentage, you must set a usage_percentage. Must be between 0.0000 and 100.0000.","default":"","type":"string","name":"usage_percentage"}],"results":{"codes":[{"name":"","code":"<add_on href=\"https://your-subdomain.recurly.com/v2/plans/gold/add_ons/ipaddresses\">\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\"/>\n  <add_on_code>ipaddresses</add_on_code>\n  <name>Extra IP Addresses</name>\n  <default_quantity type=\"integer\">1</default_quantity>\n  <display_quantity_on_hosted_page type=\"boolean\">false</display_quantity_on_hosted_page>\n  <tax_code nil=\"nil\"/>\n  <unit_amount_in_cents>\n    <USD type=\"integer\">1200</USD>\n  </unit_amount_in_cents>\n  <accounting_code nil=\"nil\"/>\n  <created_at type=\"datetime\">2011-06-28T12:34:56Z</created_at>\n</add_on>","language":"xml","status":200}]},"settings":"","url":"/plans/:plan_code/add_ons/:add_on_code"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2015-06-18T19:59:54.118Z","excerpt":"Update the pricing information or description for an add-on. Existing subscriptions with the add-on will not receive any pricing updates.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":5,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"update-an-add-on","sync_unique":"","title":"Update a Plan Add-On","type":"put","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate a Plan Add-On

Update the pricing information or description for an add-on. Existing subscriptions with the add-on will not receive any pricing updates.

add_on_code:
string
Add On Code. Max of 50 characters.
name:
string
Add-on name. Max of 255 characters.
unit_amount_in_cents:
array of integers
Array of unit amounts with their currency code. Max 10000000.
default_quantity:
integer
Default quantity for the hosted pages
display_quantity_on_hosted_page:
string
If true, display a quantity field on the hosted pages for the add-on
accounting_code:
string
Accounting code for invoice line items for the add-on, defaults to add_on_code. Max of 20 characters.
tax_code:
string
Optional field for EU VAT merchants and Avalara AvaTax Pro merchants. If you are using Recurly's EU VAT feature, you can use values of 'unknown', 'physical', or 'digital'. If you have your own AvaTax account configured, you can use Avalara tax codes to assign custom tax rules.
measured_unit_id:
string
Allowed if Usage-Based Billing Beta enabled on your site: The id of the measured unit on your site associated with the add-on.
optional:
booleantrue
Allowed if Usage-Based Billing Beta enabled on your site: Whether the add-on is optional for the customer to include in their purchase on the hosted payment page.
usage_percentage:
string
Allowed if Usage-Based Billing Beta enabled on your site: If add_on_type = usage and usage_type = percentage, you must set a usage_percentage. Must be between 0.0000 and 100.0000.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":1,"_id":"56fd7e6b5a08190e00084fa7","api":{"auth":"required","examples":{"codes":[{"name":"","code":"try {\n  $add_on = Recurly_Addon::get('gold', 'ipaddresses'); // (plan_code, addon_code)\n  $add_on->delete();\n\n  print \"Addon: $add_on\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Plan or Addon Not Found: $e\";\n}","language":"php"},{"code":"plan = Recurly::Plan.find('gold')\nadd_on = plan.add_ons.find('ipaddresses')\nadd_on.destroy","language":"ruby"},{"code":"plan = Plan.get('gold')\nadd_on = plan.get_add_on('ipaddresses')\nadd_on.delete()","language":"python"},{"code":"var plan = Plans.Get(\"gold\");\nvar addon = plan.GetAddOn(\"ipaddresses\");\naddon.Delete();","language":"csharp"}]},"params":[],"results":{"codes":[{"name":"","code":"Status: 204 No Content","language":"json","status":204}]},"settings":"","url":"/plans/:plan_code/add_ons/:add_on_code"},"body":"","category":"56fd7e6b5a08190e00084f51","createdAt":"2015-06-18T20:01:20.016Z","excerpt":"Remove an add-on from a plan.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":6,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"delete-an-add-on","sync_unique":"","title":"Delete a Plan Add-On","type":"delete","updates":[],"user":"5581f6648625220d00429ef6","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteDelete a Plan Add-On

Remove an add-on from a plan.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":2,"_id":"57363160be10a92000307270","api":{"auth":"required","examples":{"codes":[]},"params":[{"_id":"57365485a12ae12000774fbb","ref":"","required":false,"desc":"Unique id of the measured unit on your site","default":"","type":"string","name":"id"},{"_id":"57365485a12ae12000774fba","ref":"","required":false,"desc":"Unique internal name of the measured unit on your site","default":"","type":"string","name":"name"},{"_id":"57365485a12ae12000774fb9","ref":"","required":false,"desc":"Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)","default":"","type":"string","name":"display_name"},{"_id":"57365485a12ae12000774fb8","ref":"","required":false,"desc":"Optional internal description","default":"","type":"string","name":"description"}],"results":{"codes":[{"status":200,"language":"xml","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012650\">\n    <id type=\"integer\">404351234712012650</id>\n    <name>Streaming Bandwidth</name>\n    <display_name>GB</display_name>\n    <description nil=\"nil\">Video steaming bandwidth measured in gigabytes</description>\n</measured_unit>","name":""}]},"settings":"","url":"/measured_units"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:56:16.743Z","excerpt":"A measured unit describes a usage-based add-on's usage. If different usage-based add-ons share the same measured unit, you can report on customer usage for those add-ons at the aggregated measured unit level.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"measured-unit-object","sync_unique":"","title":"Measured Unit Object","type":"get","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getMeasured Unit Object

A measured unit describes a usage-based add-on's usage. If different usage-based add-ons share the same measured unit, you can report on customer usage for those add-ons at the aggregated measured unit level.

id:
string
Unique id of the measured unit on your site
name:
string
Unique internal name of the measured unit on your site
display_name:
string
Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)
description:
string
Optional internal description
[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Result Format



[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":8,"_id":"5736317fda06991700865d36","api":{"auth":"required","examples":{"codes":[]},"params":[],"results":{"codes":[{"name":"","code":"<measured_units type=\"array\">\n    <measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012650\">\n        <id type=\"integer\">404351234712012650</id>\n        <name>Streaming Bandwidth</name>\n        <display_name>GB</display_name>\n        <description nil=\"nil\">Video streaming bandwidth measured in gigabytes</description>\n    </measured_unit>\n    <measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012644\">\n        <id type=\"integer\">404351234712012644</id>\n        <name>Video Storage</name>\n        <display_name>GB</display_name>\n        <description nil=\"nil\">Video storage measured in gigabytes</description>\n    </measured_unit>\n    <measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012641\">\n        <id type=\"integer\">404351234712012641</id>\n        <name>Ad Impressions</name>\n        <display_name>Impression</display_name>\n        <description nil=\"nil\">Number of ad impressions</description>\n    </measured_unit>\n</measured_units>","language":"xml","status":200}]},"settings":"","url":"/measured_units"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:56:47.296Z","excerpt":"List all measured units for your site.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"list-measured-units","sync_unique":"","title":"List Measured Units","type":"get","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Measured Units

List all measured units for your site.

[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Result Format



[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":2,"_id":"5736319ada06991700865d38","api":{"auth":"required","examples":{"codes":[]},"params":[{"_id":"573670a1cacfa619004f6d6f","default":"","desc":"Unique id of the measured unit on your site","name":"id","ref":"","required":false,"type":"string"}],"results":{"codes":[{"status":200,"language":"xml","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012650\">\n    <id type=\"integer\">404351234712012650</id>\n    <name>Streaming Bandwidth</name>\n    <display_name>GB</display_name>\n    <description nil=\"nil\">Video steaming bandwidth measured in gigabytes</description>\n</measured_unit>","name":""}]},"settings":"","url":"/measured_units/:measured_unit_id"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:57:14.614Z","excerpt":"Lookup a specific measured unit for your site. A customer's usage-based add-on and usage records will reference the associated measured unit where you can grab the display name for pricing and usage displays.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"lookup-measured-unit","sync_unique":"","title":"Lookup Measured Unit","type":"get","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup Measured Unit

Lookup a specific measured unit for your site. A customer's usage-based add-on and usage records will reference the associated measured unit where you can grab the display name for pricing and usage displays.

id:
string
Unique id of the measured unit on your site
[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Result Format



[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":1,"_id":"573631aacacfa619004f6ce8","api":{"auth":"required","examples":{"codes":[{"language":"xml","code":"<measured_unit>\n  <name>Streaming Bandwidth</name>\n  <display_name>GB</display_name>\n  <description>Video steaming bandwidth measured in gigabytes</description>\n</measured_unit>"}]},"params":[{"_id":"573671093d00df0e00ef112d","default":"","desc":"Unique internal name of the measured unit on your site","name":"name","ref":"","required":true,"type":"string"},{"_id":"573671093d00df0e00ef112c","default":"","desc":"Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)","name":"display_name","ref":"","required":true,"type":"string"},{"_id":"573671093d00df0e00ef112b","default":"","desc":"Optional internal description","name":"description","ref":"","required":false,"type":"string"}],"results":{"codes":[{"status":200,"language":"xml","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012653\">\n    <id type=\"integer\">404351234712012653</id>\n    <name>Streaming Bandwidth</name>\n    <display_name>GB</display_name>\n    <description>Video steaming bandwidth measured in gigabytes</description>\n</measured_unit>","name":""}]},"settings":"","url":"/measured_units"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:57:30.314Z","excerpt":"Create a measured unit on your site.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"create-measured-unit","sync_unique":"","title":"Create Measured Unit","type":"post","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

postCreate Measured Unit

Create a measured unit on your site.

name:
required
string
Unique internal name of the measured unit on your site
display_name:
required
string
Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)
description:
string
Optional internal description
[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":3,"_id":"573631c03d00df0e00ef1058","api":{"auth":"required","examples":{"codes":[{"language":"xml","code":"<measured_unit>\n  <display_name>Gigabyte</display_name>\n</measured_unit>"}]},"params":[{"_id":"57367572f8ebd31700769f73","ref":"","required":false,"desc":"Unique internal name of the measured unit on your site","default":"","type":"string","name":"name"},{"_id":"57367572f8ebd31700769f72","default":"","desc":"Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)","name":"display_name","ref":"","required":false,"type":"string"},{"_id":"57367572f8ebd31700769f71","default":"","desc":"Optional internal description","name":"description","ref":"","required":false,"type":"string"}],"results":{"codes":[{"status":200,"language":"xml","code":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<measured_unit href=\"https://your-subdomain.recurly.com/v2/measured_units/404351234712012653\">\n    <id type=\"integer\">404351234712012653</id>\n    <name>Streaming Bandwidth</name>\n    <display_name>Gigabyte</display_name>\n    <description>Video steaming bandwidth measured in gigabytes</description>\n</measured_unit>","name":""}]},"settings":"","url":"/measured_units/:measured_unit_id"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:57:52.013Z","excerpt":"Update a measured unit on your site. Updates immediately change the measured unit for any associated plan and subscription usage-based add-ons.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"update-measured-unit","sync_unique":"","title":"Update Measured Unit","type":"put","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

putUpdate Measured Unit

Update a measured unit on your site. Updates immediately change the measured unit for any associated plan and subscription usage-based add-ons.

name:
string
Unique internal name of the measured unit on your site
display_name:
string
Display name for the measured unit. We recommend the singular version. (e.g. - GB, API Call, Email)
description:
string
Optional internal description
[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":2,"_id":"573631d1a12ae12000774f73","api":{"auth":"required","examples":{"codes":[]},"params":[],"results":{"codes":[{"status":204,"language":"xml","code":"","name":""}]},"settings":"","url":"/measured_units/:measured_units_id"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Learn more about Usage-Based Billing\",\n  \"body\": \"Read our <a href=\\\"https://docs.recurly.com/docs/usage-based-billing\\\" target=\\\"_blank\\\">feature documentation</a>.\"\n}\n[/block]","category":"5736314df8ebd31700769edd","createdAt":"2016-05-13T19:58:09.190Z","excerpt":"Delete a measured unit on your site. The measured unit must be removed from all plans before it can be deleted.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":999,"project":"555fbba928249c1900618a82","slug":"delete-measured-unit","sync_unique":"","title":"Delete Measured Unit","type":"delete","updates":[],"user":"55b66dba6127b1250036446f","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

deleteDelete Measured Unit

Delete a measured unit on your site. The measured unit must be removed from all plans before it can be deleted.

[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]

Definition

{{ api_url }}{{ page_api_url }}


[block:callout] { "type": "info", "title": "Learn more about Usage-Based Billing", "body": "Read our <a href=\"https://docs.recurly.com/docs/usage-based-billing\" target=\"_blank\">feature documentation</a>." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f54","api":{"examples":{"codes":[{"name":"","code":"$subscriptions = Recurly_SubscriptionList::getActive();\nforeach ($subscriptions as $subscription) {\n  print \"Subscription: $subscription\\n\";\n}","language":"php"},{"code":"Recurly::Subscription.find_each do |subscription|\n  puts \"Susbcription: #{subscription}\"\nend","language":"ruby"},{"code":"#client version <= 2.1.5\nsubscriptions = Subscription.all()\nwhile subscriptions:\n    for subscription in subscriptions:\n        print 'Subscription: %s' % subscription\n    try:\n        subscriptions = subscriptions.next_page()\n    except PageError:\n        subscriptions = ()\n\n#client version 2.1.6+\nfor subscription in Subscription.all():\n    print 'Subscription: %s' % subscription","language":"python"},{"code":"using System.Linq;\n\nvar account = Accounts.Get(\"1\");\nvar subscriptions = account.GetSubscriptions();\nwhile (subscriptions.Any())\n{\n  foreach (var subscription in subscriptions)\n    Console.WriteLine(\"Subscription: \" + subscription);\n  subscriptions = subscriptions.Next;\n}","language":"csharp"}]},"results":{"codes":[{"name":"","code":"<subscriptions type=\"array\">\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n    <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n    <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n      <plan_code>gold</plan_code>\n      <name>Gold plan</name>\n    </plan>\n    <uuid>44f83d7cba354d5b84812419f923ea96</uuid>\n    <state>active</state>\n    <unit_amount_in_cents type=\"integer\">800</unit_amount_in_cents>\n    <currency>EUR</currency>\n    <quantity type=\"integer\">1</quantity>\n    <activated_at type=\"datetime\">2011-05-27T07:00:00Z</activated_at>\n    <canceled_at nil=\"nil\"></canceled_at>\n    <expires_at nil=\"nil\"></expires_at>\n    <current_period_started_at type=\"datetime\">2011-06-27T07:00:00Z</current_period_started_at>\n    <current_period_ends_at type=\"datetime\">2010-07-27T07:00:00Z</current_period_ends_at>\n    <trial_started_at nil=\"nil\"></trial_started_at>\n    <trial_ends_at nil=\"nil\"></trial_ends_at>\n    <tax_in_cents type=\"integer\">72</tax_in_cents>\n    <tax_type>usst</tax_type>\n    <tax_region>CA</tax_region>\n    <tax_rate type=\"float\">0.0875</tax_rate>\n    <po_number nil=\"nil\"></po_number>\n    <net_terms type=\"integer\">0</net_terms>\n    <subscription_add_ons type=\"array\">\n    </subscription_add_ons>\n    <a name=\"cancel\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/cancel\" method=\"put\"/>\n    <a name=\"terminate\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/terminate\" method=\"put\"/>\n    <a name=\"postpone\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/postpone\" method=\"put\"/>\n  </subscription>\n  <!-- Continued... -->\n</subscriptions>","language":"xml","status":200}]},"settings":"","auth":"required","params":[{"_id":"558219b8b806360d00244640","ref":"","required":false,"desc":"The state of subscriptions to return: \"active\", \"canceled\", \"expired\", \"future\", \"in_trial\", \"live\", or \"past_due\". A subscription may belong to more than one state.","default":"","type":"string","name":"state"},{"_id":"558219b8b806360d0024463f","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"558219b8b806360d0024463e","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"string","name":"per_page"}],"url":"/subscriptions"},"body":"###Subscription Query States\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"state\",\n    \"h-1\": \"description\",\n    \"0-0\": \"active\",\n    \"0-1\": \"Subscriptions that are valid for the current time. This includes subscriptions in a trial period\",\n    \"1-0\": \"canceled\",\n    \"1-1\": \"Subscriptions that are valid for the current time but will not renew because a cancelation was requested\",\n    \"2-0\": \"expired\",\n    \"2-1\": \"Subscriptions that have expired and are no longer valid\",\n    \"3-0\": \"future\",\n    \"3-1\": \"Subscriptions that will start in the future, they are not active yet\",\n    \"4-0\": \"in_trial\",\n    \"4-1\": \"Subscriptions that are active or canceled and are in a trial period\",\n    \"5-0\": \"live\",\n    \"5-1\": \"All subscriptions that are not expired\",\n    \"6-0\": \"past_due\",\n    \"6-1\": \"Subscriptions that are active or canceled and have a past-due invoice\"\n  },\n  \"cols\": 2,\n  \"rows\": 7\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"\",\n  \"body\": \"Please note: a queried state and the base state of a returned subscription may differ. For example, querying for past_due subscriptions will not result in a list of subscriptions with a 'past_due' state (they will either be 'active' or 'canceled'). Only base states ('pending', 'active', 'canceled', 'expired', 'future') will be present in the returned subscription records.\"\n}\n[/block]","category":"56fd7e6b5a08190e00084f52","createdAt":"2015-06-18T01:07:04.439Z","excerpt":"Returns a list of all the subscriptions.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":0,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-subscriptions","sync_unique":"","title":"List Subscriptions","type":"get","updates":["55b102d96c91eb2d008712bf"],"user":"556790090145bc23008e3bf8","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Subscriptions

Returns a list of all the subscriptions.

state:
string
The state of subscriptions to return: "active", "canceled", "expired", "future", "in_trial", "live", or "past_due". A subscription may belong to more than one state.
cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
string50
Number of records to return per page, up to a maximum of 200.
###Subscription Query States [block:parameters] { "data": { "h-0": "state", "h-1": "description", "0-0": "active", "0-1": "Subscriptions that are valid for the current time. This includes subscriptions in a trial period", "1-0": "canceled", "1-1": "Subscriptions that are valid for the current time but will not renew because a cancelation was requested", "2-0": "expired", "2-1": "Subscriptions that have expired and are no longer valid", "3-0": "future", "3-1": "Subscriptions that will start in the future, they are not active yet", "4-0": "in_trial", "4-1": "Subscriptions that are active or canceled and are in a trial period", "5-0": "live", "5-1": "All subscriptions that are not expired", "6-0": "past_due", "6-1": "Subscriptions that are active or canceled and have a past-due invoice" }, "cols": 2, "rows": 7 } [/block] [block:callout] { "type": "warning", "title": "", "body": "Please note: a queried state and the base state of a returned subscription may differ. For example, querying for past_due subscriptions will not result in a list of subscriptions with a 'past_due' state (they will either be 'active' or 'canceled'). Only base states ('pending', 'active', 'canceled', 'expired', 'future') will be present in the returned subscription records." } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



###Subscription Query States [block:parameters] { "data": { "h-0": "state", "h-1": "description", "0-0": "active", "0-1": "Subscriptions that are valid for the current time. This includes subscriptions in a trial period", "1-0": "canceled", "1-1": "Subscriptions that are valid for the current time but will not renew because a cancelation was requested", "2-0": "expired", "2-1": "Subscriptions that have expired and are no longer valid", "3-0": "future", "3-1": "Subscriptions that will start in the future, they are not active yet", "4-0": "in_trial", "4-1": "Subscriptions that are active or canceled and are in a trial period", "5-0": "live", "5-1": "All subscriptions that are not expired", "6-0": "past_due", "6-1": "Subscriptions that are active or canceled and have a past-due invoice" }, "cols": 2, "rows": 7 } [/block] [block:callout] { "type": "warning", "title": "", "body": "Please note: a queried state and the base state of a returned subscription may differ. For example, querying for past_due subscriptions will not result in a list of subscriptions with a 'past_due' state (they will either be 'active' or 'canceled'). Only base states ('pending', 'active', 'canceled', 'expired', 'future') will be present in the returned subscription records." } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f55","api":{"examples":{"codes":[{"name":"","code":"<?php\ntry {\n  $subscriptions = Recurly_SubscriptionList::getForAccount('b6f5783');\n  foreach ($subscriptions as $subscription) {\n    print \"Subscription: $subscription\\n\";\n  }\n} catch (Recurly_NotFoundError $e) {\n  print \"Account Not Found: $e\";\n}\n?>","language":"php"},{"code":"account = Recurly::Account.find('1')\naccount.subscriptions.find_each do |subscription|\n  puts \"Subscription: #{subscription.inspect}\"\nend","language":"ruby"},{"code":"#client version 2.1.6+\naccount = Account.get('1')\nfor subscription in account.subscriptions():\n    print 'Subscription: %s' % subscription\n\n#client version <= 2.1.5\naccount = Account.get('1')\nsubscriptions = account.subscriptions()\nwhile subscriptions:\n    for subscription in subscriptions:\n        print 'Subscription: %s' % subscription\n    try:\n        subscriptions = subscriptions.next_page()\n    except PageError:\n        subscriptions = ()","language":"python"},{"code":"using System.Linq;\n\nvar account = Accounts.Get(\"1\");\nvar subscriptions = account.GetSubscriptions();\nwhile (subscriptions.Any())\n{\n  foreach (var subscription in subscriptions)\n    Console.WriteLine(\"Subscription: \" + subscription);\n  subscriptions = subscriptions.Next;\n}","language":"csharp"}]},"results":{"codes":[{"status":200,"language":"xml","code":"<subscriptions type=\"array\">\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f3b96d\n99067eb08904457a9180eb\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/4568526784588812\"/\n>\n    <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1768\"/>\n    <plan href=\"https://your-subdomain.recurly.com/v2/plans/plic\">\n      <plan_code>plic</plan_code>\n      <name>Premium Licence</name>\n    </plan>\n    <uuid>3053f3b96d99067eb08904457a9180eb</uuid>\n    <state>active</state>\n    <unit_amount_in_cents type=\"integer\">24995</unit_amount_in_cents>\n    <currency>USD</currency>\n    <quantity type=\"integer\">1</quantity>\n    <activated_at type=\"datetime\">2015-07-31T17:28:31Z</activated_at>\n    <canceled_at nil=\"nil\"></canceled_at>\n    <expires_at nil=\"nil\"></expires_at>\n    <total_billing_cycles nil=\"nil\"></total_billing_cycles>\n    <remaining_billing_cycles nil=\"nil\"></remaining_billing_cycles>\n    <current_period_started_at type=\"datetime\">2015-07-31T17:28:31Z</current_per\niod_started_at>\n    <current_period_ends_at type=\"datetime\">2016-07-31T17:28:31Z</current_period\n_ends_at>\n    <trial_started_at nil=\"nil\"></trial_started_at>\n    <trial_ends_at nil=\"nil\"></trial_ends_at>\n    <terms_and_conditions></terms_and_conditions>\n    <customer_notes></customer_notes>\n    <tax_in_cents type=\"integer\">2250</tax_in_cents>\n    <tax_type>usst</tax_type>\n    <tax_region>CA</tax_region>\n    <tax_rate type=\"float\">0.09</tax_rate>\n    <po_number></po_number>\n    <net_terms type=\"integer\">0</net_terms>\n    <collection_method>automatic</collection_method>\n    <subscription_add_ons type=\"array\">\n    </subscription_add_ons>\n    <a name=\"cancel\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f\n3b96d99067eb08904457a9180eb/cancel\" method=\"put\"/>\n    <a name=\"terminate\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/30\n53f3b96d99067eb08904457a9180eb/terminate\" method=\"put\"/>\n    <a name=\"postpone\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/305\n3f3b96d99067eb08904457a9180eb/postpone\" method=\"put\"/>\n    <a name=\"notes\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f3\nb96d99067eb08904457a9180eb/notes\" method=\"put\"/>\n  </subscription>\n  <subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f29711\nd5aa94abd0244df2832937\">\n    <account href=\"https://your-subdomain.recurly.com/v2/accounts/4568526784588812\"/\n>\n    <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1767\"/>\n    <plan href=\"https://your-subdomain.recurly.com/v2/plans/pro\">\n      <plan_code>pro</plan_code>\n      <name>Pro</name>\n    </plan>\n    <uuid>3053f29711d5aa94abd0244df2832937</uuid>\n    <state>active</state>\n    <unit_amount_in_cents type=\"integer\">3000</unit_amount_in_cents>\n    <currency>USD</currency>\n    <quantity type=\"integer\">1</quantity>\n    <activated_at type=\"datetime\">2015-07-31T17:27:17Z</activated_at>\n    <canceled_at nil=\"nil\"></canceled_at>\n    <expires_at nil=\"nil\"></expires_at>\n    <total_billing_cycles nil=\"nil\"></total_billing_cycles>\n    <remaining_billing_cycles nil=\"nil\"></remaining_billing_cycles>\n    <current_period_started_at type=\"datetime\">2015-07-31T17:27:17Z</current_per\niod_started_at>\n    <current_period_ends_at type=\"datetime\">2015-08-31T17:27:17Z</current_period\n_ends_at>\n    <trial_started_at nil=\"nil\"></trial_started_at>\n    <trial_ends_at nil=\"nil\"></trial_ends_at>\n    <terms_and_conditions></terms_and_conditions>\n    <customer_notes></customer_notes>\n    <tax_in_cents type=\"integer\">270</tax_in_cents>\n    <tax_type>usst</tax_type>\n    <tax_region>CA</tax_region>\n    <tax_rate type=\"float\">0.09</tax_rate>\n    <po_number></po_number>\n    <net_terms type=\"integer\">0</net_terms>\n    <collection_method>automatic</collection_method>\n    <subscription_add_ons type=\"array\">\n    </subscription_add_ons>\n    <a name=\"cancel\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f\n29711d5aa94abd0244df2832937/cancel\" method=\"put\"/>\n    <a name=\"terminate\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/30\n53f29711d5aa94abd0244df2832937/terminate\" method=\"put\"/>\n    <a name=\"postpone\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/305\n3f29711d5aa94abd0244df2832937/postpone\" method=\"put\"/>\n    <a name=\"notes\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/3053f2\n9711d5aa94abd0244df2832937/notes\" method=\"put\"/>\n  </subscription>\n</subscriptions>","name":""}]},"settings":"","auth":"required","params":[{"_id":"55821a9e5b7fa60d0068b421","ref":"","required":false,"desc":"The state of subscriptions to return: \"active\", \"canceled\", \"expired\", \"future\", \"in_trial\", \"live\", or \"past_due\". A subscription may belong to more than one state. Please see the previous section for a note on subscription states.","default":"live","type":"string","name":"state"},{"_id":"55821a9e5b7fa60d0068b420","ref":"","required":false,"desc":"Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.","default":"","type":"string","name":"cursor"},{"_id":"55821a9e5b7fa60d0068b41f","ref":"","required":false,"desc":"Number of records to return per page, up to a maximum of 200.","default":"50","type":"string","name":"per_page"}],"url":"/accounts/:account_code/subscriptions"},"body":"","category":"56fd7e6b5a08190e00084f52","createdAt":"2015-06-18T01:10:54.210Z","excerpt":"Returns a list of subscriptions for an account.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":1,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"list-accounts-subscriptions","sync_unique":"","title":"List Account's Subscriptions","type":"get","updates":[],"user":"556790090145bc23008e3bf8","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getList Account's Subscriptions

Returns a list of subscriptions for an account.

state:
stringlive
The state of subscriptions to return: "active", "canceled", "expired", "future", "in_trial", "live", or "past_due". A subscription may belong to more than one state. Please see the previous section for a note on subscription states.
cursor:
string
Splits records across pages. Leave blank to return the first page. Follow the URI in the first page's Link header to fetch the next page.
per_page:
string50
Number of records to return per page, up to a maximum of 200.

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



{"__v":0,"_id":"56fd7e6b5a08190e00084f56","api":{"examples":{"codes":[{"name":"","code":"try {\n  $subscription = Recurly_Subscription::get('44f83d7cba354d5b84812419f923ea96');\n\n  print \"Subscription: $subscription\";\n} catch (Recurly_NotFoundError $e) {\n  print \"Subscription Not Found: $e\";\n}","language":"php"},{"code":"subscription = Recurly::Subscription.find('44f83d7cba354d5b84812419f923ea96')","language":"ruby"},{"code":"subscription = Subscription.get('44f83d7cba354d5b84812419f923ea96')","language":"python"},{"code":"var subscription = Subscriptions.Get(\"44f83d7cba354d5b84812419f923ea96\");","language":"csharp"}]},"results":{"codes":[{"status":200,"language":"xml","code":"<subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n    <plan_code>gold</plan_code>\n    <name>Gold plan</name>\n  </plan>\n  <uuid>44f83d7cba354d5b84812419f923ea96</uuid>\n  <state>active</state>\n  <unit_amount_in_cents type=\"integer\">800</unit_amount_in_cents>\n  <currency>EUR</currency>\n  <quantity type=\"integer\">1</quantity>\n  <activated_at type=\"datetime\">2011-05-27T07:00:00Z</activated_at>\n  <canceled_at nil=\"nil\"></canceled_at>\n  <expires_at nil=\"nil\"></expires_at>\n  <current_period_started_at type=\"datetime\">2011-06-27T07:00:00Z</current_period_started_at>\n  <current_period_ends_at type=\"datetime\">2010-07-27T07:00:00Z</current_period_ends_at>\n  <trial_started_at nil=\"nil\"></trial_started_at>\n  <trial_ends_at nil=\"nil\"></trial_ends_at>\n  <tax_in_cents type=\"integer\">80</tax_in_cents>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0.0875</tax_rate>\n  <po_number nil=\"nil\"></po_number>\n  <net_terms type=\"integer\">0</net_terms>\n  <subscription_add_ons type=\"array\">\n  </subscription_add_ons>\n  <a name=\"cancel\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/cancel\" method=\"put\"/>\n  <a name=\"terminate\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/terminate\" method=\"put\"/>\n  <a name=\"postpone\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/postpone\" method=\"put\"/>\n</subscription>","name":""}]},"settings":"","auth":"required","params":[],"url":"/subscriptions/:uuid"},"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"When looking up a subscription that has pending changes, the new subscription details will be in a pending_subscription node. Since immediate subscription changes take place immediately, pending subscription changes will only show for changes occurring when the subscription renews.\",\n  \"title\": \"PENDING SUBSCRIPTION CHANGES\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Subscription Parameters\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"plan\",\n    \"0-1\": \"Nested plan_code and plan name\",\n    \"1-0\": \"uuid\",\n    \"1-1\": \"Unique subscription ID\",\n    \"2-0\": \"state\",\n    \"2-1\": \"`active`, `canceled`, `future`, `expired`\",\n    \"3-0\": \"unit_amount_in_cents\",\n    \"3-1\": \"Unit amount of the subscription\",\n    \"4-1\": \"Number of units\",\n    \"5-1\": \"3-letter ISO currency for the subscription\",\n    \"6-1\": \"Date the subscription started\",\n    \"7-1\": \"Date the subscription was marked canceled\",\n    \"8-1\": \"Date the subscription will end (if state is `canceled`) or ended (if state is `expired`)\",\n    \"9-1\": \"Date the current bill cycle started\",\n    \"10-1\": \"Date the current bill cycle will end\",\n    \"11-1\": \"Date the trial was started, if applicable\",\n    \"12-1\": \"Date the trial ended, if applicable\",\n    \"13-1\": \"Amount of tax or VAT within the transaction, in cents.\",\n    \"14-1\": \"Tax type as \\\"vat\\\" for VAT or \\\"usst\\\" for US Sales Tax.\",\n    \"15-1\": \"Region where taxes are applied.\",\n    \"16-1\": \"Tax rate that will be applied to this subscription.\",\n    \"17-1\": \"PO number reference.\",\n    \"18-1\": \"Invoice net terms in days.\",\n    \"19-1\": \"Invoice collection as \\\"automatic\\\" or \\\"manual\\\".\",\n    \"20-1\": \"Nested list of add-ons on the subscription, if applicable\",\n    \"21-1\": \"Nested information about a pending subscription change at renewal\",\n    \"22-1\": \"Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.\",\n    \"23-1\": \"Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Customer Notes. Custom notes will stay with a subscription on all renewals.\",\n    \"24-1\": \"Recurring subscriptions paid with ACH will have this attribute with an iso8601 timestamp value. This timestamp is used for alerting customers to reauthorize in 3 years in accordance with NACHA rules. If a subscription becomes inactive or the billing info is no longer a bank account, this timestamp is cleared and the attribute will not exist.\",\n    \"25-1\": \"**Description**\",\n    \"26-1\": \"Nested information about the new plan\",\n    \"27-1\": \"New subscription's unit amount in cents\",\n    \"28-1\": \"New subscription quantity\",\n    \"29-1\": \"Nested list of add-ons\",\n    \"29-0\": \"subscription_add_ons\",\n    \"28-0\": \"quantity\",\n    \"26-0\": \"plan\",\n    \"27-0\": \"unit_amount_in_cents\",\n    \"25-0\": \"**Subscription Parameters**\",\n    \"24-0\": \"bank_account_authorized_at\",\n    \"23-0\": \"customer_notes\",\n    \"22-0\": \"terms_and_conditions\",\n    \"21-0\": \"pending_subscription\",\n    \"20-0\": \"subscription_add_ons\",\n    \"19-0\": \"collection_method\",\n    \"18-0\": \"net_terms\",\n    \"17-0\": \"po_number\",\n    \"16-0\": \"tax_rate\",\n    \"15-0\": \"tax_region\",\n    \"14-0\": \"tax_type\",\n    \"13-0\": \"tax_in_cents\",\n    \"12-0\": \"trial_ends_at\",\n    \"11-0\": \"trial_started_at\",\n    \"10-0\": \"current_period_ends_at\",\n    \"9-0\": \"current_period_started_at\",\n    \"8-0\": \"expires_at\",\n    \"7-0\": \"canceled_at\",\n    \"6-0\": \"activated_at\",\n    \"5-0\": \"currency\",\n    \"4-0\": \"quantity\"\n  },\n  \"cols\": 2,\n  \"rows\": 30\n}\n[/block]","category":"56fd7e6b5a08190e00084f52","createdAt":"2015-06-18T01:22:21.025Z","excerpt":"Lookup a subscription's details.","githubsync":"","hidden":false,"isReference":false,"link_external":false,"link_url":"","order":2,"parentDoc":null,"project":"555fbba928249c1900618a82","slug":"lookup-subscription-details","sync_unique":"","title":"Lookup Subscription Details","type":"get","updates":[],"user":"556790090145bc23008e3bf8","version":"56fd7e6b5a08190e00084f45","childrenPages":[]}

getLookup Subscription Details

Lookup a subscription's details.

[block:callout] { "type": "info", "body": "When looking up a subscription that has pending changes, the new subscription details will be in a pending_subscription node. Since immediate subscription changes take place immediately, pending subscription changes will only show for changes occurring when the subscription renews.", "title": "PENDING SUBSCRIPTION CHANGES" } [/block] [block:parameters] { "data": { "h-0": "Subscription Parameters", "h-1": "Description", "0-0": "plan", "0-1": "Nested plan_code and plan name", "1-0": "uuid", "1-1": "Unique subscription ID", "2-0": "state", "2-1": "`active`, `canceled`, `future`, `expired`", "3-0": "unit_amount_in_cents", "3-1": "Unit amount of the subscription", "4-1": "Number of units", "5-1": "3-letter ISO currency for the subscription", "6-1": "Date the subscription started", "7-1": "Date the subscription was marked canceled", "8-1": "Date the subscription will end (if state is `canceled`) or ended (if state is `expired`)", "9-1": "Date the current bill cycle started", "10-1": "Date the current bill cycle will end", "11-1": "Date the trial was started, if applicable", "12-1": "Date the trial ended, if applicable", "13-1": "Amount of tax or VAT within the transaction, in cents.", "14-1": "Tax type as \"vat\" for VAT or \"usst\" for US Sales Tax.", "15-1": "Region where taxes are applied.", "16-1": "Tax rate that will be applied to this subscription.", "17-1": "PO number reference.", "18-1": "Invoice net terms in days.", "19-1": "Invoice collection as \"automatic\" or \"manual\".", "20-1": "Nested list of add-ons on the subscription, if applicable", "21-1": "Nested information about a pending subscription change at renewal", "22-1": "Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.", "23-1": "Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Customer Notes. Custom notes will stay with a subscription on all renewals.", "24-1": "Recurring subscriptions paid with ACH will have this attribute with an iso8601 timestamp value. This timestamp is used for alerting customers to reauthorize in 3 years in accordance with NACHA rules. If a subscription becomes inactive or the billing info is no longer a bank account, this timestamp is cleared and the attribute will not exist.", "25-1": "**Description**", "26-1": "Nested information about the new plan", "27-1": "New subscription's unit amount in cents", "28-1": "New subscription quantity", "29-1": "Nested list of add-ons", "29-0": "subscription_add_ons", "28-0": "quantity", "26-0": "plan", "27-0": "unit_amount_in_cents", "25-0": "**Subscription Parameters**", "24-0": "bank_account_authorized_at", "23-0": "customer_notes", "22-0": "terms_and_conditions", "21-0": "pending_subscription", "20-0": "subscription_add_ons", "19-0": "collection_method", "18-0": "net_terms", "17-0": "po_number", "16-0": "tax_rate", "15-0": "tax_region", "14-0": "tax_type", "13-0": "tax_in_cents", "12-0": "trial_ends_at", "11-0": "trial_started_at", "10-0": "current_period_ends_at", "9-0": "current_period_started_at", "8-0": "expires_at", "7-0": "canceled_at", "6-0": "activated_at", "5-0": "currency", "4-0": "quantity" }, "cols": 2, "rows": 30 } [/block]

Definition

{{ api_url }}{{ page_api_url }}

Examples


Result Format



[block:callout] { "type": "info", "body": "When looking up a subscription that has pending changes, the new subscription details will be in a pending_subscription node. Since immediate subscription changes take place immediately, pending subscription changes will only show for changes occurring when the subscription renews.", "title": "PENDING SUBSCRIPTION CHANGES" } [/block] [block:parameters] { "data": { "h-0": "Subscription Parameters", "h-1": "Description", "0-0": "plan", "0-1": "Nested plan_code and plan name", "1-0": "uuid", "1-1": "Unique subscription ID", "2-0": "state", "2-1": "`active`, `canceled`, `future`, `expired`", "3-0": "unit_amount_in_cents", "3-1": "Unit amount of the subscription", "4-1": "Number of units", "5-1": "3-letter ISO currency for the subscription", "6-1": "Date the subscription started", "7-1": "Date the subscription was marked canceled", "8-1": "Date the subscription will end (if state is `canceled`) or ended (if state is `expired`)", "9-1": "Date the current bill cycle started", "10-1": "Date the current bill cycle will end", "11-1": "Date the trial was started, if applicable", "12-1": "Date the trial ended, if applicable", "13-1": "Amount of tax or VAT within the transaction, in cents.", "14-1": "Tax type as \"vat\" for VAT or \"usst\" for US Sales Tax.", "15-1": "Region where taxes are applied.", "16-1": "Tax rate that will be applied to this subscription.", "17-1": "PO number reference.", "18-1": "Invoice net terms in days.", "19-1": "Invoice collection as \"automatic\" or \"manual\".", "20-1": "Nested list of add-ons on the subscription, if applicable", "21-1": "Nested information about a pending subscription change at renewal", "22-1": "Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.", "23-1": "Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Customer Notes. Custom notes will stay with a subscription on all renewals.", "24-1": "Recurring subscriptions paid with ACH will have this attribute with an iso8601 timestamp value. This timestamp is used for alerting customers to reauthorize in 3 years in accordance with NACHA rules. If a subscription becomes inactive or the billing info is no longer a bank account, this timestamp is cleared and the attribute will not exist.", "25-1": "**Description**", "26-1": "Nested information about the new plan", "27-1": "New subscription's unit amount in cents", "28-1": "New subscription quantity", "29-1": "Nested list of add-ons", "29-0": "subscription_add_ons", "28-0": "quantity", "26-0": "plan", "27-0": "unit_amount_in_cents", "25-0": "**Subscription Parameters**", "24-0": "bank_account_authorized_at", "23-0": "customer_notes", "22-0": "terms_and_conditions", "21-0": "pending_subscription", "20-0": "subscription_add_ons", "19-0": "collection_method", "18-0": "net_terms", "17-0": "po_number", "16-0": "tax_rate", "15-0": "tax_region", "14-0": "tax_type", "13-0": "tax_in_cents", "12-0": "trial_ends_at", "11-0": "trial_started_at", "10-0": "current_period_ends_at", "9-0": "current_period_started_at", "8-0": "expires_at", "7-0": "canceled_at", "6-0": "activated_at", "5-0": "currency", "4-0": "quantity" }, "cols": 2, "rows": 30 } [/block]
{"__v":0,"_id":"56fd7e6b5a08190e00084f57","api":{"examples":{"codes":[{"name":"","code":"try {\n  $subscription = new Recurly_Subscription();\n  $subscription->plan_code = 'gold';\n  $subscription->currency = 'EUR';\n\n  $account = new Recurly_Account();\n  $account->account_code = 'b6f5783';\n  $account->email = 'verena@example.com';\n  $account->first_name = 'Verena';\n  $account->last_name = 'Example';\n\n  $billing_info = new Recurly_BillingInfo();\n  $billing_info->number = '4111-1111-1111-1111';\n  $billing_info->month = 12;\n  $billing_info->year = 2017;\n  $billing_info->verification_value = 123;\n  $billing_info->address1 = '400 Alabama St';\n  $billing_info->city = 'San Francisco';\n  $billing_info->state = 'CA';\n  $billing_info->country = 'US';\n  $billing_info->zip = '94110';\n\n  $account->billing_info = $billing_info;\n  $subscription->account = $account;\n\n  $subscription->create();\n\n  print \"Subscription: $subscription\";\n} catch (Recurly_ValidationError $e) {\n  print \"Invalid Plan, Subscription, Account, or BillingInfo data: $e\";\n}","language":"php"},{"code":"subscription = Recurly::Subscription.create(\n  :plan_code => 'gold',\n  :currency  => 'EUR',\n  :customer_notes  => 'Thank you for your business!',\n  :account   => {\n    :account_code => '1',\n    :email        => 'verena@example.com',\n    :first_name   => 'Verena',\n    :last_name    => 'Example',\n    :billing_info => {\n      :number => '4111-1111-1111-1111',\n      :month  => 1,\n      :year   => 2014,\n    }\n  }\n)","language":"ruby"},{"code":"subscription = Subscription()\nsubscription.plan_code = 'gold'\nsubscription.currency = 'EUR'\n\naccount = Account(account_code='1')\naccount.email = 'verena@example.com'\naccount.first_name = 'Verena'\naccount.last_name = 'Example'\n\nbilling_info = BillingInfo()\nbilling_info.number = '4111-1111-1111-1111'\nbilling_info.month = 1\nbilling_info.year = 2014\n\naccount.billing_info = billing_info\nsubscription.account = account\n\nsubscription.save()","language":"python"},{"code":"var account = Accounts.Get(\"1\"); // Account contains BillingInfo\nvar plan = Plans.Get(\"gold\");\nvar subscription = new Subscription(account, plan, \"USD\"); // account, plan, currency\nsubscription.Create();","language":"csharp"},{"code":"<subscription>\n  <plan_code>gold</plan_code>\n  <currency>EUR</currency>\n  <account>\n    <account_code>1</account_code>\n    <email>verena@example.com</email>\n    <first_name>Verena</first_name>\n    <last_name>Example</last_name>\n    <billing_info>\n      <number>4111-1111-1111-1111</number>\n      <month>1</month>\n      <year>2014</year>\n    </billing_info>\n  </account>\n</subscription>","language":"xml"}]},"results":{"codes":[{"name":"","code":"<subscription href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96\">\n  <account href=\"https://your-subdomain.recurly.com/v2/accounts/1\"/>\n  <invoice href=\"https://your-subdomain.recurly.com/v2/invoices/1108\"/>\n  <plan href=\"https://your-subdomain.recurly.com/v2/plans/gold\">\n    <plan_code>gold</plan_code>\n    <name>Gold plan</name>\n  </plan>\n  <uuid>44f83d7cba354d5b84812419f923ea96</uuid>\n  <state>active</state>\n  <unit_amount_in_cents type=\"integer\">800</unit_amount_in_cents>\n  <currency>EUR</currency>\n  <quantity type=\"integer\">1</quantity>\n  <activated_at type=\"datetime\">2011-05-27T07:00:00Z</activated_at>\n  <canceled_at nil=\"nil\"></canceled_at>\n  <expires_at nil=\"nil\"></expires_at>\n  <current_period_started_at type=\"datetime\">2011-06-27T07:00:00Z</current_period_started_at>\n  <current_period_ends_at type=\"datetime\">2010-07-27T07:00:00Z</current_period_ends_at>\n  <trial_started_at nil=\"nil\"></trial_started_at>\n  <trial_ends_at nil=\"nil\"></trial_ends_at>\n  <tax_in_cents type=\"integer\">80</tax_in_cents>\n  <tax_type>usst</tax_type>\n  <tax_region>CA</tax_region>\n  <tax_rate type=\"float\">0.0875</tax_rate>\n  <po_number nil=\"nil\"></po_number>\n  <net_terms type=\"integer\">0</net_terms>\n  <subscription_add_ons type=\"array\">\n  </subscription_add_ons>\n  <a name=\"cancel\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/cancel\" method=\"put\"/>\n  <a name=\"terminate\" href=\"https://your-subdomain.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96/terminate\" method=\"put\"/>\n</subscription>","language":"xml","status":201},{"code":"<errors>\n    <error field=\"subscription.coupon_code\" symbol=\"invalid\">is invalid</error>\n</errors>","language":"xml","status":400,"name":"Expired/Invalid Coupon"}]},"settings":"","auth":"required","params":[{"_id":"55821f1f6f8ec90d00cf1a76","ref":"","required":true,"desc":"plan_code for the subscription","default":"","type":"string","name":"plan_code"},{"_id":"55821f1f6f8ec90d00cf1a75","ref":"","required":true,"desc":"nested account attributes","default":"","type":"object","name":"account"},{"_id":"55821f1f6f8ec90d00cf1a71","ref":"","required":true,"desc":"Currency for the subscription","default":"","type":"string","name":"currency"},{"_id":"55821f1f6f8ec90d00cf1a74","ref":"","required":false,"desc":"nested add ons","default":"","type":"array_mixed","name":"subscription_add_ons"},{"_id":"55821f1f6f8ec90d00cf1a73","ref":"","required":false,"desc":"Optional coupon code to redeem on the account and discount the subscription. Please note, the subscription request will fail if the coupon is invalid.","default":"","type":"string","name":"coupon_code"},{"_id":"55821f1f6f8ec90d00cf1a72","ref":"","required":false,"desc":"Override the unit amount of the subscription plan by setting this value in cents. If not provided, the subscription will inherit the price from the subscription plan for the provided currency. Max 10000000.","default":"","type":"int","name":"unit_amount_in_cents"},{"_id":"55821f1f6f8ec90d00cf1a70","ref":"","required":false,"desc":"Optionally override the default quantity of 1","default":"","type":"int","name":"quantity"},{"_id":"55821f1f6f8ec90d00cf1a6f","ref":"","required":false,"desc":"If set, overrides the default trial behavior for the subscription. This must be a date and time, preferably in UTC. The date must be in the future.","default":"","type":"datetime","name":"trial_ends_at"},{"_id":"55821f1f6f8ec90d00cf1a6e","ref":"","required":false,"desc":"If set, the subscription will begin in the future on this date. The subscription will apply the setup fee and trial period, unless the plan has no trial.","default":"","type":"datetime","name":"starts_at"},{"_id":"55821f1f6f8ec90d00cf1a6d","ref":"","required":false,"desc":"Renews the subscription for a specified number of cycles, then automatically cancels. Defaults to the subscription renewing indefinitely.","default":"","type":"int","name":"total_billing_cycles"},{"_id":"55821f1f6f8ec90d00cf1a6c","ref":"","required":false,"desc":"Indicates a date at which the first renewal should occur. Subsequent renewals will be offset from this date. The first invoice will be prorated appropriately so that the customer only pays for the portion of the first billing period for which the subscription applies. Useful for forcing a subscription to renew on the first of the month.","default":"","type":"datetime","name":"first_renewal_date"},{"_id":"55821f1f6f8ec90d00cf1a6b","ref":"","required":false,"desc":"Optional field to set the collection for an invoice as \"automatic\" or \"manual\". The default is \"automatic\" if it's not set.","default":"","type":"string","name":"collection_method"},{"_id":"55821f1f6f8ec90d00cf1a6a","ref":"","required":false,"desc":"Integer representing the number of days after an invoice's creation that the invoice will become past due. If an invoice's net terms are set to '0', it is due 'On Receipt' and will become past due 24 hours after it’s created. If an invoice is due net 30, it will become past due at 31 days exactly. Defaults to '0'.","default":"0","type":"int","name":"net_terms"},{"_id":"55821f1f6f8ec90d00cf1a69","ref":"","required":false,"desc":"Optional notes field. Attach a PO number to the invoice.","default":"","type":"string","name":"po_number"},{"_id":"55821f1f6f8ec90d00cf1a68","ref":"","required":false,"desc":"Optional field to be used only when needing to bypass the 60 second limit on creating subscriptions. Should only be used when creating subscriptions in bulk from the API. Set to 'true' or 'false'. Defaults to 'false'.","default":"false","type":"boolean","name":"bulk"},{"_id":"55821f1f6f8ec90d00cf1a67","ref":"","required":false,"desc":"Optional notes field. This will default to the Terms and Conditions text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Terms and Conditions. Custom notes will stay with a subscription on all renewals.","default":"","type":"string","name":"terms_and_conditions"},{"_id":"55821f1f6f8ec90d00cf1a66","ref":"","required":false,"desc":"Optional notes field. This will default to the Customer Notes text specified on the Invoice Settings page in your Recurly admin. Specify custom notes with this tag to add or override Customer Notes. Custom notes will stay with a subscription on all renewals.","default":"","type":"string","name":"customer_notes"},{"_id":"55821f1f6f8ec90d00cf1a65","ref":"","required":false,"desc":"VAT Reverse Charge Notes only appear if you have EU VAT enabled or are using your own Avalara AvaTax account and the customer is in the EU, has a VAT number, and is in a different country than your own. This will default to the VAT Reverse Charge Notes text specified on the Tax Settings page in your Recurly admin, unless custom notes were created with the original subscription. Specify custom notes with this tag to add or override VAT Reverse Charge Notes. Custom notes will stay with a subscription on all renewals.","default":"","type":"string","name":"vat_reverse_charge_notes"},{"_id":"55821f1f6f8ec90d00cf1a64","ref":"","required":false,"desc":"Merchants importing recurring subscriptions paid with ACH into Recurly can backdate the subscription's authorization with this attribute using an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. This timestamp is used for alerti