Ver a proveniência

provision to handel paypal and razoapay subscription charge notifications

pull/2/head
Saurabh há 6 anos
ascendente
cometimento
e49643feb5
2 ficheiros alterados com 43 adições e 3 eliminações
  1. +20
    -0
      payments/payment_gateways/doctype/paypal_settings/paypal_settings.py
  2. +23
    -3
      payments/payment_gateways/doctype/razorpay_settings/razorpay_settings.py

+ 20
- 0
payments/payment_gateways/doctype/paypal_settings/paypal_settings.py Ver ficheiro

@@ -363,7 +363,27 @@ def manage_recurring_payment_profile_status(profile_id, action, args, url):
})

response = make_post_request(url, data=args)

if response.get("ACK")[0] != "Success":
frappe.throw(_("Failed while amending subscription"))

@frappe.whitelist(allow_guest=True)
def ipn_handler():
data = frappe.local.form_dict
data.update({
"payment_gateway": "PayPal"
})

doc = frappe.get_doc({
"data": frappe.local.form_dict,
"doctype": "Integration Request",
"status": "Subscription Notification"
}).insert(ignore_permissions=True)
frappe.db.commit()

frappe.enqueue(method='frappe.integrations.doctype.paypal_settings.paypal_settings.handle_subscription_notification',
queue='long', timeout=600, is_async=True, **{"doctype": "Integration Request", "docname": doc.name})

def handle_subscription_notification(doctype, docname):
call_hook_method("handle_subscription_notification", doctype=doctype, docname=docname)

+ 23
- 3
payments/payment_gateways/doctype/razorpay_settings/razorpay_settings.py Ver ficheiro

@@ -119,7 +119,6 @@ class RazorpaySettings(Document):
"content-type": "application/json"
}
)

if not resp.get('id'):
frappe.log_error(str(resp), 'Razorpay Failed while creating subscription')
except:
@@ -329,5 +328,26 @@ def capture_payment(is_sandbox=False, sanbox_response=None):
def convert_rupee_to_paisa(**kwargs):
for addon in kwargs.get('addons'):
addon['item']['amount'] *= 100
frappe.conf.converted_rupee_to_paisa = True

frappe.conf.converted_rupee_to_paisa = True


@frappe.whitelist(allow_guest=True)
def razorpay_subscription_callback():
data = frappe.local.form_dict
data.update({
"payment_gateway": "Razorpay"
})

doc = frappe.get_doc({
"data": json.dumps(frappe.local.form_dict),
"doctype": "Integration Request",
"status": "Subscription Notification"
}).insert(ignore_permissions=True)
frappe.db.commit()

frappe.enqueue(method='frappe.integrations.doctype.razorpay_settings.razorpay_settings.handle_subscription_notification',
queue='long', timeout=600, is_async=True, **{"doctype": "Integration Request", "docname": doc.name})

def handle_subscription_notification(doctype, docname):
call_hook_method("handle_subscription_notification", doctype=doctype, docname=docname)

Carregando…
Cancelar
Guardar