-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] recurring_payments_stripe: Add recurring payments with stripe #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should take a look to the next file:
https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#review
Initial comments:
- README generator missing
- Squash your commits into just one
- Install pre-commit and run it on your module files (here you will need to fix some of the next items in order to run it successfully)
- the commit msg should be: "[ADD] recurring_payments_stripe: Add recurring payments with stripe"
- the PR name: "[16.0][ADD] recurring_payments_stripe: Add recurring payments with stripe"
- No code comented "Unless is documentation"
- All the code should be in English
# def stripe_pay_invoice(self): | ||
# """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" | ||
# for invoice in self: | ||
# subscription = invoice.invoice_date and self.env[ | ||
# "sale.subscription" | ||
# ].search([("code", "=", invoice.invoice_date)], limit=1) | ||
# if ( | ||
# subscription | ||
# and subscription.is_recurrent | ||
# and subscription.stripe_customer | ||
# ): | ||
# provider = self.env["payment.provider"].search( | ||
# [("code", "=", "stripe")], | ||
# ) | ||
# stripe.api_key = provider.stripe_secret_key | ||
# token = self.env["payment.token"].search( | ||
# [("provider_id", "=", provider.id)] | ||
# ) | ||
# try: | ||
# # Crea un PaymentIntent en Stripe para el monto de la factura | ||
# payment_intent = stripe.PaymentIntent.create( | ||
# # Stripe maneja montos en centavos | ||
# amount=int(invoice.amount_total * 100), | ||
# currency=invoice.currency_id.name.lower(), | ||
# customer=token.provider_ref, | ||
# payment_method=token.stripe_payment_method, | ||
# payment_method_types=["card"], | ||
# # Para pagos automáticos sin intervención del usuario | ||
# off_session=True, | ||
# # Confirmar el PaymentIntent inmediatamente | ||
# confirm=True, | ||
# metadata={"odoo_invoice_id": invoice.id}, | ||
# ) | ||
|
||
# # Confirmar el pago y actualizar el estado de la factura en Odoo | ||
# if payment_intent["status"] == "succeeded": | ||
# invoice.action_post() | ||
# invoice.payment_state = "paid" | ||
# else: | ||
# raise Exception( | ||
# f"Error en el pago de Stripe: {payment_intent['status']}" | ||
# ) | ||
|
||
# except stripe.StripeError as e: | ||
# raise UserError(f"Stripe error: {e.user_message or str(e)}") | ||
|
||
# def action_post(self): | ||
# """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" | ||
# res = super(AccountMove, self).action_post() | ||
# for invoice in self: | ||
# subscription = self.env["sale.subscription"].search( | ||
# [("code", "=", invoice.invoice_date)], limit=1 | ||
# ) | ||
# if subscription and subscription.is_recurrent: | ||
# invoice.stripe_pay_invoice() | ||
# return res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
# def stripe_pay_invoice(self): | |
# """Paga la factura en Stripe si `is_recurrent` está activado en la suscripción.""" | |
# for invoice in self: | |
# subscription = invoice.invoice_date and self.env[ | |
# "sale.subscription" | |
# ].search([("code", "=", invoice.invoice_date)], limit=1) | |
# if ( | |
# subscription | |
# and subscription.is_recurrent | |
# and subscription.stripe_customer | |
# ): | |
# provider = self.env["payment.provider"].search( | |
# [("code", "=", "stripe")], | |
# ) | |
# stripe.api_key = provider.stripe_secret_key | |
# token = self.env["payment.token"].search( | |
# [("provider_id", "=", provider.id)] | |
# ) | |
# try: | |
# # Crea un PaymentIntent en Stripe para el monto de la factura | |
# payment_intent = stripe.PaymentIntent.create( | |
# # Stripe maneja montos en centavos | |
# amount=int(invoice.amount_total * 100), | |
# currency=invoice.currency_id.name.lower(), | |
# customer=token.provider_ref, | |
# payment_method=token.stripe_payment_method, | |
# payment_method_types=["card"], | |
# # Para pagos automáticos sin intervención del usuario | |
# off_session=True, | |
# # Confirmar el PaymentIntent inmediatamente | |
# confirm=True, | |
# metadata={"odoo_invoice_id": invoice.id}, | |
# ) | |
# # Confirmar el pago y actualizar el estado de la factura en Odoo | |
# if payment_intent["status"] == "succeeded": | |
# invoice.action_post() | |
# invoice.payment_state = "paid" | |
# else: | |
# raise Exception( | |
# f"Error en el pago de Stripe: {payment_intent['status']}" | |
# ) | |
# except stripe.StripeError as e: | |
# raise UserError(f"Stripe error: {e.user_message or str(e)}") | |
# def action_post(self): | |
# """Sobreescribe el método `action_post` para procesar el pago automático si `is_recurrent` está activo.""" | |
# res = super(AccountMove, self).action_post() | |
# for invoice in self: | |
# subscription = self.env["sale.subscription"].search( | |
# [("code", "=", invoice.invoice_date)], limit=1 | |
# ) | |
# if subscription and subscription.is_recurrent: | |
# invoice.stripe_pay_invoice() | |
# return res |
No description provided.