order = Order.objects.filter(reference_order_id = l, state='pending_order').order_by('-timestamp') if order: order = order[0] else: order = Order.objects.filter(reference_order_id = l).order_by('-timestamp') if order: order = order[0] else: print 'not found', l continue continue try: phones = order.user.get_primary_phones() if phones: phone = phones[0] ress = users.get_user_by_mobile(order.user.user.username, 'hemant.fb', cookie_file) if ress['responseCode'] != 'UM_FOUND_USER': print phones print 'not found user',order.user.user.username, order.reference_order_id if phones: ress = users.get_user_by_mobile(phones[0], 'hemant.fb', cookie_file) if ress['responseCode'] != 'UM_FOUND_USER': print 'not found 2ndtry user',order.user.user.username, order.reference_order_id continue else: print 'no login',order.user.user.username, order.reference_order_id continue delivery_info = order.get_delivery_info() shipping_address = delivery_info.address billing_info = BillingInfo.objects.filter(user=order.user)
ROOT_FOLDER = os.path.realpath(os.path.dirname(__file__)) ROOT_FOLDER = ROOT_FOLDER[:ROOT_FOLDER.rindex('/')] if ROOT_FOLDER not in sys.path: sys.path.insert(1, ROOT_FOLDER + '/') # also add the parent folder PARENT_FOLDER = ROOT_FOLDER[:ROOT_FOLDER.rindex('/')+1] if PARENT_FOLDER not in sys.path: sys.path.insert(1, PARENT_FOLDER) from users.models import Profile from integrations.fbapi import users, orders, fbapiutils from accounts.models import * import socket socket.setdefaulttimeout(10*60) if __name__ == '__main__': for i in range(1, 100): class Request: pass req = Request() req.client = ClientDomain.objects.get(domain='www.futurebazaar.com') cookie_file = fbapiutils.init(req) # cookie_file = '/tmp/tmpD3VfgE' u = users.get_user_by_mobile('*****@*****.**', 'hemant.fb', cookie_file,req) profile = u['items'][0]['profileId']
if order: order = order[0] else: order = Order.objects.filter( reference_order_id=l).order_by('-timestamp') if order: order = order[0] else: print 'not found', l continue continue try: phones = order.user.get_primary_phones() if phones: phone = phones[0] ress = users.get_user_by_mobile(order.user.user.username, 'hemant.fb', cookie_file) if ress['responseCode'] != 'UM_FOUND_USER': print phones print 'not found user', order.user.user.username, order.reference_order_id if phones: ress = users.get_user_by_mobile(phones[0], 'hemant.fb', cookie_file) if ress['responseCode'] != 'UM_FOUND_USER': print 'not found 2ndtry user', order.user.user.username, order.reference_order_id continue else: print 'no login', order.user.user.username, order.reference_order_id continue delivery_info = order.get_delivery_info() shipping_address = delivery_info.address
import os, sys os.environ['DJANGO_SETTINGS_MODULE'] = 'tinla.settings' ROOT_FOLDER = os.path.realpath(os.path.dirname(__file__)) ROOT_FOLDER = ROOT_FOLDER[:ROOT_FOLDER.rindex('/')] if ROOT_FOLDER not in sys.path: sys.path.insert(1, ROOT_FOLDER + '/') # also add the parent folder PARENT_FOLDER = ROOT_FOLDER[:ROOT_FOLDER.rindex('/')+1] if PARENT_FOLDER not in sys.path: sys.path.insert(1, PARENT_FOLDER) from users.models import Profile from integrations.fbapi import users, orders, fbapiutils if __name__ == '__main__': cookie_file = fbapiutils.init() print cookie_file # cookie_file = '/tmp/tmpD3VfgE' print users.get_user_by_mobile('*****@*****.**', 'hemant.fb', cookie_file) #order = orders.get_cart('hemant.fb', cookie_file, '9326164025') #print order
from users.models import * from integrations.fbapi import users as apiuser, orders, fbapiutils p = Phone.objects.get(phone='0000000000') emails = p.user.get_primary_emails() print len(emails) print emails cookie_file = fbapiutils.init() count = 0 notfound = [] for e in emails: u = apiuser.get_user_by_mobile(e.email, 'nilesh', cookie_file) if u['responseCode'] == fbapiutils.USER_FOUND: count += 1 print 'user found for %s' % e.email orders_info = orders.get_order_by_user(e.email, 'nilesh', cookie_file, 1) if orders_info['items'][0]['totalNoOfOrdersInProfile'] == 1: if not orders_info['items'][1]['items']: notfound.append(e.email) print 'order history for %s: %s' % (e.email, orders_info) else: notfound.append(e.email) print notfound
from integrations.fbapi import users as apiuser, orders, fbapiutils p = Phone.objects.get(phone = '0000000000') emails = p.user.get_primary_emails() print len(emails) print emails cookie_file = fbapiutils.init() count = 0 notfound = [] for e in emails: u = apiuser.get_user_by_mobile(e.email,'nilesh',cookie_file) if u['responseCode'] == fbapiutils.USER_FOUND: count += 1 print 'user found for %s' % e.email orders_info = orders.get_order_by_user(e.email,'nilesh',cookie_file,1) if orders_info['items'][0]['totalNoOfOrdersInProfile'] == 1: if not orders_info['items'][1]['items']: notfound.append(e.email) print 'order history for %s: %s' % (e.email,orders_info) else: notfound.append(e.email) print notfound print 'total user found %s' % count
d.update({keys[i]: data[i].strip()}) """ d['emi_details'] = {} d['order_amount'] = int(d['order_amount']) """ js = simplejson.loads(d['pg_response']) for key in js.keys(): if key in ['cvv', 'exp_year', 'exp_month', 'card_no']: js[key] = int(js[key]) d['pg_response'] = {'cardNo': js['card_no'], 'cardCvv': js['cvv'], 'cardHoldersName': js['name_on_card'], 'cardExpMon': js['exp_month'], 'cardExpYear': js['exp_year'], 'amountReceivedFromPG': d['order_amount'], 'currentPriceList': d['current_price_list'], 'orderAmount': d['order_amount'], 'paymentMode': d['payment_mode']} data_set.append(d) sock.close() from pprint import pprint i = 0 for data in data_set: f_users.get_user_by_mobile('*****@*****.**', 'hemant.fb', cookie_file) f_users.submit_cart(data, 'hemant.fb', cookie_file) i = i+1 print i