Esempio n. 1
0
 def get_payment_intent(self, amount, paymentid):
     vertical_data = {
         'firstname': '',
         'lastname': '',
         'is_domestic': True,
         'product_type': 'load_wallet',
         'vertical_message':
         'To load money in your GoCash wallet pay using UPI',
         'payment_link': '',
         'unique_count': 1,
         'bookingid': '',
         'email': self.email,
         'actual_flavour': unicode("whatsapp")
     }
     entities = {
         "paymentid": paymentid,
         "payment_mode": unicode("UPI"),
         "channel": unicode("whatsapp"),
         "vertical": unicode("gocash"),
         "amount": unicode(amount),
         "vertical_data": vertical_data,
         "mobile": self.mobile
     }
     next_intents = Lambda.fetch_actions(self.vertical,
                                         entity=entities,
                                         intent_obj=self.intent_obj,
                                         intent_list=[{
                                             'intent':
                                             'pay.collect.payment',
                                             'subIntent': 'default',
                                             'message': 'Yes'
                                         }])
     return entities
Esempio n. 2
0
    def action(self):
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={"user_email": self.email},
            intent_list=[{
                'intent': "gocash.gocash_summary"
            }, {
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.how_to_earn_more"
            }],
            #{'intent': "gocash.gift_not_received"},],
            intent_obj=self.intent_obj)

        logger.debug("In Gocash Balance Action")
        logger.debug(self.base_resp)

        if not hasattr(self, 'email') or not self.email:
            self.base_resp['data'] = {
                "message": "Required params not provided"
            }
            self.base_resp['success'] = False
            return self.base_resp

        gocash_response = GocashMiddleware.user_balance(self.email)

        try:
            if gocash_response.json().get('success'):
                resp_data = gocash_response.json()['data']
                """
                self.base_resp['message'] = 'Your GoCash balance is as below:' \
                                            '\n\tPromotional GoCash: %s' \
                                            '\n\tNon-Promotional Gocash: %s' \
                                            '\n\tTotal Gocash: %s' % (str(resp_data.get('p_amt', '0')),
                                                                      str(resp_data.get('np_amt', 0) +
                                                                          resp_data.get('b_amt', 0)),
                                                                      str(resp_data.get('t_amt', '0')))
                """
                self.base_resp['data'] = {
                    "creditsBalance": resp_data.get('p_amt', '0'),
                    "goCashPlusBalance": resp_data.get('b_amt', 0),
                    "myCashBalance": resp_data.get('np_amt', 0)
                }
                self.base_resp['template'] = "gocash_balance"
                self.base_resp['action'] = 'endWithResult'
            else:
                raise Exception
        except:
            self.base_resp['data'] = {"message": "User's Wallet Not Found"}
            self.base_resp['success'] = False

        return self.base_resp
Esempio n. 3
0
    def action(self):
        self.base_resp['message'] = "For more information on how to earn more goCash+, " \
                                    "click on the link [link](https://go.ibi.bo/IdDWcZyrDP)"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 4
0
    def action(self):
        self.base_resp[
            'message'] = "You need to log into Goibibo account to view the goCash+ on the booking page."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 5
0
    def action(self):
        self.base_resp['message'] = "The upper limit for earning goCash through promotional activities/refer and earn" \
                                    " is upto INR 10,000"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 6
0
    def action(self):
        self.base_resp[
            'message'] = "You can check goCash+ by signing into Goibibo website under My account or Mobile app."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 7
0
    def action(self):
        self.base_resp['message'] = 'goCash+ doesn\'t have restriction or usage limits, whereas promotional GoCash ' \
                                    '(which is called simply "GoCash") has usage limits.'
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 8
0
    def action(self):
        self.base_resp['message'] = "goCash+ earned from Cancellation has unlimited validity. It does not expire.\n" \
                                    "goCash+ earned from goContacts has validity of only 90 days from the date of issue."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 9
0
    def action(self):
        self.base_resp['message'] = "goCash+ is 100% redeemable on Flight, Hotel and Cab bookings."\
                                    "There are absolutely no usage restrictions"\
                                    "Use your goCash+ while making a booking"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.balance"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 10
0
    def action(self):
        self.base_resp['message'] = "The upper limit for earning goCash+ in case of cancellation has no limit but " \
                                    "goCash+ earned through goContacts has a limit of 500"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 11
