| Line 94... |
Line 94... |
| 94 |
#orderSuccessUrl = "https://paytm.com/shop/orderdetail/1155961075?actions=1&channel=web&version=2"
|
94 |
#orderSuccessUrl = "https://paytm.com/shop/orderdetail/1155961075?actions=1&channel=web&version=2"
|
| 95 |
ordermap = json.loads(rawHtml).get("order")
|
95 |
ordermap = json.loads(rawHtml).get("order")
|
| 96 |
if not ordermap.get("need_shipping"):
|
96 |
if not ordermap.get("need_shipping"):
|
| 97 |
resp['result'] = 'PAYTM_RECHARGE_ORDER'
|
97 |
resp['result'] = 'PAYTM_RECHARGE_ORDER'
|
| 98 |
return resp
|
98 |
return resp
|
| - |
|
99 |
elif ordermap.get("payment_status") == "PROCESSING":
|
| - |
|
100 |
resp['result'] = 'ORDER_PENDING_PAYMENT'
|
| - |
|
101 |
return resp
|
| 99 |
order = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
|
102 |
order = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
|
| 100 |
order.deliveryCharges = ordermap.get("shipping_charges") - ordermap.get("shipping_discount")
|
103 |
order.deliveryCharges = ordermap.get("shipping_charges") - ordermap.get("shipping_discount")
|
| 101 |
order.merchantOrderId = str(ordermap.get("id"))
|
104 |
order.merchantOrderId = str(ordermap.get("id"))
|
| 102 |
order.discountApplied = ordermap.get("discount_amount")
|
105 |
order.discountApplied = ordermap.get("discount_amount")
|
| 103 |
order.paidAmount = ordermap.get("grandtotal")
|
106 |
order.paidAmount = ordermap.get("grandtotal")
|
| Line 121... |
Line 124... |
| 121 |
total_cashback += paytmcashback
|
124 |
total_cashback += paytmcashback
|
| 122 |
break
|
125 |
break
|
| 123 |
amountPaid = item.get("subtotal") - paytmcashback
|
126 |
amountPaid = item.get("subtotal") - paytmcashback
|
| 124 |
detailedStatus = item.get("status_text")
|
127 |
detailedStatus = item.get("status_text")
|
| 125 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
128 |
status = self._getStatusFromDetailedStatus(detailedStatus)
|
| - |
|
129 |
if status == None:
|
| - |
|
130 |
status = MStore.ORDER_PLACED
|
| 126 |
subOrder = SubOrder(item.get("title"), item.get("product").get(""), ordermap.get("date"), amountPaid, status, item.get("quantity"))
|
131 |
subOrder = SubOrder(item.get("title"), item.get("product").get(""), ordermap.get("date"), amountPaid, status, item.get("quantity"))
|
| 127 |
subOrder.imgUrl = product.get("thumbnail")
|
132 |
subOrder.imgUrl = product.get("thumbnail")
|
| - |
|
133 |
subOrder.detailedStatus = detailedStatus
|
| 128 |
subOrder.productUrl = shareUrl
|
134 |
subOrder.productUrl = shareUrl
|
| 129 |
subOrder.productCode = product.get("url").split("?")[0].split("/")[-1]
|
135 |
subOrder.productCode = product.get("url").split("?")[0].split("/")[-1]
|
| 130 |
subOrder.merchantSubOrderId = str(item.get("id"))
|
136 |
subOrder.merchantSubOrderId = str(item.get("id"))
|
| 131 |
if status == MStore.ORDER_PLACED:
|
137 |
if status == MStore.ORDER_PLACED:
|
| 132 |
subOrder.estimatedDeliveryDate = datetime.strftime(getISTDate(item.get("status_flow")[1].get("date")), "%d %b")
|
138 |
subOrder.estimatedDeliveryDate = datetime.strftime(getISTDate(item.get("status_flow")[1].get("date")), "%d %b")
|
| Line 151... |
Line 157... |
| 151 |
|
157 |
|
| 152 |
def _getStatusFromDetailedStatus(self, detailedStatus):
|
158 |
def _getStatusFromDetailedStatus(self, detailedStatus):
|
| 153 |
for key, value in Store.OrderStatusMap.iteritems():
|
159 |
for key, value in Store.OrderStatusMap.iteritems():
|
| 154 |
if detailedStatus.lower() in value:
|
160 |
if detailedStatus.lower() in value:
|
| 155 |
return key
|
161 |
return key
|
| 156 |
print "Detailed Status-", detailedStatus, "need to be mapped for Store-", self.store_id
|
162 |
print "Detailed Status-", detailedStatus, "need to be mapped for Store-", self.store_name
|
| 157 |
return None
|
163 |
return None
|
| 158 |
def getISTDate(tzString):
|
164 |
def getISTDate(tzString):
|
| 159 |
tzDate = datetime.strptime(tzString, "%Y-%m-%dT%H:%M:%S.%fZ")
|
165 |
tzDate = datetime.strptime(tzString, "%Y-%m-%dT%H:%M:%S.%fZ")
|
| 160 |
tzDate = tzDate + timedelta(0,19800)
|
166 |
tzDate = tzDate + timedelta(0,19800)
|
| 161 |
return tzDate
|
167 |
return tzDate
|