Merge pull request #21470 from scmmishra/razorpay-subscription

refactor: minor changes to razorpay subscription
This commit is contained in:
Shivam Mishra 2020-04-30 20:07:44 +05:30 committed by GitHub
commit 9067c7bc55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,11 +62,9 @@ def get_member_based_on_subscription(subscription_id, email):
'subscription_id': subscription_id,
'email_id': email
}, order_by="creation desc")
return frappe.get_doc("Member", members[0]['name'])
@frappe.whitelist()
@frappe.whitelist(allow_guest=True)
def trigger_razorpay_subscription(data):
if isinstance(data, six.string_types):
data = json.loads(data)
@ -88,10 +86,13 @@ def trigger_razorpay_subscription(data):
if data.event == "subscription.activated":
member.customer_id = payment.customer_id
member.subscription_start = datetime.fromtimestamp(subscription.start_at)
member.subscription_end = datetime.fromtimestamp(subscription.end_at)
member.subscription_activated = 1
member.save(ignore_permissions=True)
# Update these values anyway
member.subscription_start = datetime.fromtimestamp(subscription.start_at)
member.subscription_end = datetime.fromtimestamp(subscription.end_at)
member.subscription_activated = 1
member.save(ignore_permissions=True)
elif data.event == "subscription.charged":
membership = frappe.new_doc("Membership")
membership.update({