0
    def action(self):

        if self.retry_count > 2:
            return {"success": True}

        q_resp, check = self.check_requirements()
        if not check:
            return q_resp

        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'user_email': self.intent_obj.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_summary"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            intent_obj=self.intent_obj)

        if not hasattr(self, 'sender_mobile') or not hasattr(
                self, 'receiver_mobile'):
            self.base_resp['data'] = {
                "message": "Required params not provided"
            }
            self.base_resp['success'] = False
            logger.error("Params not provided")
            return self.base_resp

        gocash_response = GocashMiddleware.gift_details(
            self.sender_mobile, self.receiver_mobile)

        try:

            self.base_resp['success'] = gocash_response.status_code == 200
            if 'Message' in gocash_response.json():

                self.base_resp['message'] = gocash_response.json()['Message']
            else:
                raise Exception

        except:
            self.base_resp['success'] = False
            self.base_resp[
                'message'] = 'Could not process your query due to technical errors'

        return self.base_resp
Esempio n. 12
0
    def action(self):
        self.base_resp['template'] = 'md-text'
        self.base_resp['data']['md-message'] = "Please view the Terms and Conditions for goCash+ by " \
                                               "clicking on this [link](https://www.goibibo.com/gocash/)"

        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.balance"
            }],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 13
0
    def action(self):
        self.base_resp['message'] = "goCash+ is a very safe and encrypted payment instrument on Goibibo. Please keep " \
                                    "your email and password safe so that no one except you can use your goCash+. " \
                                    "In case of any fraudulent activity regarding your goCash+, please contact our " \
                                    "customer support services and we will take necessary actions to safeguard your interest."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 14
0
    def action(self):
        self.base_resp['message'] = 'Gocash can be transfered to another account only through Gift gocash option ' \
                                    'through Mobile App (Android and IOS only)goCash+ and Non Promotional goCash+ ' \
                                    'cannot be transfered to another account'
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }, {
                'intent': "gocash.balance"
            }],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 15
0
    def action(self):
        self.base_resp['message'] = "goCash+ is the travel currency at Goibibo."\
                                    "You can use 100% of your goCash+ without any restrictions."\
                                    "You can earn goCash+ through booking cashbacks, writing reviews,"\
                                    "referring friends and many more ways."\
                                    "goCash+ has a general validity of 3 calendar months"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 16
0
    def action(self):
        self.base_resp['message'] = "You can write to us visiting 24x7 goCare and provide us your email id and mobile " \
                                    "number with your concern. Your goCash+ will be blocked: " \
                                    "https://www.goibibo.com/support/"
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[
                {
                    'intent': "gocash.how_to_redeem"
                },
                {
                    'intent': "gocash.gocash_t&c"
                },
                # {'intent': "gocash.gocash_redemption"}
            ],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 17
0
    def action(self):

        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'user_email': self.user_email},
            intent_list=[
                {
                    'intent': "gocash.gocash_t&c"
                },
                #{'intent': "gocash.gocash_redemption"},
                {
                    'intent': "gocash.how_to_redeem"
                }
            ],
            intent_obj=self.intent_obj)

        if not hasattr(self, 'email') or not self.user_email:
            self.base_resp['data'] = {
                "message": "Required params not provided"
            }
            self.base_resp['success'] = False
            return self.base_resp

        gocash_response = GocashMiddleware.user_summary(self.user_email)

        try:
            if gocash_response.status_code == 200:
                resp_data = gocash_response.json()
                self.base_resp['data'] = resp_data.get('results', '')

            else:
                raise Exception("wallet not found {}".format(
                    gocash_response.json()))
        except Exception as e:
            logger.error(" error in gocash_summary {}".format(str(e)))
            self.base_resp['data'] = {"message": "User's Wallet Not Found"}
            self.base_resp['success'] = False

        return self.base_resp
Esempio n. 18
0
    def action(self):
        self.base_resp['message'] = "goCash is our travel booking currency which can be used to make bookings " \
                                    "with us at any point of time. " \
                                    "There are two types of goCash, namely Promotional goCash, " \
                                    "or goCash & goCashPlus." \
                                    "Promotional goCash can be earned by participating in various " \
                                    "promotional activities of Goibibo such as cash backs, referral and rewards. " \
                                    "Promotional goCash, also called goCash expires after 90 days from the date of issue."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[
                {
                    'intent': "how_to_redeem"
                },
                #{'intent': "gocash.gocash_redemption"},
                {
                    'intent': "gocash.gocash_t&c"
                }
            ],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 19
