[Google Ads API] Adding account billing setup using existing paymentAccountId

83 views
Skip to first unread message

alok

unread,
Jan 10, 2020, 10:40:52 AM1/10/20
to AdWords API and Google Ads API Forum
Hi,

I am trying to add account billing by calling BillingSetupService using an existing paymentAccountId which is in format xxxxxxxxxxxxxxxx. But it throws invalid format as expected format is xxxx-xxxx-xxxx-xxxx (dashes are required as opposed to adwords api).
Trouble is looks like there is a bug in Google ads java client library as it expects payment account resource name with long paymentAccountId

BillingSetup billingSetup = BillingSetup.newBuilder()
                // BUG: Google Ads api accepts only long PaymentsAccountId while
                // creating ResourceNames.paymentsAccount, but requires String
                // in format "xxxx-xxxx-xxxx-xxxx"
                .setPaymentsAccount(StringValue.of(ResourceNames.paymentsAccount(anAccountID, Long.valueOf(aBilling.getPaymentsAccountId()))))

Below is my request and response while adding the billingsetup. Can you please confirm if above steps are correct and this is indeed a bug?? or is there any other way of getting this work?

Request
-------
MethodName: google.ads.googleads.v2.services.BillingSetupService/MutateBillingSetup
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=REDACTED, login-customer-id=aaaaaaa, x-goog-api-client=gl-java/1.8.0_201 gapic/ gax/1.45.0 grpc/1.21.0}
Body: customer_id: "bbbbb"
operation {
  create {
    start_time_type: NOW
    payments_account {
      value: "customers/bbbbb/paymentsAccounts/xxxxxxxxxxxxxxxx"
    }
    end_time_type: FOREVER
  }
}


Response
--------
Headers: Metadata(content-type=application/grpc,request-id=hM4Hr0B0AlzCIMLI1qlSsg,date=Fri, 10 Jan 2020 14:49:07 GMT,alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000)
Body: null
Failure message: errors {
  error_code {
    billing_setup_error: INVALID_PAYMENTS_ACCOUNT
  }
  message: "The requested payments account needs either a correctly formatted id (xxxx-xxxx-xxxx-xxxx), or a non-blank name."
}

Thanks,
Alok

Google Ads API Forum Advisor Prod

unread,
Jan 10, 2020, 5:00:44 PM1/10/20
to aloks...@gmail.com, adwor...@googlegroups.com
Hi Alok,

Thank you for reaching out. Adding the payments_account to BillingSetup requires the payments_account_id from PaymentsAccountInfo. As you can see, this value is a string and must be passed with dashes. Therefore, you need to pass the Id as a string with dashes and the error message is correct.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001USw5MD:ref

alok

unread,
Jan 13, 2020, 5:15:01 AM1/13/20
to AdWords API and Google Ads API Forum
 Hi Mitchell,

As I mentioned above, I am trying to use an EXISTING paymentAccountID which is in xxxx-xxxx-xxxx-xxxx format. According to billingsetup document, I should be setting payments_account and not payment_account_info as payment_account_info is used to signup with new payments accounts.

payments_account (StringValue)

The resource name of the payments account associated with this billing setup. Payments resource names have the form:

customers/{customer_id}/paymentsAccounts/{payments_account_id} When setting up billing, this is used to signup with an existing payments account (and then payments_account_info should not be set). When getting a billing setup, this and payments_account_info will be populated.


payments_account_info (PaymentsAccountInfo)

The payments account information associated with this billing setup. When setting up billing, this is used to signup with a new payments account (and then payments_account should not be set). When getting a billing setup, this and payments_account will be populated.


Approach 1) Now assuming, I have to use payments_account resource name (as I am using existing payments_account), the java client doesn't support
ResourceNames.paymentsAccount(long custonerID,String payment_accountId) but only supports ResourceNames.paymentsAccount(long customerId,long payment_accountId)



BillingSetup billingSetup = BillingSetup.newBuilder()
                // BUG: Google Ads api accepts only long PaymentsAccountId while
                // creating ResourceNames.paymentsAccount, but requires String
                // in format "xxxx-xxxx-xxxx-xxxx"
                .setPaymentsAccount(StringValue.of(ResourceNames.paymentsAccount(anAccountID, Long.valueOf(aBilling.getPaymentsAccountId()))))

Approach 2) lets try the approach of setting payment_accountInfo, it throws error message INVALID_PAYMENTS_ACCOUNT as payments_account_name is mandatory to set, which I don't want to overwrite as I am using existing payment_accountId which already has a predefined name which I might have access to. If I go ahead and set a payments_account_name in below request, the request is successful but It creates a new payment_accountId which obviously I don't want, as whole intention is to use same payment_accountId

Request
-------
MethodName: google.ads.googleads.v2.services.BillingSetupService/MutateBillingSetup
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=REDACTED, login-customer-id=aaaaa, x-goog-api-client=gl-java/1.8.0_201 gapic/ gax/1.45.0 grpc/1.21.0}
Body: customer_id: "bbbbbb"
operation {
  create {
    start_time_type: NOW
    payments_account_info {
      payments_account_id {
        value: "xxxx-xxxx-xxxx-xxxx"
      }
      payments_profile_id {
        value: "yyyy-yyyy-yyyy"
      }
    }
    end_time_type: FOREVER
  }
}


Response
--------
Headers: Metadata(content-type=application/grpc,request-id=H8OHfex_fwh3PV-IQQvyUw,date=Mon, 13 Jan 2020 10:03:59 GMT,alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000)

Body: null
Failure message: errors {
  error_code {
    billing_setup_error: INVALID_PAYMENTS_ACCOUNT
  }
  message: "The requested payments account needs either a correctly formatted id (xxxx-xxxx-xxxx-xxxx), or a non-blank name."
  location {
    field_path_elements {
      field_name: "operation"
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "payments_account_info"
    }
    field_path_elements {
      field_name: "payments_account_name"
    }
  }
}

Any pointers would be nice??

Thanks,

Alok


Google Ads API Forum Advisor Prod

unread,
Jan 13, 2020, 10:20:42 AM1/13/20
to aloks...@gmail.com, adwor...@googlegroups.com
Hi Alok,

I was able to reproduce your error on my end. It appears to be an issue with the client library. Please post an issue on the GitHub page here and let them know that it should be updated so that the resource is expecting the payments account ID without dashes.

In the meantime, if this issue is urgent, you will have to hard-code the dashes into the StringValue before passing it to the PaymentsAccount resource or use the AdWords API instead.
Reply all
Reply to author
Forward
0 new messages