#alexdietz

1 messages · Page 1 of 1 (latest)

dire solarBOT
weary swan
compact moon
#

Define the parameters for the report run

params = {
"report_type": "payout_reconciliation.by_id.itemized.4",
"parameters": {
"payout": payout_id,

    "columns":["balance_transaction_id",
"created_utc",
"created",
"available_on_utc",
"available_on",
"currency",
"gross",
"fee",
"net",
"reporting_category",
"source_id",
"description",
"customer_facing_amount",
"customer_facing_currency",
"regulatory_tag",
"automatic_payout_id",
"automatic_payout_effective_at_utc",
"automatic_payout_effective_at",
"customer_id",
"customer_email",
"customer_name",
"customer_description",
"shipping_address_line1",
"shipping_address_line2",
"shipping_address_city",
"shipping_address_state",
"shipping_address_postal_code",
"shipping_address_country",
"charge_id",
"payment_intent_id",
"charge_created_utc",
"charge_created",
"invoice_id",
"subscription_id",
"payment_method_type",
"is_link",
"card_brand",
"card_funding",
"card_country",
"statement_descriptor",
"dispute_reason",
"connected_account_id",
"connected_account_name",
"connected_account_country",
"connected_account_direct_charge_id",
"destination_payment_id",
"payment_metadata[basket_id]",
"refund_metadata[basket_id]",
"transfer_metadata[basket_id]"
    ]
},

}

Create the report run

report_run = stripe.reporting.ReportRun.create(**params)

print(report_run)

Continue to poll until the report's status is 'succeeded'

while report_run.status != 'succeeded':
time.sleep(10) # Wait for 10 seconds before checking again
report_run = stripe.reporting.ReportRun.retrieve(report_run.id)

print("Report is ready!")
report_url = report_run.result.url
print(f"Download the report from the following URL: {report_url}")

response = requests.get(report_url,auth=(STRIPE_SECRET,""))