### cURL Request Example Source: https://docs.recurly.com/recurly-commerce/reference/listswapandaddonoptions Demonstrates how to make a GET request to retrieve swap and add-on options using cURL. Includes example query parameters for pagination. ```Shell curl --request GET \ --url 'https://subs.api.recurlycommerce.com/api/v1/swapAndAddOnOptions?page=1&limit=10' \ --header 'accept: application/json' ``` -------------------------------- ### Braze Instance URL Example Source: https://docs.recurly.com/docs/braze-integration An example of a Braze instance URL. Ensure you select the correct URL for your Braze instance during integration setup. ```text https://dashboard-03.braze.com/dashboard/app_usage?locale=en ``` -------------------------------- ### Python Example for Performance Obligations Source: https://docs.recurly.com/recurly-subscriptions/v2.29/reference/get_performance_obligations This Python code snippet shows how to get performance obligations using the 'requests' library. Make sure to install it using 'pip install requests'. ```python import requests url = "https://my-super-successful-company.recurly.com/v2/performance_obligations" headers = { 'accept': 'application/xml' } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Example GET Request for Dynamic Image Resizing Source: https://docs.recurly.com/recurly-engage/reference/dynamic-image-resizing Use this example to request a dynamically sized image asset. This feature only works for images hosted by the Redfast platform. If an invalid `screen_size` is provided, the original image will be returned. ```http GET https://abcdef.redfastlabs.com/assets/test.png?screen_size=720 ``` -------------------------------- ### Fetch External Product Reference (Node.js) Source: https://docs.recurly.com/recurly-subscriptions/v2.29/reference/external-product-references Example using Node.js to make a GET request to retrieve an external product reference. Ensure you have the necessary libraries installed and replace placeholders with your specific details. ```javascript const https = require('https'); const options = { method: 'GET', hostname: 'my-super-successful-company.recurly.com', port: null, path: '/v2/external_product_references/external_product_reference_id', headers: { 'accept': 'application/xml' } }; const req = https.request(options, function (res) { const chunks = []; res.on('data', function (chunk) { chunks.push(chunk); }); res.on('end', function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); res.on('error', function (error) { console.error(error); }); }); req.end(); ``` -------------------------------- ### Create a Tiered Plan with Add-on (JavaScript) Source: https://docs.recurly.com/recurly-subscriptions/docs/quantity-based-pricing-guide This JavaScript example demonstrates creating a plan with a tiered pricing add-on. It uses `async/await` for handling the API call. ```JavaScript const planCreate = { code: 'tiered-tshirt-plan', name: 'Tiered T-shirt Plan', currencies: [ { currency: 'USD', unitAmount: 100 } ], add_ons: [ { item_code: item.code, display_quantity: true, tier_type: 'tiered', tiers: [ { currencies: [ { currency: 'USD', unit_amount: 20 } ], ending_quantity: 100 }, { currencies: [ { currency: 'USD', unit_amount: 15 } ], ending_quantity: 999999999 // maximum value } ] } ] } const plan = await client.createPlan(planCreate) console.log('Created Plan: ', plan.code) ``` -------------------------------- ### Get Preview Renewal Source: https://docs.recurly.com/recurly-subscriptions/v2021-02-25/reference/get_preview_renewal This example shows how to make a GET request to the preview renewal endpoint using cURL. ```APIDOC ## GET /subscriptions/{subscription_id}/preview_renewal ### Description Retrieves a preview of a subscription's renewal details. ### Method GET ### Endpoint /subscriptions/{subscription_id}/preview_renewal ### Parameters #### Path Parameters - **subscription_id** (string) - Required - The ID of the subscription to preview the renewal for. #### Query Parameters None #### Request Body None ### Request Example ```bash curl --request GET \ --url https://v3.recurly.com/subscriptions/subscription_id/preview_renewal \ --header 'accept: application/json' ``` ### Response #### Success Response (200) - **renewal_details** (object) - Contains the details of the upcoming renewal. - **next_billing_date** (string) - The date of the next billing cycle. - **next_billing_period** (object) - The billing period for the next renewal. - **start_date** (string) - The start date of the billing period. - **end_date** (string) - The end date of the billing period. - **total** (object) - The total cost of the renewal. - **amount** (number) - The amount of the renewal. - **currency** (string) - The currency of the renewal amount. #### Response Example ```json { "renewal_details": { "next_billing_date": "2023-12-31T00:00:00Z", "next_billing_period": { "start_date": "2023-12-01T00:00:00Z", "end_date": "2023-12-31T23:59:59Z" }, "total": { "amount": 1000, "currency": "USD" } } } ``` ``` -------------------------------- ### Get Export Files Source: https://docs.recurly.com/recurly-subscriptions/v2019-10-10/reference/get_export_files This example demonstrates how to retrieve a list of export files using a GET request to the Recurly API. ```APIDOC ## GET /sites/{site_id}/export_dates/{export_date}/export_files ### Description Retrieves a list of available export files for a given site and date. ### Method GET ### Endpoint /sites/{site_id}/export_dates/{export_date}/export_files ### Parameters #### Query Parameters - **site_id** (string) - Required - The ID of the site. - **export_date** (string) - Required - The date for which to retrieve export files (YYYY-MM-DD). ### Request Example ```curl curl --request GET \ --url https://v3.recurly.com/sites/site_id/export_dates/export_date/export_files \ --header 'accept: application/json' ``` ### Response #### Success Response (200) - **export_files** (array) - A list of export file objects. - **href** (string) - The URL to download the export file. - **name** (string) - The name of the export file. - **size** (integer) - The size of the export file in bytes. - **created_at** (string) - The timestamp when the export file was created. #### Response Example ```json { "export_files": [ { "href": "https://recurly-exports.s3.amazonaws.com/your-bucket/file.csv.gz?AWSAccessKeyId=...", "name": "file.csv.gz", "size": 102400, "created_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### JavaScript for New Setup with Elements Source: https://docs.recurly.com/recurly-subscriptions/docs/upgrading This JavaScript snippet demonstrates the new setup using Recurly.js Elements, including configuration, Element creation, and attachment. ```javascript recurly.configure('my-public-key'); const elements = recurly.Elements(); const card = elements.CardElement({ style: { inputType: 'mobileSelect', fontColor: '#010101' } }); card.attach('.my-card-element'); ``` -------------------------------- ### Legacy Installation via Local SDK Source: https://docs.recurly.com/recurly-engage/docs/ios-sdk Steps to integrate the Redfast SDK into your project by embedding the Redfast.xcframework file. ```text 1. Within Xcode, select Target > General > Frameworks > Libraries > Embedded Content and click on `+`. 2. Select "Add Other" on bottom left corner and choose "Add Files" 3. Open the `Redfast.xcframework` file 4. Ensure the "Embed & Sign option is selected" 5. Import the SDK into your project 6. Initialize the SDK per instructions below ``` -------------------------------- ### Get a site's Performance Obligations Source: https://docs.recurly.com/recurly-subscriptions/v2021-02-25/reference/get_performance_obligations This example demonstrates how to retrieve a list of performance obligations using a GET request to the Recurly API. ```APIDOC ## Get a site's Performance Obligations ### Description Retrieves a list of performance obligations for a given site. ### Method GET ### Endpoint https://v3.recurly.com/performance_obligations ### Parameters #### Query Parameters None ### Request Example ```curl curl --request GET \ --url https://v3.recurly.com/performance_obligations \ --header 'accept: application/json' ``` ### Response #### Success Response (200) A list of Performance Obligations. #### Response Example ```json { "example": "response body" } ``` #### Error Response (default) Unexpected error. ``` -------------------------------- ### Install Recurly Go Package Source: https://docs.recurly.com/recurly-subscriptions/v2021-02-25/reference/client-libraries Install the Recurly Go client library using 'go get'. This library supports Go 1.16+. ```Bash go get github.com/recurly/recurly-client-go/v3 ``` -------------------------------- ### Create Account with Billing Info Source: https://docs.recurly.com/recurly-subscriptions/v2019-10-10/docs/using-gateway-tokens-and-external-ntids-with-recurly-apis This example demonstrates how to create a new account and store billing information using a gateway token. The `billing_info_id` obtained from this step is crucial for subsequent subscription creation. ```APIDOC ## Create Account with Billing Info ### Description Create an account and store billing information using a gateway token. The `billing_info_id` is a required field for creating subscriptions. ### Method POST ### Endpoint `/accounts` ### Request Body - **code** (string) - Required - Unique identifier for the account. - **email** (string) - Required - Customer's email address. - **preferred_locale** (string) - Optional - Customer's preferred locale. - **preferred_time_zone** (string) - Optional - Customer's preferred time zone. - **billing_info** (object) - Required - Billing information for the account. - **first_name** (string) - Required - Billing first name. - **last_name** (string) - Required - Billing last name. - **address** (object) - Required - Billing address. - **phone** (string) - Optional - Billing phone number. - **street1** (string) - Required - Billing street address. - **city** (string) - Required - Billing city. - **region** (string) - Required - Billing state or region. - **postal_code** (string) - Required - Billing postal code. - **country** (string) - Required - Billing country. - **gateway_attributes** (object) - Optional - Attributes specific to the payment gateway. - **account_reference** (string) - Required for Adyen - The shopper reference from Adyen. - **gateway_token** (string) - Deprecated - Use `payment_gateway_references.token` instead. - **payment_gateway_references** (array) - Optional - References to payment gateway tokens. - **token** (string) - Required - The token obtained from the payment gateway. ### Request Example ```json { "code": "account-code", "email": "johndoe@example.comm", "preferred_locale": "en-US", "preferred_time_zone": "America/Chicago", "billing_info": { "first_name": "John", "last_name": "Rambo", "address": { "phone": "1234567890", "street1": "23 Recurly Ave", "city": "Chicago", "region": "IL", "postal_code": "60601", "country": "US" }, "gateway_attributes":{ "account_reference":"adyen-shopper-reference" }, "payment_gateway_references": [ { "token": "gateway-token-here" } ] } } ``` ``` -------------------------------- ### PHP Example for Performance Obligations Source: https://docs.recurly.com/recurly-subscriptions/v2.29/reference/get_performance_obligations A PHP example for fetching performance obligations using cURL. Ensure the cURL extension is enabled in your PHP installation. ```php ``` -------------------------------- ### HTML for New Elements Setup Source: https://docs.recurly.com/recurly-subscriptions/docs/upgrading This HTML snippet shows the div element used for the new Elements setup. ```html
``` -------------------------------- ### Google Play Store Configuration Example Source: https://docs.recurly.com/recurly-subscriptions/v2019-10-10/docs/step-by-step-process Example of inputting service account JSON key, Earnings report URI, and App package name in Recurly App Management. ```text Service account JSON key: { "type": "service_account", "project_id": "your-project-id", "private_key_id": "your-private-key-id", "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----", "client_email": "your-service-account-email@your-project-id.iam.gserviceaccount.com", "client_id": "your-client-id", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/your-service-account-email%40your-project-id.iam.gserviceaccount.com" } Google Earnings Report URI: gs://your-bucket-name/earnings/ App Package Name: com.yourcompany.yourapp ``` -------------------------------- ### PHP Request Example Source: https://docs.recurly.com/recurly-subscriptions/v2.29/reference/lookupaccountsbillinginfowallet Example of how to retrieve an account's billing information using PHP. This snippet demonstrates making a GET request with cURL. ```php ``` -------------------------------- ### Create a Volume Plan (Ruby) Source: https://docs.recurly.com/recurly-subscriptions/v2019-10-10/docs/quantity-based-pricing-guide Demonstrates creating a plan with volume pricing for an add-on using the Recurly client library in Ruby. ```ruby plan_create = { code: "volume-tshirt-plan", name: "Volume T-shirt Plan", currencies: [ { currency: "USD", unit_amount: 100 } ], add_ons: [ { item_code: item.code, display_quantity: true, tier_type: "volume", tiers: [ { currencies: [ { currency: "USD", unit_amount: 20 } ], ending_quantity: 100 }, { currencies: [ { currency: "USD", unit_amount: 15 } ], ending_quantity: 999999999 # maximum value } ] } ] } plan = @client.create_plan(body: plan_create) puts "Created Plan #{plan}" ```