Skip to content

Unable to mutate billing setups #501

@adwinjb

Description

@adwinjb

Hopefully I'm just doing something wrong, but I've tried multiple different ways of mutating billing setups of a customer with no success.
I am able to grab the payment profiles available to the customer with paymentsAccounts.listPaymentsAccounts() but no success in creating a billing setup linked to it.

First, I tried passing billingSetups.create() an object as Visual Studio Code tells me it expects that or an array.
image

await customer.billingSetups.create({
    payments_account: paymentProfile.resource_name,
    status: enums.BillingSetupStatus.PENDING,
    start_date_type: enums.TimeType.NOW
});

This results in error entities.map is not a function, so I tried passing an array of objects instead.

await customer.billingSetups.create([
  {
    payments_account: paymentProfile.resource_name,
    status: enums.BillingSetupStatus.PENDING,
    start_date_type: enums.TimeType.NOW
  }
]);

Ads API now returns the following error: Mutate operations must have 'create', 'update', or 'remove' specified.
Looked through the library code, figured something was up with the abstractions over the API calls since it seems the array of billing setups gets mapped to a structure the API will accept, so I tried the generic mutateResources() method instead.

/** @type {MutateOperation<resources.BillingSetup | resources.IBillingSetup>[]} */
const operations = [
  {
    entity: "billing_setup",
    operation: "create",
    resource: {
      payments_account: paymentProfile.resource_name,
      status: enums.BillingSetupStatus.PENDING,
      start_date_type: enums.TimeType.NOW
    }
  }
];
await customer.mutateResources(operations);

But I still get the same error: Mutate operations must have 'create', 'update', or 'remove' specified.
Looked through the code again and it too seems to be mapping the operations to a different object structure before sending to the API.
Maybe I'm missing something obvious, but comparing to the documentation provided this should be working just fine?

Running in Node.js, v22.5.1, library version 16.0.0, on Windows 11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions