### Create Customer with Bank Account - Python Source: https://apidocs.chargebee.com/docs/api/customers/create-a-customer This Python example illustrates creating a customer and providing their bank account information for direct debit. Ensure the 'chargebee' library is installed. ```python import chargebee from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Customer.create( cb_client.Customer.CreateParams( first_name="John", last_name="Doe", allow_direct_debit=True, email="john@test.com", bank_account=cb_client.Customer.CreateBankAccountParams( account_number="000222222227", routing_number="110000000", bank_name="US Bank", account_holder_type=chargebee.AccountHolderType.INDIVIDUAL, account_type=chargebee.AccountType.SAVINGS, first_name="Shay", last_name="Liam", gateway_account_id="gw___test__KyVnGlSBWl8M41ju" ) ) ) customer = response.customer card = response.card ``` -------------------------------- ### Create Subscription with Items in Python Source: https://apidocs.chargebee.com/docs/api/subscriptions/create-subscription-for-items This Python example illustrates creating a subscription with multiple items. Ensure the Chargebee Python client is installed and initialized with your site and API key. ```python from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Subscription.create_with_items("__test__8asz8Ru9WhHOJO", cb_client.Subscription.CreateWithItemsParams( subscription_items=[ cb_client.Subscription.CreateWithItemsSubscriptionItemParams( item_price_id="basic-USD", billing_cycles=2, quantity=1 ), cb_client.Subscription.CreateWithItemsSubscriptionItemParams( item_price_id="day-pass-USD", unit_price=100 ) ] ) ) subscription = response.subscription customer = response.customer card = response.card invoice = response.invoice unbilled_charges = response.unbilled_charges ``` -------------------------------- ### Create Item Coupon - Python Source: https://apidocs.chargebee.com/docs/api/coupons/create-a-coupon-for-items This Python example shows how to create an item coupon. Ensure the chargebee library is installed and the client is initialized with your site and API key. ```python import chargebee from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Coupon.create_for_items( cb_client.Coupon.CreateForItemsParams( coupon_constraints=[ cb_client.Coupon.CreateForItemsCouponConstraintParams( entity_type=chargebee.Coupon.CouponConstraintEntityType.CUSTOMER, type=chargebee.Coupon.CouponConstraintType.NEW_CUSTOMER, value="based_on_invoice" ) ], id="welcome_offer", name="Welcome Offer", discount_percentage=15, discount_type=chargebee.Coupon.DiscountType.PERCENTAGE, duration_type="one-time", apply_on=chargebee.Coupon.ApplyOn.INVOICE_AMOUNT ) ) coupon = response.coupon ``` -------------------------------- ### Create Customer with Bank Account - Node.js Source: https://apidocs.chargebee.com/docs/api/customers/create-a-customer This Node.js example demonstrates how to create a customer and include their bank account information for direct debit. Ensure the 'chargebee' package is installed. ```node.js import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.customer.create({ first_name: "John", last_name: "Doe", allow_direct_debit: true, email: "john@test.com", bank_account: { account_number: "000222222227", routing_number: 110000000, bank_name: "US Bank", account_holder_type: "individual", account_type: "savings", first_name: "Shay", last_name: "Liam", gateway_account_id: "gw___test__KyVnGlSBWl8M41ju" } }); console.log(result); const customer = result.customer; const card = result.card; } catch (err) { console.log(err); } ``` -------------------------------- ### Install Chargebee Node.js SDK with deno Source: https://apidocs.chargebee.com/docs/sdks/nodejs Use deno to install the Chargebee Node.js SDK. ```bash deno add npm:chargebee ``` -------------------------------- ### Install Chargebee Node.js SDK with bun Source: https://apidocs.chargebee.com/docs/sdks/nodejs Use bun to install the Chargebee Node.js SDK. ```bash bun add chargebee ``` -------------------------------- ### Create Invoice with Items and Charges (Python) Source: https://apidocs.chargebee.com/docs/api/invoices/create-invoice-for-items-and-one-time-charges This Python example demonstrates creating an invoice with item prices and shipping details using the Chargebee Python client. It requires the `chargebee` library to be installed. ```python from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Invoice.create_for_charge_items_and_charges( cb_client.Invoice.CreateForChargeItemsAndChargesParams( item_prices=[ cb_client.Invoice.CreateForChargeItemsAndChargesItemPriceParams( item_price_id="ssl-charge-USD", unit_price=2000 ) ], customer_id="__test__KyVkkWS1xLskm8", shipping_address=cb_client.Invoice.CreateForChargeItemsAndChargesShippingAddressParams( first_name="John", last_name="Mathew", city="Walnut", state="California", zip="91789", country="US" ) ) ) invoice = response.invoice ``` -------------------------------- ### Create Subscription for Items using Go (v3) Source: https://apidocs.chargebee.com/docs/api/subscriptions/create-subscription-for-items This Go example demonstrates creating a subscription with items using the Chargebee Go SDK v3. It shows how to configure the API client and structure the request with subscription items, including item price IDs, billing cycles, quantities, and unit prices. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v3" subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription" "github.com/chargebee/chargebee-go/v3/models/subscription" ) func main() { chargebee.Configure("{site_api_key}","{site}"); res,err := subscriptionAction.CreateWithItems("__test__8asz8Ru9WhHOJO", &subscription.CreateWithItemsRequestParams{ SubscriptionItems : []*subscription.CreateWithItemsSubscriptionItemParams{ { ItemPriceId : "basic-USD", BillingCycles : chargebee.Int32(2), Quantity : chargebee.Int32(1), }, { ItemPriceId : "day-pass-USD", UnitPrice : chargebee.Int64(100), }, }, }).Request() if err != nil { fmt.Println(err) } else { Subscription := res.Subscription Customer := res.Customer Card := res.Card Invoice := res.Invoice UnbilledCharges := res.UnbilledCharges } } ``` -------------------------------- ### Get Customer Subordinates using Chargebee Java SDK (v4) Source: https://apidocs.chargebee.com/docs/api/customers/get-hierarchy This example demonstrates fetching customer hierarchy subordinates using the v4 Chargebee Java SDK. It utilizes a builder pattern for client configuration and parameter setup. ```java import com.chargebee.v4.client.ChargebeeClient; import com.chargebee.v4.models.customer.params.CustomerHierarchyParams; import com.chargebee.v4.models.customer.responses.CustomerHierarchyResponse; import com.chargebee.v4.models.hierarchy.Hierarchy; import java.util.List; public class CustomerHierarchy { public static void main(String[] args) { ChargebeeClient client = ChargebeeClient.builder() .apiKey("{site_api_key}") .siteName("{site}") .build(); CustomerHierarchyParams params = CustomerHierarchyParams.builder() .hierarchyOperationType(CustomerHierarchyParams.HierarchyOperationType.SUBORDINATES) .build(); CustomerHierarchyResponse response = client .customers() .hierarchy("foo", params); List hierarchies = response.getHierarchies(); } } ``` -------------------------------- ### Subscription Started Event Source: https://apidocs.chargebee.com/docs/api/events/webhook/subscription_started This event is triggered when a 'future' subscription gets started. It provides details about the subscription, customer, and invoice associated with the event. ```APIDOC ## subscription_started ### Description Triggered when a 'future' subscription gets started. ### Event Schema - **id** (string) - Unique identifier for the event - **occurred_at** (integer) - Timestamp when the event occurred - **source** (string) - Source that triggered the event (e.g., admin_console, api, scheduled_job) - **object** (string) - Always "event" for webhook events - **api_version** (string) - API version used for this event - **event_type** (string) - Type of the webhook event - **webhook_status** (string) - Status of the webhook delivery - **content** (object) - Content of the event - **subscription** (object) - The subscription object affected by this event - **customer** (object) - The customer object affected by this event - **invoice** (object) - The invoice object affected by this event ### Sample Payload ```json { "id": "ev_subscriptitca3zc", "occurred_at": 1782382097, "source": "admin_console", "object": "event", "api_version": "v2", "event_type": "subscription_started", "webhook_status": "not_applicable", "content": { "subscription": { "activated_at": 1612890920, "billing_period": 1, "billing_period_unit": "month", "created_at": 1612890920, "currency_code": "USD", "...": "..." }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "billing_address": { "city": "Walnut", "country": "US", "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "...": "..." }, "card_status": "no_card", "created_at": 1517505731, "...": "..." }, "invoice": { "adjustment_credit_notes": {}, "amount_adjusted": 0, "amount_due": 0, "amount_paid": 1000, "amount_to_collect": 0, "...": "..." } } } ``` ``` -------------------------------- ### List Customers using Chargebee Go SDK (v4) Source: https://apidocs.chargebee.com/docs/api/customers/list-customers This example shows how to list customers with filters using the v4 Chargebee Go SDK. It requires initializing the client with your site and API key. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.CustomerListRequest{ FirstName : &chargebee.StringFilter{ Is : "John", }, LastName : &chargebee.StringFilter{ Is : "Doe", }, Email : &chargebee.StringFilter{ Is : "john@test.com", }, } res, err := client.Customer.List(req) if err != nil { fmt.Println(err) } else { for idx := 0; idx < len(res.List); idx++ { Customer := res.List[idx].Customer Card := res.List[idx].Card } } } ``` -------------------------------- ### transaction_updated Event Source: https://apidocs.chargebee.com/docs/api/events/webhook/transaction_updated This event is triggered when a transaction is updated. Examples include when a transaction is removed, when an excess payment is applied on an invoice, or when the amount_capturable gets updated. ```APIDOC ## transaction_updated Event ### Description Triggered when a transaction is updated. E.g. (1) When a transaction is removed, (2) or when an excess payment is applied on an invoice, (3) or when amount_capturable gets updated. ### Event Schema - **id** (string): Unique identifier for the event. - **occurred_at** (integer): Timestamp when the event occurred (unix timestamp). - **source** (string): Source that triggered the event (e.g., admin_console, api, scheduled_job). - **object** (string): Always "event" for webhook events. - **api_version** (string): API version used for this event. - **event_type** (string): Type of the webhook event. - **webhook_status** (string): Status of the webhook delivery. - **content** (object): Content of the event. - **transaction** (object): The transaction object affected by this event. ### Sample Payload ```json { "id": "ev_transactiotca1qr", "occurred_at": 1782382094, "source": "admin_console", "object": "event", "api_version": "v2", "event_type": "transaction_updated", "webhook_status": "not_applicable", "content": { "transaction": { "amount": 1395, "amount_unused": 0, "currency_code": "USD", "customer_id": "__test__KyVnHhSBWlv242pN", "date": 1517505921, "...": "..." } } } ``` ``` -------------------------------- ### Create Subscription for Items using Go (v4) Source: https://apidocs.chargebee.com/docs/api/subscriptions/create-subscription-for-items This Go example uses Chargebee Go SDK v4 to create a subscription with items. It initializes the client with configuration and then constructs the request object, specifying subscription items with their respective details. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.SubscriptionCreateWithItemsRequest{ SubscriptionItems : []*chargebee.SubscriptionCreateWithItemsSubscriptionItem{ { ItemPriceId : "basic-USD", BillingCycles : chargebee.Int32(2), Quantity : chargebee.Int32(1), }, { ItemPriceId : "day-pass-USD", UnitPrice : chargebee.Int64(100), }, }, } res, err := client.Subscription.CreateWithItems("__test__8asz8Ru9WhHOJO", req) if err != nil { fmt.Println(err) } else { Subscription := res.Subscription Customer := res.Customer Card := res.Card Invoice := res.Invoice UnbilledCharges := res.UnbilledCharges } } ``` -------------------------------- ### Merge Customers using PHP Source: https://apidocs.chargebee.com/docs/api/customers/merge-customers Merge customer records using the Chargebee PHP client. This example assumes you have installed the SDK via Composer. ```php "{site}", "apiKey" => "{site_api_key}", ]); $result = $chargebee->customer()->merge([ "from_customer_id" => "__test__KyVnHhSBWlCbP2cp", "to_customer_id" => "__test__KyVnHhSBWlCdz2cv" ]); $customer = $result->customer; ``` -------------------------------- ### Create Item Coupon in Node.js Source: https://apidocs.chargebee.com/docs/api/coupons/create-a-coupon-for-items This Node.js example demonstrates how to create a coupon for specific items. Ensure the Chargebee Node.js module is installed and your credentials are set. ```javascript import Chargebee from "chargebee"; const chargebee = new Chargebee ({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.coupon.createForItems({ item_constraints: [ { constraint: "all", item_type: "plan" } ], id: "summer_offer", name: "Summer Offer", discount_percentage: 10, discount_type: "percentage", duration_type: "forever", apply_on: "each_specified_item" }); console.log(result); const coupon = result.coupon; } catch (err) { console.log(err); } ``` -------------------------------- ### Create Customer with Payment Source - Go (v3) Source: https://apidocs.chargebee.com/docs/api/customers/create-a-customer This Go snippet (v3 library) shows how to create a customer and associate a payment method using gateway details. Ensure the Chargebee Go SDK is installed and configured. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v3" customerAction "github.com/chargebee/chargebee-go/v3/actions/customer" "github.com/chargebee/chargebee-go/v3/models/customer" enum "github.com/chargebee/chargebee-go/v3/enum" ) func main() { chargebee.Configure("{site_api_key}","{site}"); res,err := customerAction.Create(&customer.CreateRequestParams{ FirstName : "John", LastName : "Doe", PaymentMethod : &customer.CreatePaymentMethodParams{ GatewayAccountId : "gw___test__KyVnGlSBWl8M41ju", Type : enum.TypeCard, ReferenceId : "cus_I58PkwpAskxXlJ", }, }).Request() if err != nil { fmt.Println(err) } else { Customer := res.Customer Card := res.Card } } ``` -------------------------------- ### Update an Attached Item using PHP Source: https://apidocs.chargebee.com/docs/api/attached_items/update-an-attached-item Update an attached item using the Chargebee PHP client. This example assumes you have installed the SDK via Composer. ```php "{site}", "apiKey" => "{site_api_key}", ]); $result = $chargebee->attachedItem()->update("85943f11-6014-4ab5-990d-60c86a9c2893", [ "parent_item_id" => "cb-demo", "type" => "recommended" ]); $attachedItem = $result->attached_item; ``` -------------------------------- ### Update Billing Info in Node.js Source: https://apidocs.chargebee.com/docs/api/customers/update-billing-info-for-a-customer This Node.js example demonstrates how to update a customer's billing address. Make sure the Chargebee Node.js module is installed and configured. ```node import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.customer.updateBillingInfo("__test__KyVnHhSBWlFY32dl", { billing_address: { first_name: "John", last_name: "Doe", line1: "PO Box 9999", city: "Walnut", state: "California", zip: 91789, country: "US" } }); console.log(result); const customer = result.customer; const card = result.card; } catch (err) { console.log(err); } ``` -------------------------------- ### Link Customer in Go (v4) Source: https://apidocs.chargebee.com/docs/api/customers/link-a-customer This Go example utilizes the v4 Chargebee SDK for linking customers. It shows how to initialize the client and make the relationships request. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.CustomerRelationshipsRequest{ ParentId : "__test__KyVnHhSBWlDrp2dC", PaymentOwnerId : "__test__KyVnHhSBWlDrp2dC", InvoiceOwnerId : "__test__KyVnHhSBWlDrp2dC", } res, err := client.Customer.Relationships("__test__KyVnHhSBWlDwm2dJ", req) if err != nil { fmt.Println(err) } else { Customer := res.Customer } } ``` -------------------------------- ### Update Customer Contact - Node.js Source: https://apidocs.chargebee.com/docs/api/customers/update-contacts-for-a-customer This Node.js example demonstrates how to update a customer's contact information. It requires the Chargebee Node.js module to be installed and configured with your credentials. ```javascript import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.customer.updateContact("__test__KyVnHhSBWlFmo2do", { contact: { id: "contact___test__KyVnHhSBWlFnd2dq", first_name: "Jane", last_name: "Doe", email: "jane@test.com", label: "dev", enabled: true, send_billing_email: true, send_account_email: true } }); console.log(result); const customer = result.customer; const card = result.card; } catch (err) { console.log(err); } ``` -------------------------------- ### Create Customer with Payment Source - Go (v4) Source: https://apidocs.chargebee.com/docs/api/customers/create-a-customer This Go snippet (v4 library) demonstrates creating a customer and linking a payment method via gateway details. Ensure the Chargebee Go SDK is installed and configured. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.CustomerCreateRequest{ FirstName : "John", LastName : "Doe", PaymentMethod : &chargebee.CustomerCreatePaymentMethod{ GatewayAccountId : "gw___test__KyVnGlSBWl8M41ju", Type : chargebee.TypeCard, ReferenceId : "cus_I58PkwpAskxXlJ", }, } res, err := client.Customer.Create(req) if err != nil { fmt.Println(err) } else { Customer := res.Customer Card := res.Card } } ``` -------------------------------- ### List Contacts for a Customer using Go (v4 SDK) Source: https://apidocs.chargebee.com/docs/api/customers/list-of-contacts-for-a-customer This example demonstrates fetching customer contacts using the Chargebee Go SDK (v4). Initialize the client with your site and API key. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.CustomerContactsForCustomerRequest{} res, err := client.Customer.ContactsForCustomer("__test__KyVnHhSBWlCK52cl", req) if err != nil { fmt.Println(err) } else { for idx := 0; idx < len(res.List); idx++ { Contact := res.List[idx].Contact } } } ``` -------------------------------- ### Create Item Coupon in Python Source: https://apidocs.chargebee.com/docs/api/coupons/create-a-coupon-for-items This Python example shows how to create a coupon for specific items. Ensure the chargebee-python library is installed and initialized with your site and API key. ```python import chargebee from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Coupon.create_for_items( cb_client.Coupon.CreateForItemsParams( item_constraints=[ cb_client.Coupon.CreateForItemsItemConstraintParams( constraint=chargebee.Coupon.ItemConstraintConstraint.ALL, item_type=chargebee.Coupon.ItemConstraintItemType.PLAN ) ], id="summer_offer", name="Summer Offer", discount_percentage=10, discount_type=chargebee.Coupon.DiscountType.PERCENTAGE, duration_type=chargebee.Coupon.DurationType.FOREVER, apply_on=chargebee.Coupon.ApplyOn.EACH_SPECIFIED_ITEM ) ) coupon = response.coupon ``` -------------------------------- ### List Items in Go (v3) Source: https://apidocs.chargebee.com/docs/api/items/list-items This Go example demonstrates listing items using the v3 Chargebee Go SDK. Configure the client with your site and API key. The `Limit` parameter in `ListRequestParams` filters the results. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v3" itemAction "github.com/chargebee/chargebee-go/v3/actions/item" "github.com/chargebee/chargebee-go/v3/models/item" ) func main() { chargebee.Configure("{site_api_key}","{site}"); res,err := itemAction.List(&item.ListRequestParams{ Limit : chargebee.Int32(2), }).ListRequest() if err != nil { fmt.Println(err) } else { for idx := 0; idx < len(res.List); idx++ { Item := res.List[idx].Item } } } ``` -------------------------------- ### Create Customer using Go SDK (v3) Source: https://apidocs.chargebee.com/docs/api/customers/create-a-customer Example of creating a customer using the Chargebee Go SDK (v3), demonstrating how to pass customer and billing address details. ```APIDOC ## customerAction.Create() ### Description Creates a new customer using the Chargebee Go SDK (v3). ### Method Signature customerAction.Create(params *customer.CreateRequestParams) ### Parameters - **FirstName** (string): The first name of the customer. - **LastName** (string): The last name of the customer. - **Email** (string): The email address of the customer. - **Locale** (string): The locale for the customer. - **BillingAddress** (*customer.CreateBillingAddressParams): An object containing billing address details: - **FirstName** (string): The first name for the billing address. - **LastName** (string): The last name for the billing address. - **Line1** (string): The first line of the billing address. - **City** (string): The city for the billing address. - **State** (string): The state for the billing address. - **Zip** (string): The zip code for the billing address. - **Country** (string): The country for the billing address. ### Request Example ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v3" customerAction "github.com/chargebee/chargebee-go/v3/actions/customer" "github.com/chargebee/chargebee-go/v3/models/customer" ) func main() { chargebee.Configure("{site_api_key}","{site}"); res,err := customerAction.Create(&customer.CreateRequestParams{ FirstName : "John", LastName : "Doe", Email : "john@test.com", Locale : "fr-CA", BillingAddress : &customer.CreateBillingAddressParams{ FirstName : "John", LastName : "Doe", Line1 : "PO Box 9999", City : "Walnut", State : "California", Zip : "91789", Country : "US", }, }).Request() if err != nil { fmt.Println(err) } else { Customer := res.Customer Card := res.Card } } ``` ``` -------------------------------- ### Create Subscription with Items in Node.js Source: https://apidocs.chargebee.com/docs/api/subscriptions/create-subscription-for-items This Node.js example demonstrates how to create a subscription with multiple items. Ensure the Chargebee Node.js module is installed and configured with your site and API key. ```node import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.subscription.createWithItems("__test__8asz8Ru9WhHOJO", { subscription_items: [ { item_price_id: "basic-USD", billing_cycles: 2, quantity: 1 }, { item_price_id: "day-pass-USD", unit_price: 100 } ] }); console.log(result); const subscription = result.subscription; const customer = result.customer; const card = result.card; const invoice = result.invoice; const unbilledCharges = result.unbilled_charges; } catch (err) { console.log(err); } ``` -------------------------------- ### Link Customer in Go (v3) Source: https://apidocs.chargebee.com/docs/api/customers/link-a-customer This Go example uses the v3 Chargebee SDK to link customers. It includes error handling and demonstrates how to access the customer object from the response. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v3" customerAction "github.com/chargebee/chargebee-go/v3/actions/customer" "github.com/chargebee/chargebee-go/v3/models/customer" ) func main() { chargebee.Configure("{site_api_key}","{site}"); res,err := customerAction.Relationships("__test__KyVnHhSBWlDwm2dJ", &customer.RelationshipsRequestParams{ ParentId : "__test__KyVnHhSBWlDrp2dC", PaymentOwnerId : "__test__KyVnHhSBWlDrp2dC", InvoiceOwnerId : "__test__KyVnHhSBWlDrp2dC", }).Request() if err != nil { fmt.Println(err) } else { Customer := res.Customer } } ``` -------------------------------- ### List Items in Go (v4) Source: https://apidocs.chargebee.com/docs/api/items/list-items This Go example uses the v4 Chargebee Go SDK to list items. Initialize the client with your site and API key. The `Limit` field in `ItemListRequest` filters the results. ```go package main import ( "fmt" "github.com/chargebee/chargebee-go/v4" ) func main() { config := &chargebee.ClientConfig{ SiteName: "{site}", ApiKey: "{site_api_key}", } client := chargebee.NewClient(config) req := &chargebee.ItemListRequest{ Limit : chargebee.Int32(2), } res, err := client.Item.List(req) if err != nil { fmt.Println(err) } else { for idx := 0; idx < len(res.List); idx++ { Item := res.List[idx].Item } } } ``` -------------------------------- ### List Path to Root Hierarchy in .NET Source: https://apidocs.chargebee.com/docs/api/customers/list-hierarchy-details This .NET example demonstrates how to fetch the path to the root of a customer's hierarchy. Ensure the Chargebee .NET SDK is installed and configured. ```csharp using ChargeBee.Api; using ChargeBee.Models; using ChargeBee.Models.Enums; ApiConfig.Configure("{site}","{site_api_key}"); ListResult result = Customer.ListHierarchyDetail("east_outlet") .HierarchyOperationType(HierarchyOperationTypeEnum.PathToRoot) .Limit(2) .Request(); foreach (var listItem in result.List){ Hierarchy hierarchy = listItem.Hierarchy; } ``` -------------------------------- ### Install Chargebee Node.js SDK with npm Source: https://apidocs.chargebee.com/docs/sdks/nodejs Use npm to install the Chargebee Node.js SDK. ```bash npm install chargebee ``` -------------------------------- ### Get Customer Subordinates using Python SDK Source: https://apidocs.chargebee.com/docs/api/customers/get-hierarchy Retrieve customer hierarchy subordinates using the Chargebee Python SDK. This example shows how to initialize the client and make the hierarchy request. ```python import chargebee from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.Customer.hierarchy("foo", cb_client.Customer.HierarchyParams( hierarchy_operation_type=chargebee.HierarchyOperationType.SUBORDINATES ) ) hierarchies = response.hierarchies ``` -------------------------------- ### Get Customer Subordinates using Node.js SDK Source: https://apidocs.chargebee.com/docs/api/customers/get-hierarchy Fetch customer hierarchy subordinates using the Chargebee Node.js SDK. This asynchronous example requires proper initialization of the Chargebee client. ```node.js import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.customer.hierarchy("foo", { hierarchy_operation_type: "subordinates" }); console.log(result); const hierarchies = result.hierarchies; } catch (err) { console.log(err); } ``` -------------------------------- ### List Customers using Node.js SDK Source: https://apidocs.chargebee.com/docs/api/customers/list-customers This Node.js example shows how to list customers by applying filters for first name, last name, and email. It uses the 'chargebee' npm package and async/await. ```node import Chargebee from "chargebee"; const chargebee = new Chargebee({ site: "{site}", apiKey: "{site_api_key}", }); try { const result = await chargebee.customer.list({ first_name: { is: "John" }, last_name: { is: "Doe" }, email: { is: "john@test.com" } }); result.list.forEach((entry) => { console.log(entry); const customer = entry.customer; const card = entry.card; }); } catch (err) { console.log(err); } ```