ERROR: BillingSetup start_time

69 views
Skip to first unread message

Adam Walters

unread,
Dec 8, 2022, 9:25:20 PM12/8/22
to Google Ads API and AdWords API Forum
I have consolidated billing set up and am linking brand new accounts to those payments_account_id & payments_profile_id

I am using almost exactly the same code that is provided in the examples but receive the below error: Also, when running the code I will always get the error. However, if I go into the GoogleAds UI and click into Billing > Settings and DO NOT setup any billing. After I exist GoogleAds and rerun the code it runs perfectly fine. Below are the error and code used.

I am receiving this ERROR:
errors {
  error_code {
    billing_setup_error: FUTURE_START_TIME_PROHIBITED
  }
  message: "A start time in the future cannot be used because there is currently no active billing setup for this customer."
  location {
    field_path_elements {
      field_name: "operation"
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "start_time"
    }
  }
}
request_id: "v8fEru_pUG1egwSLFDOTZA"
, 'v8fEru_pUG1egwSLFDOTZA')

Below are the methods used:
def setup_billing(self):
billing_setup = self._create_billing_setup()
billing_setup_operation = client.get_type("BillingSetupOperation")
client.copy_from(billing_setup_operation.create, billing_setup)
billing_setup_service = client.get_service("BillingSetupService")
response = billing_setup_service.mutate_billing_setup(
customer_id=self.customer_id, operation=billing_setup_operation
)
self.billing_setup_id = billing_setup.id
logger.info(
f"Added new billing setup with resource name {response.result.resource_name} for cid:{self.customer_id}")


def _create_billing_setup(self):
"""Creates and returns a new billing setup instance.
The new billing setup will have its payment details populated. One of the
payments_account_id or payments_profile_id must be provided.

Returns:
A newly created BillingSetup instance.
"""
billing_setup = self.client.get_type("BillingSetup")

# Sets the appropriate payments account field.
if self.payments_account_id != None:
# If a payments account ID has been provided, set the payments_account
# field to the full resource name of the given payments account ID.
# You can list available payments accounts via the
# PaymentsAccountService's ListPaymentsAccounts method.
billing_setup.payments_account = client.get_service(
"BillingSetupService"
).payments_account_path(self.customer_id, self.payments_account_id)
elif self.payments_profile_id != None:
# Otherwise, create a new payments account by setting the
# payments_account_info field
# See https://support.google.com/google-ads/answer/7268503
# for more information about payments profiles.
billing_setup.payments_account_info.payments_account_name = (
f"Payments Account #{uuid4()}"
)
billing_setup.payments_account_info.payments_profile_id = (
self.payments_profile_id
)
start_date = datetime.now()
billing_setup.start_date_time = start_date.strftime("%Y-%m-%d %H:%M:%S")
return billing_setup

Google Ads API Forum Advisor

unread,
Dec 9, 2022, 2:46:13 AM12/9/22
to ad...@digible.com, adwor...@googlegroups.com

Hi Adam,

Thanks for reaching out to the Google Ads API Forum.

I can see that you’ve received BillingSetupError.FUTURE_START_TIME_PROHIBITED errors. Upon checking the details closely that you’ve shared with us, I found that the API request contains the start date as datetime.now(). Could you confirm this?

 

start_date = datetime.now()

billing_setup.start_date_time = start_date.strftime("%Y-%m-%d %H:%M:%S")

return billing_setup

 

Kindly double check your request if you are not setting the future date as compared to when the API call was made. To avoid this error, you would need to avoid setting a start date in future with respect to API call request time.

Also, as a side note, you may double check the latest billing setup ID in your request that has a valid start date and end date that doesn’t extend beyond its billing setup. Once you confirm it, you may retry your API request. Let us know how it goes further. If the error still persists, you may provide us with the complete logs in the format of the request and response logs along with request-id as seen in their respective links. In addition, we recommend you to enable logging to capture complete details if any error occurs by navigating to the Client libraries > Your client library (ex Python) > Logging documentation, which you can access from this link

Kindly provide the logs to our team via reply privately to the author option.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2h16Va:ref

Adam Walters

unread,
Dec 9, 2022, 12:19:13 PM12/9/22
to Google Ads API Forum Advisor, adwor...@googlegroups.com
Hello,

Confirming the start date is set to datetime.now() and that it is being made at the same time as the API request. I have re-run the code several times and got the same error message. Would you be able to assist me in where to pull those request and response logs from? Below is the full error message. Also, just to re-iterate the oddity I was experiencing where I would receive this error, but if, in the Google Ads UI, I clicked into billing then selected Link to Existing Setup, and then exited WITHOUT setting up billing, the next time I ran the code it would work as expected.

[2022-12-09 12:11:41,703 - WARNING] Request made: ClientCustomerId: 5265225717, Host: googleads.googleapis.com, Method: /google.ads.googleads.v11.services.BillingSetupService/MutateBillingSetup, RequestId: pz-QrJn0RfhHZnWTn3ygag, IsFault: True, FaultMessage: A start time in the future cannot be used because there is currently no active billing setup for this customer.
Traceback (most recent call last):
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/greystar_account_creation/billing_test.py", line 87, in <module>
    billing.setup_billing()
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/greystar_account_creation/billing_test.py", line 41, in setup_billing
    response = billing_setup_service.mutate_billing_setup(
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/google/ads/googleads/v11/services/services/billing_setup_service/client.py", line 495, in mutate_billing_setup
    response = rpc(
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py", line 142, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 66, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 247, in __call__
    response, ignored_call = self._with_call(request,
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 290, in _with_call
    return call.result(), call
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 146, in result
    raise self._exception
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 274, in continuation
    response, call = self._thunk(new_method).with_call(
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 301, in with_call
    return self._with_call(request,
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 290, in _with_call
    return call.result(), call
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 146, in result
    raise self._exception
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 274, in continuation
    response, call = self._thunk(new_method).with_call(
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 301, in with_call
    return self._with_call(request,
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/grpc/_interceptor.py", line 287, in _with_call
    call = self._interceptor.intercept_unary_unary(continuation,
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/google/ads/googleads/interceptors/exception_interceptor.py", line 99, in intercept_unary_unary
    self._handle_grpc_failure(response)
  File "/Users/adamwalters/digible_repos/Paid_Social_Optimizations/venv/lib/python3.9/site-packages/google/ads/googleads/interceptors/exception_interceptor.py", line 71, in _handle_grpc_failure
    raise self._get_error_from_response(response)
google.ads.googleads.errors.GoogleAdsException: (<_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B2607:f8b0:4009:803::200a%5D:443 {created_time:"2022-12-09T12:11:41.579003-05:00", grpc_status:3, grpc_message:"Request contains an invalid argument."}"
>, <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B2607:f8b0:4009:803::200a%5D:443 {created_time:"2022-12-09T12:11:41.579003-05:00", grpc_status:3, grpc_message:"Request contains an invalid argument."}"
>, errors {

  error_code {
    billing_setup_error: FUTURE_START_TIME_PROHIBITED
  }
  message: "A start time in the future cannot be used because there is currently no active billing setup for this customer."
  location {
    field_path_elements {
      field_name: "operation"
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "start_time"
    }
  }
}
request_id: "pz-QrJn0RfhHZnWTn3ygag"
, 'pz-QrJn0RfhHZnWTn3ygag')






Adam Walters

 Director of Paid Media


 AUTHENTICITY | FOCUS | CURIOSITY | HUMILITY | HAPPINESS


Phone: (317) 840-1645

Email:   ad...@digible.com



This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.



Reply all
Reply to author
Forward
Message has been deleted
0 new messages