npx stripe fixtures doesn't report the country from the billing address · Issue #1447 · stripe/stripe-cli · GitHub
Skip to content

npx stripe fixtures doesn't report the country from the billing address #1447

Open

Description

@erwanvivien

Issue

Using fixture to generate a transaction, the country is always set to United States (US)

Expected Behavior

Use the country provided in the fixture

Steps to reproduce

{
  "_meta": {
    "template_version": 0
  },
  "fixtures": [
    {
      "name": "checkout_session",
      "path": "/v1/checkout/sessions",
      "method": "post",
      "params": {
        "success_url": "https://httpbin.org/post",
        "cancel_url": "https://httpbin.org/post",
        "mode": "payment",
        "metadata": {
          "firstname": "E",
          "lastname": "V",
          "orderSource": "dropList",
          "priceId": "price_1Sc7NTKGlmKra3A1O0zDePPu",
          "productId": "prod_TZFtASXRqKD9Af",
          "referral": "erwan",
          "tag": "liste-deroulante"
        },
        "line_items": [
          {
            "price": "price_1Sc7NTKGlmKra3A1O0zDePPu",
            "quantity": 1
          }
        ],
        "payment_intent_data": {
          "shipping": {
            "name": "UyHSck",
            "address": {
              "line1": "10 rue de Penthièvre",
              "line2": null,
              "postal_code": "75008",
              "city": "Paris",
              "state": null,
              "country": "FR"
            }
          }
        }
      }
    },
    {
      "name": "payment_page",
      "path": "/v1/payment_pages/${checkout_session:id}",
      "method": "get"
    },
    {
      "name": "payment_method",
      "path": "/v1/payment_methods",
      "method": "post",
      "params": {
        "type": "card",
        "card": {
          "token": "tok_visa"
        },
        "metadata": {
          "firstname": "E",
          "lastname": "V",
          "orderSource": "dropList",
          "priceId": "price_1Sc7NTKGlmKra3A1O0zDePPu",
          "productId": "prod_TZFtASXRqKD9Af",
          "referral": "erwan",
          "tag": "liste-deroulante"
        },
        "billing_details": {
          "email": "stripe+UyHSck@example.com",
          "name": "UyHSck",
          "address": {
            "line1": "10 rue de Penthièvre",
            "line2": null,
            "postal_code": "75008",
            "city": "Paris",
            "state": null,
            "country": "FR"
          }
        }
      }
    },
    {
      "name": "payment_page_confirm",
      "path": "/v1/payment_pages/${checkout_session:id}/confirm",
      "method": "post",
      "params": {
        "payment_method": "${payment_method:id}",
        "expected_amount": 2200
      }
    }
  ]
}

I'm getting the following output:

$ npx stripe fixtures temp_fixture_FR.json
Setting up fixture for: checkout_session
Running fixture for: checkout_session
Setting up fixture for: payment_page
Running fixture for: payment_page
Setting up fixture for: payment_method
Running fixture for: payment_method
Setting up fixture for: payment_page_confirm
Running fixture for: payment_page_confirm

And from the Stripe UI:

Image

Activity

  1. ChinmayBhattt commented on Mar 19, 2026

    @ChinmayBhattt

    #attempt

  2. ChinmayBhattt commented on Mar 19, 2026

    @ChinmayBhattt

    Hi everyone! I just raised a PR containing a fix for this issue. Here is a brief explanation of the problem and the approach taken to resolve it:

    The Problem

    When a fixture JSON file contains explicit null values (e.g. "country": null or "state": null under address), the CLI silently drops them instead of sending them over to the Stripe API. Because the null value is never transmitted in the payload, the API uses its own default fallbacks (such as defaulting the country to "US") instead of actively clearing those fields as the user intended.

    The root cause comes from ParseMapForFormData and ParseArrayForFormData in pkg/parsers/parsers.go. When the JSON payload unmarshals null, it becomes a Go nil interface. However, calling reflect.ValueOf(nil).Kind() returns reflect.Invalid, which falls through to the default: continue switch case. This causes the field to be silently ignored and skipped during form data conversion.

    The Fix

    I've added explicit value == nil checks right before the reflection switch in both ParseMapForFormData and ParseArrayForFormData.

    Now, when a nil object is detected, the CLI correctly emits the keyname with an empty string (e.g. shipping[address][country]=), which behaves correctly by passing an empty value over the network. The API successfully reads this and clears out the data field accordingly.

    I also added a corresponding test case TestParseInterfaceWithNulls in parsers_test.go to ensure null cases always convert properly to an empty string.

    Hope this helps! Let me know if any further tweaks are needed in the PR.

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions