我正在尝试使用Stripe API获取客户订阅的状态。
例如:
print(subscriptionStatusFunctionAPI(subscriptionID))
*"returns subscription status (e.g. active, past_due, canceled, unpaid, etc)"*下面是当前的伪码
import stripe
stripe.api_key = 'rk_test_XXX'
### retrieve and return customer specific Subscription object ###
retrieve_sub = stripe.Subscription.retrieve(
"sub_1M3iv0LwptWcL8DfHusz7LZ1",
)
print(dir(retrieve_sub))“‘OBJECT_NAME”、“ReprJSONEncoder”、“__类__”、'__包含_’、'__ copy_‘、'__深刻拷贝__’、'__ delattr__‘、'__ delitem_、'__ dict_’、'__ dir_‘、'__ doc__’、'__ eq__‘、'__ format_’、'__ ge__‘、'__ getattr_、'__ getattribute__‘、'__ getitem_、'__ gt__’、'__ hash__‘、'__ init_’、'__ init_、'__ iter__‘、'__ le_’、'__ len_‘、'__ lt_’、'__模块__‘、'__ ne_’、'__ new_‘、'__ reduce_’,'__ ___ex_‘,'__反向_’,'__ setattr_,'__ setitem_‘,'__ setstate_’,'__‘,'__ str__','__ subclasshook_’,'__弱repr__','_cls_cancel','_cls_delete',‘_cls_delete__折扣’,‘_cls_repr_“_request”、“_request_and_refresh”、“_request_params”、“_search”、“_static_request”、“_static_request_from”、‘_瞬态_values’、‘_未保存的值’、'api_base‘、'api_key’、‘auto_寻呼_iter’、'cancel‘、'class_url’、‘清除’、‘构造_从’、‘复制’、‘创建’、‘删除’,“删除_折扣”、“从键”、“获取”、“实例_url”、“项”、“键”、“最后一次响应”、“列表”、“修改”、“弹出”、“弹出”、“刷新”、“请求”、“请求流”、“检索”、“保存”、“搜索”、“搜索”、“自动寻呼_iter”、“序列化”、“设置默认值”、“stripe_account”,'stripe_id','stripe_version','to_dict',‘to_dict_递归’,'update','values‘
retrieve_sub<Subscription subscription id=sub_1M3je8LwptWcL8DfJCObejxI at 0x25183cb5c70> JSON: {
"application": null,
"application_fee_percent": null,
"automatic_tax": {
"enabled": false
},
"billing": "charge_automatically",
"billing_cycle_anchor": 1672333500,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"collection_method": "charge_automatically",
"created": 1672333500,
"currency": "usd",
"current_period_end": 1675011900,
"current_period_start": 1672333500,
"customer": "cus_MnKIJmGPujdOVd",
"days_until_due": null,
"default_payment_method": null,
"default_source": null,
"description": null,
"discount": null,
"ended_at": null,
"id": "sub_1M3je8LwptWcL8DfJCObejxI",
"invoice_customer_balance_settings": {
"consume_applied_balance_on_void": true
},
"items": {
"data": [
{
"billing_thresholds": null,
"created": 1672333500,
"id": "si_MnKIat6U3EN0O9",
"metadata": {},
"object": "subscription_item",
"plan": {
"active": true,
"aggregate_usage": null,
"amount": 10000,
"amount_decimal": "10000",
"billing_scheme": "per_unit",
"created": 1668352687,
"currency": "usd",
"id": "price_1M3hwhLwptWcL8DfUOZfUBnH",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "Test Sub",
"nickname": null,
"object": "plan",
"product": "prod_MnIXRF3ji6h4Nq",
"statement_descriptor": null,
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"price": {
"active": true,
"billing_scheme": "per_unit",
"created": 1668352687,
"currency": "usd",
"custom_unit_amount": null,
"id": "price_1M3hwhLwptWcL8DfUOZfUBnH",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
"product": "prod_MnIXRF3ji6h4Nq",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 10000,
"unit_amount_decimal": "10000"
},
"quantity": 1,
"subscription": "sub_1M3je8LwptWcL8DfJCObejxI",
"tax_rates": []
}
],
"has_more": false,
"object": "list",
"total_count": 1,
"url": "/v1/subscription_items?subscription=sub_1M3je8LwptWcL8DfJCObejxI"
},
"latest_invoice": "in_1M3je8LwptWcL8DfNbeYfB6C",
"livemode": false,
"metadata": {},
"next_pending_invoice_item_invoice": null,
"object": "subscription",
"on_behalf_of": null,
"pause_collection": null,
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null,
"save_default_payment_method": "off"
},
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"pending_update": null,
"plan": {
"active": true,
"aggregate_usage": null,
"amount": 10000,
"amount_decimal": "10000",
"billing_scheme": "per_unit",
"created": 1668352687,
"currency": "usd",
"id": "price_1M3hwhLwptWcL8DfUOZfUBnH",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"name": "Test Sub",
"nickname": null,
"object": "plan",
"product": "prod_MnIXRF3ji6h4Nq",
"statement_descriptor": null,
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"schedule": null,
"start": 1672333500,
"start_date": 1672333500,
"status": "active",
"tax_percent": null,
"test_clock": "clock_1M3jckLwptWcL8Dff89Wpff4",
"transfer_data": null,
"trial_end": null,
"trial_start": null
}https://stackoverflow.com/questions/74468494
复制相似问题