Update default payment method error: you must specify an Electronic Payment Method as the default
Production error log
{
"insertId": "n1jevnf42ff3w",
"jsonPayload": {
"fqdn": "customers.gitlab.com",
"correlation_id": "5bbb50a7f7f8f542225994be866976d0",
"errors": "",
"progname": null,
"tier": "sv",
"update_objects": [
{
"auto_pay": true,
"id": "2c92a0fe705c0568017077dd00e84eae",
"fieldsToNull": [
"DefaultPaymentMethodId"
]
}
],
"entity": "Account",
"shard": "default",
"message": "[IronBank] Failed to update record",
"hostname": "10.185.6.4",
"stage": "main",
"error": "[IronBank] Failed to update record",
"path": null,
"params": null,
"error_message": "Body: [{\"Errors\"=>[{\"Message\"=>\"Because this customer account is designated as Auto-Pay, you must specify an Electronic Payment Method as the default.\", \"Code\"=>\"INVALID_VALUE\"}], \"Success\"=>false}]",
"class": "Zuora::Actions::Update",
"type": "customersdot",
"environment": "gprd"
},
"resource": {
"type": "gce_instance",
"labels": {
"project_id": "gitlab-subscriptions-prod",
"instance_id": "8292704651874933457",
"zone": "us-east1-b"
}
},
"timestamp": "2024-01-12T09:11:56.225Z",
"severity": "ERROR",
"labels": {
"compute.googleapis.com/resource_name": "customers-03-inf-prdsub",
"tag": "rails.production"
},
"logName": "projects/gitlab-subscriptions-prod/logs/rails.production",
"receiveTimestamp": "2024-01-12T09:12:07.060207486Z"
}
Production error log 2
{
"insertId": "n1jevnf42ff3x",
"jsonPayload": {
"environment": "gprd",
"progname": null,
"account_id": "2c92a0fe705c0568017077dd00e84eae",
"tier": "sv",
"stage": "main",
"message": "Default payment could not be updated",
"type": "customersdot",
"payment_method_id": null,
"fqdn": "customers.gitlab.com",
"shard": "default",
"class": "Zuora::Orders::PreSubscriptionCreationService",
"hostname": "10.185.6.4",
"params": null,
"correlation_id": "5bbb50a7f7f8f542225994be866976d0",
"path": null
},
"resource": {
"type": "gce_instance",
"labels": {
"project_id": "gitlab-subscriptions-prod",
"zone": "us-east1-b",
"instance_id": "8292704651874933457"
}
},
"timestamp": "2024-01-12T09:11:56.233Z",
"severity": "WARNING",
"labels": {
"compute.googleapis.com/resource_name": "customers-03-inf-prdsub",
"tag": "rails.production"
},
"logName": "projects/gitlab-subscriptions-prod/logs/rails.production",
"receiveTimestamp": "2024-01-12T09:12:07.060207486Z"
}
Problem
Sometimes, when customer makes a purchase, it does not require a payment. For example, this ZuoraAccount purchased ultimate_sm_edu_1_year
which is 0
cost.
In this case, the params[:payment_method_id]
is nil
. When we try to update the default payment method id, we get the error.
Proposal
Maybe we should skip the set_default_payment_method when payment_method_id is nil
?
Maybe a better way, is to skip set_default_payment_method when process_payments? is false
. This solution allows us to only skip set_default_payment_method in known scenarios, and set_default_payment_method will continue to report ERROR for unexpected scenarios.
Result
Next steps (if any)
How will we measure success?
Edited by Qingyu Zhao