0
    def action(self):
        self.base_resp['message'] = "When you cancel your booking and choose refund as goCash+ option while cancelling " \
                                    "ticket, you will get goCash+/refund in your goibibo account. " \
                                    "You can also get goCash+ when a contact from your Phonebook transacts " \
                                    "on GoIbibo. You can ask your friend to gift goCash on your number but only " \
                                    "promotional goCash can be transferred. You can get goCash & goCashPlus through " \
                                    "the Referral program.For each invite, you get a certain amount of goCash. " \
                                    "Your friend also earns some amount, the bonus amount depending on the " \
                                    "promotional campaign. Cashbacks, Goibibo vouchers & Review bonuses are other ways " \
                                    "to get goCash. In case of any forgery, Goibibo has all rights to revert goCash " \
                                    "awarded to the user."
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 20
0
    def action(self):
        message = "goCash+ referral program enables you and your friends to earn goCash+. " \
            "Your invitees will need to create a new Goibibo account by clicking the link you send them " \
            "via SMSFor each invite signing up, customers will get the bonus depending on the promotional campaign." \
            "When your friend books with Goibibo, you'll earn goCash+. " \
            "Your available goCash+ automatically appears on the My Account and Booking page. " \
            "If goCash+ isn't automatically added, it means booking does not qualify for the same." \
            "goCash+ expires in 90 days from the date it is issued. " \
            "People you refer will also see their goCash+ automatically appear on their account and booking page. " \
            "In case of any forgery, Goibibo has all rights to revert goCash+ awarded to the user."
        self.base_resp['message'] = message
        self.base_resp['next_intents'] = Lambda.fetch_actions(
            "",
            entity={'email': self.email},
            intent_list=[{
                'intent': "gocash.how_to_redeem"
            }, {
                'intent': "gocash.gocash_t&c"
            }],
            #{'intent': "gocash.gocash_redemption"}],
            intent_obj=self.intent_obj)

        return self.base_resp
Esempio n. 21
0
    def action(self):
        obj = self.intent_obj

        response = {
            'template':
            'text',
            'data': {},
            'next_intents':
            Lambda.fetch_actions("",
                                 entity={'user_email': obj.email},
                                 intent_list=[{
                                     'intent': "gocash.how_to_redeem"
                                 }, {
                                     'intent': "gocash.gocash_summary"
                                 }, {
                                     'intent': "gocash.gocash_t&c"
                                 }],
                                 intent_obj=obj),
            'success':
            True,
            'action':
            'endWithResult'
        }
        booking_id = obj.booking_id if hasattr(obj, "booking_id") else None
        vertical = ''
        if booking_id:
            try:

                if 'HTL' in booking_id.upper():
                    vertical = 'hotels'
                elif 'FL' in booking_id.upper():
                    vertical = 'flights'
                else:
                    response['message'] = "goCash+ information for the provided booking ID could not be found. " \
                                          "Please contact the CRM team."
                    response['success'] = True

                if response['success']:
                    middleware_response = BookingMiddleware.getBookingData(
                        booking_id)
                    if middleware_response[vertical][0][
                            'db_status'] != 'to deliver':
                        response['message'] = "goCash+ information for the provided booking ID could not be found. " \
                                              "Please contact the CRM team."
                        response['success'] = True
                    else:
                        cashback_val = middleware_response[vertical][0][
                            vertical[:-1]].get('gocash_cash_back_value', 0)
                        credit_date_string = middleware_response[vertical][0][
                            vertical[:-1]]['bon']['date']
                        credit_date = datetime.strptime(
                            credit_date_string, "%Y-%m-%d %H:%M:%S")
                        if cashback_val > 0:

                            if middleware_response[vertical][0][
                                    vertical[:-1]].get('gocash_processed'):
                                response['message'] = "goCash+ amount of %d has already been processed for the given booking" \
                                                      % cashback_val

                                response['success'] = True
                            else:
                                if credit_date > datetime.now():
                                    response['message'] = "goCash+ amount of %d will be credited to you for the given " \
                                                          "booking after the completion of your trip." % cashback_val

                                    response['success'] = True
                                else:

                                    try:

                                        url = "http://gocash.goibibo.com/v2/gocash/credit/"
                                        payload = {
                                            "user_email": obj.email,
                                            "type": "promo",
                                            "promotional_amount": cashback_val,
                                            "vertical": "Gocash",
                                            "bucket_amount": 0,
                                            "non_promotional_amount": 0,
                                            "application": "cashback",
                                            "txn_id": obj.booking_id,
                                            "extra_params": {
                                                "client_remarks": "cashback"
                                            }
                                        }
                                        headers = {
                                            'Content-Type': "application/json"
                                        }
                                        cr_response = requests.request(
                                            "POST",
                                            url,
                                            data=payload,
                                            headers=headers)
                                        response['message'] = "The booking ID provided is eligible for a goCash+ cashback " \
                                                            "amount of {} which has been credited now. ".format(cashback_val)

                                    except Exception:

                                        response['message'] = "The booking ID provided is eligible for a goCash+ cashback " \
                                                          "amount of {}. Please contact CRM team to help in credit.".format(cashback_val)

                                    response['success'] = True
                        else:
                            response[
                                'message'] = "The booking ID provided by you is not eligible for cashback."

                            response['success'] = True
            except Exception as e:

                logger.error('gocash - cashback not received' +
                             traceback.format_exc())

                response[
                    'message'] = "goCash+ information corresponding to the booking ID provided by you is not found."

                response['success'] = True

        else:
            try:
                email = obj.email if hasattr(obj, "email") else None
                if not email:
                    raise Exception
                vertical = obj.vertical if hasattr(
                    obj, "vertical") else "flights|hotels"
                #bookings = BookingMiddleware.get_user_booking_history(email=email, Pagination=5, verticals=vertical)
                bookings_list = []
                #query = self.__get_query_showbookings__(
                # paymentid=paymentid, lid=lid, pastbookings=self.pastbookings)
                hints = {
                    "$orderby": {
                        "departure": -1
                    },
                    "$fields": self.__class__.REQUIRED_CARD_FIELDS
                }
                cursor = self.ejdb.find('booking', hints=hints)
                #flights = bookings.get("flights", [])
                #hotels = bookings.get("hotels", [])
                for item in cursor:
                    entity = dict(booking_id=item['pid'],
                                  email=self.intent_obj.email)
                    actions = Lambda.fetch_actions("",
                                                   entity=entity,
                                                   intent_obj=self.intent_obj,
                                                   intent_list=[{
                                                       'intent':
                                                       self.intent_name
                                                   }])
                    card = self.build_booking_card(item)
                    card.update({'actions': actions})
                    bookings_list.append(card)

                # for hotel in hotels:
                #     entity = dict(booking_id=hotel['hotel']['pid'], email=self.intent_obj.email)
                #     actions = Lambda.fetch_actions("", entity=entity, intent_obj=self.intent_obj,
                #                                    intent_list=[{'intent': self.intent_name}])
                #     card = self.build_booking_card(hotel['hotel'])
                #     card.update({'actions': actions})
                #     bookings_list.append(card)

                response[
                    'message'] = "Please select one of your recent bookings to view their cashback information"
                response['data']['items'] = bookings_list
                response['template'] = 'booking_info_list'

            except Exception as e:
                logger.error("EXCEPTION MESSAGE")

                logger.error(e)
                response[
                    'message'] = "Could not find booking information. Please contact CRM."
                response['success'] = True

        return response
