Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to mutate billing setups #501

Open
adwinjb opened this issue Sep 9, 2024 · 1 comment
Open

Unable to mutate billing setups #501

adwinjb opened this issue Sep 9, 2024 · 1 comment

Comments

@adwinjb
Copy link

adwinjb commented Sep 9, 2024

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.

@adwinjb
Copy link
Author

adwinjb commented Sep 13, 2024

Any chance there will be someone looking into this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant