def capture_payment(is_sandbox=False, sanbox_response=None):
 controller = frappe.get_doc(u'Razorpay Settings')
 for doc in frappe.get_all(u'Integration Request', filters={u'status': u'Authorized', u'integration_request_service': u'Razorpay'}, fields=[u'name', u'data']):
  try:
   if is_sandbox:
    resp = sanbox_response
   else:
    data = json.loads(doc.data)
    settings = controller.get_settings(data)
    resp = controller.post_request(u'https://api.razorpay.com/v1/payments/{0}/capture'.format(data.get(u'razorpay_payment_id')), auth=(settings.api_key, settings.api_secret), data={u'amount': data.get(u'amount')})
   if (resp.get(u'status') == u'captured'):
    frappe.db.set_value(u'Integration Request', doc.name, u'status', u'Completed')
  except Exception:
   doc = frappe.get_doc(u'Integration Request', doc.name)
   doc.status = u'Failed'
   doc.error = frappe.get_traceback()
   frappe.log_error(doc.error, u'{0} Failed'.format(doc.name))

def capture_payment ( is_sandbox = False , sanbox_response = None ) : controller = frappe . get_doc ( u'Razorpay Settings' ) for doc in frappe . get_all ( u'Integration Request' , filters = { u'status' : u'Authorized' , u'integration_request_service' : u'Razorpay' } , fields = [ u'name' , u'data' ] ) : try : if is_sandbox : resp = sanbox_response else : data = json . loads ( doc . data ) settings = controller . get_settings ( data ) resp = controller . post_request ( u'https://api.razorpay.com/v1/payments/{0}/capture' . format ( data . get ( u'razorpay_payment_id' ) ) , auth = ( settings . api_key , settings . api_secret ) , data = { u'amount' : data . get ( u'amount' ) } ) if ( resp . get ( u'status' ) == u'captured' ) : frappe . db . set_value ( u'Integration Request' , doc . name , u'status' , u'Completed' ) except Exception : doc = frappe . get_doc ( u'Integration Request' , doc . name ) doc . status = u'Failed' doc . error = frappe . get_traceback ( ) frappe . log_error ( doc . error , u'{0} Failed' . format ( doc . name ) )
verifies the purchase as complete by the merchant .