Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
chore: Update trial mobile mail notification

See merge request locker/api-core!438
  • Loading branch information
khaitranquang committed May 8, 2024
2 parents 1b750ee + 75a5981 commit b877d4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions locker_server/core/services/mobile_payment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def upgrade_plan(self, user_id: int, plan_alias: str, duration: str = DURATION_
send_trial_mail = True
# Update payment -> trial
new_payment = self.payment_repository.update_payment(
payment=new_payment, update_data={"total_price": 0, "discount": 0}
payment=new_payment, update_data={"discount": new_payment.total_price, "total_price": 0}
)

# Send mail
Expand All @@ -106,7 +106,9 @@ def upgrade_plan(self, user_id: int, plan_alias: str, duration: str = DURATION_
)

BackgroundFactory.get_background(bg_name=BG_NOTIFY, background=False).run(
func_name="pay_successfully", **{"payment": new_payment, "payment_platform": payment_platform}
func_name="pay_successfully", **{
"payment": new_payment, "payment_platform": payment_platform, "is_trial_period": is_trial_period,
}
)
return new_payment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ def trial_enterprise_successfully(self, user_id: int, scope: str = None):
if self.background:
connection.close()

def pay_successfully(self, payment, payment_platform="Stripe"):
def pay_successfully(self, payment, payment_platform="Stripe", is_trial_period=False):
"""
Notify when a payment invoice was paid
:param payment: (obj) Payment invoice
:param payment_platform: (str)
:param is_trial_period: (bool)
:return:
"""
url = API_NOTIFY_PAYMENT + "/notify_payment_success"
Expand Down Expand Up @@ -199,6 +200,7 @@ def pay_successfully(self, payment, payment_platform="Stripe"):
"currency": payment.currency,
"duration": payment.duration,
"plan": payment.plan,
"is_trial_period": is_trial_period,
"customer": payment.get_customer_dict(),
"payment_method": payment.payment_method,
"payment_data": payment_data,
Expand Down

0 comments on commit b877d4b

Please sign in to comment.