⚡ Solution Summary

  • PaymentRecord is a beta feature in the SDK.
  • Use raw_request for immediate functionality.
  • Consider upgrading to beta SDK version v11.6.0b1 for PaymentRecord support.
  • Contact Stripe support for further assistance.
### Describe the bug Stripe python SDK don't have `PaymentRecord`, as specified in documentation https://docs.stripe.com/api/payment-record/report-payment/report?lang=python ### To Reproduce Line ```python3 payment = stripe.PaymentRecord.report_payment( # whatever yall got ) ``` AttributeError: module 'stripe' has no attribute 'PaymentRecord' ### Expected behavior I expect method from docs to work, so I don't need to write crapy handmade functions :') ### Code snippets ```Python ``` ### OS any ### Language version Python 3.11.2 ### Library version stripe==11.5.0 ### API version 2025-01-27.acacia ### Additional context _No response_

Discussion & Fixes

Wawilow 2025-02-16
The guide article which I've used: https://docs.stripe.com/billing/subscriptions/bring-your-own-processor?integration-instructions=subscription-setup#record-payment For everybody who may be interested, there is my solution, I've wrote custom functions, there they are: I'm using custom stripe api version: `2025-01-27.acacia;payment_records_beta=v1;invoice_partial_payments_beta=v3` ``` def report_payment( stripe_customer_id: str, payment_method_id: str, amount_requested_value: int, amount_requested_currency: str = "usd", payment_reference: str = "", description: str = "", ) -> tuple[int, dict]: """ Handmade function for stripe api https://docs.stripe.com/api/payment-record/report-payment/report?lang=curl :param stripe_customer_id: :param payment_method_id: aka `df_pm` :param amount_requested_value: amount of pennies/cents/idk :param amount_requested_currency: usd or idk :param payment_reference: :param description: :return: """ url = "https://api.stripe.com/v1/payment_records/report_payment" auth = (STRIPE_SECRET_KEY, "") headers = { "Stripe-Version": StripeVersion, } now = int(datetime.datetime.now().timestamp()) data = { "amount_requested[currency]": amount_requested_currency, "amount_requested[value]": amount_requested_value, "payment_method_details[payment_method]": payment_method_id, "customer_details[customer]": stripe_customer_id, "customer_presence": "off_session", # "payment_reference": payment_reference, "outcome": 'guaranteed', "guaranteed[guaranteed_at]": now, # "description": description, "initiated_at": now, } if payment_reference != "": data["payment_reference"] = payment_reference if description != "": data["description"] = description response = requests.post( url, auth=auth, data=data, headers=headers, ) Logger.info(f"STRIPE API report_payment: {response.url} - {response.status_code} - {response.text}") r_data = {} try: r_data = response.json() except Exception as e: Logger.critical(f"STRIPE API report_payment error: {e}") return response.status_code, r_data ``` And also `attach_payment` function ``` def attach_payment( invoice_id: str, payment_record: str, ) -> tuple[int, dict]: """ Handmade function for stripe api https://docs.stripe.com/api/invoices/attach_payment?lang=curl :param invoice_id: aka `df_pm` :param payment_record: amount of pennies/cents/idk :return: """ url = f"https://api.stripe.com/v1/invoices/{invoice_id}/attach_payment" auth = (STRIPE_SECRET_KEY, "") headers = { "Stripe-Version": StripeVersion, } data = { "payment_record": payment_record, } response = requests.post( url, auth=auth, data=data, headers=headers, ) Logger.info(f"STRIPE API attach_payment: {response.url} - {response.status_code} - {response.text}") r_data = {} try: r_data = response.json() except Exception as e: Logger.critical(f"STRIPE API attach_payment error: {e}") return response.status_code, r_data ```
Wawilow 2025-02-16
This issue is still actual, I don't like my solution and I want to stick with SDK, so I'm looking forward to add this beta functions to the official SDK
seanzhang-stripe 2025-02-17
Hi @Wawilow Since it's a beta feature, I'd recommend you reach out to Stripe [support](https://support.stripe.com/) for assistance.
helenye-stripe 2025-02-18
Hi @Wawilow , I would also recommend that you use the `raw_request` feature available in Python as of v11.0.0. More information is available in our [README](https://github.com/stripe/stripe-python/tree/master?tab=readme-ov-file#custom-requests). Usage would look something like this: ```python client = StripeClient("sk_test_...") response = client.raw_request( "post", "v1/payment_records/report_payment", param=data, stripe_version="2025-01-27.acacia; feature_beta=v3" ) deserialized_resp = client.deserialize(response, api_mode='V1') ```
helenye-stripe 2025-02-18
Ah I also just realized this is present in our beta SDKs, see [here](https://github.com/stripe/stripe-python/blob/beta/stripe/_payment_record.py#L704). You should be able to use the snippets if you use a beta version of the SDK (like [v11.6.0b1](https://github.com/stripe/stripe-python/releases/tag/v11.6.0b1))
Wawilow 2025-02-18
> Hi [@Wawilow](https://github.com/Wawilow) Since it's a beta feature, I'd recommend you reach out to Stripe [support](https://support.stripe.com/) for assistance. Already! >_<
Wawilow 2025-02-18
> Ah I also just realized this is present in our beta SDKs, see [here](https://github.com/stripe/stripe-python/blob/beta/stripe/_payment_record.py#L704). You should be able to use the snippets if you use a beta version of the SDK (like [v11.6.0b1](https://github.com/stripe/stripe-python/releases/tag/v11.6.0b1)) Oh, thank you very much! Сouldn't find the beta sdk first

Get updates

We publish verified fixes weekly. No spam.

Subscribe