Esempio n. 22
0
    def check_requirements(self):
        status = True
        resp = self.base_resp
        try:
            self.sender_mobile = self.form_data['sender_mobile']
            self.receiver_mobile = self.form_data['receiver_mobile']
            if not self.sender_mobile.isdigit() or not self.receiver_mobile.isdigit() or \
                    not len(self.receiver_mobile) == 10 or not len(self.sender_mobile) == 10:
                raise Exception
        except:
            self.retry_count += 1
            status = False
            resp = {
                'action':
                'new_prompt',
                'template':
                'md-text',
                'data': {
                    'form': {
                        "fields": [{
                            'label': 'Sender\'s Mobile',
                            'type': "text",
                            'name': "sender_mobile"
                        }, {
                            'label': 'Receiver\'s Mobile',
                            'type': "text",
                            'name': "receiver_mobile"
                        }],
                        'actionPayload': {
                            'message': 'Check Gift Status',
                            'intent': 'gocash.gift_not_received',
                            'entities': [{
                                'retry_count': self.retry_count
                            }]
                        }
                    },
                    'md-message':
                    "Please provide the mobile number of the gift sender and receiver. "
                    "Both fields are mandatory"
                },
                'next_intents':
                Lambda.fetch_actions(
                    "",
                    entity={'user_email': self.intent_obj.email},
                    intent_list=[{
                        'intent': "gocash.how_to_redeem"
                    }, {
                        'intent': "gocash.gocash_summary"
                    }, {
                        'intent': "gocash.gocash_t&c"
                    }],
                    intent_obj=self.intent_obj),
                'success':
                True,
            }
        # status = True
        # if not self.sender_mobile:
        #     resp['message'] = "Please provide the mobile number of the account which sent the gift:"
        #     resp['golambda_context'] = {
        #         'retry_count': self.retry_count + 1
        #     }
        #     status = False
        # elif not self.receiver_mobile:
        #     resp['message'] = "Please provide the mobile number of the account which was to receive the gift:"
        #     resp['golambda_context'] = {
        #         'retry_count': self.retry_count + 1,
        #         'sender_mobile': self.sender_mobile
        #     }
        #     status = False

        return resp, status