Exemplo n.º 1
0
 def post(self):
     test_settings = BillingSettings.get_settings(mode=MODE_DEVELOPMENT)
     test_settings.account_id = self.request.get('test_account_id')
     test_settings.secret_key = self.request.get('test_secret_key')
     production_settings = BillingSettings.get_settings(mode=MODE_PRODUCTION)	        
     production_settings.account_id = self.request.get('production_account_id')
     production_settings.secret_key = self.request.get('production_secret_key')
     db.put([test_settings, production_settings])
     response = render_template('settings.html', settings_saved=True, logout_url=users.create_logout_url('/settings/billing/'), test_settings=test_settings, production_settings=production_settings)            
     self.response.out.write(response)
Exemplo n.º 2
0
 def get(self):
     mode = self.session['ebs_mode']
     settings = BillingSettings.get_settings(mode=mode)
     rendered_response_text = render_template('index.html',
         account_id=settings.account_id,
         ebs_mode=mode,
         default_ebs_secret_key=configuration.DEFAULT_EBS_SECRET_KEY,
         amount=Decimal(str(random.randint(1000, 40000)) + '.' + str(random.randint(10, 100))),
         billing_return_url=configuration.BILLING_RETURN_URL,
         countries=COUNTRIES_TUPLE_MAP,
         description=random.choice(TRANSACTION_DESCRIPTIONS),
         ebs_secure_url=configuration.EBS_SECURE_URL,
         ebs_support_email=configuration.EBS_SUPPORT_EMAIL,
         ebs_support_url=configuration.EBS_SUPPORT_URL,
         reference_number=random.randint(400000, 600000),
         modes=MODES,
         full_name=random.choice(FULL_NAMES),
         city=random.choice(CITIES),
         country_code=random.choice(COUNTRIES_TUPLE_MAP)[0],
         email=random.choice(EMAILS),
         phone_number=random.randint(9800000000, 9899999999),
         postal_address=random.choice(POSTAL_ADDRESSES),
         postal_code=random.randint(400000, 500000),
         state_province=random.choice(STATES),
         ship_full_name=random.choice(FULL_NAMES),
         ship_city=random.choice(CITIES),
         ship_country_code=random.choice(COUNTRIES_TUPLE_MAP)[0],
         ship_email=random.choice(EMAILS),
         ship_phone_number=random.randint(9800000000, 9899999999),
         ship_postal_address=random.choice(POSTAL_ADDRESSES),
         ship_postal_code=random.randint(400000, 500000),
         ship_state_province=random.choice(STATES),
         )
     self.response.out.write(rendered_response_text)
Exemplo n.º 3
0
 def post(self):
     from django.utils import simplejson as json
     mode = self.request.get('mode')
     self.session['ebs_mode'] = mode
     settings = BillingSettings.get_settings(mode=mode)
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(dict(mode=mode, account_id=settings.account_id)))
Exemplo n.º 4
0
    def get(self):
        from pickle import dumps
        from ebs.merchant.api import get_ebs_request_parameters

        dr = self.request.get('DR')
        if dr:
            billing_settings = BillingSettings.get_settings(deployment_mode=ebs_mode)
            request = get_ebs_request_parameters(dr, billing_settings.secret_key)

            response_code = request.get('ResponseCode', None)
            response_message = request.get('ResponseMessage', 'There was no response from the billing system.')

            group = self.session.get('participant_group')
            group.transaction_response_id = str(request.get('PaymentID'))
            group.transaction_response_code = str(response_code)
            group.transaction_response_message = response_message
            group.transaction_response_type = TRANSACTION_TYPE_EBS
            group.transaction_response_amount = request.get('Amount', '0')
            group.transaction_response = str(request)
            group.transaction_response_object = db.Blob(dumps(request))
            group.when_transaction_response_occurred = request.get('DateCreated')
            group.put()

            if response_code == 0:
                # mark the participant group as paid.
                message_title = 'Thank you for participating in the summit'
                group_id = group.key().id()
                logging.info('Payments for group: %s with %d processed.' % (group.title, group_id))

                participants = self.session.get('participants')
                if participants:
                    # Send email to all the participants about their attendance.
                    for participant in participants:
                        queue_mail_task(url='/worker/mail/thanks/registration/',
                            params=dict(
                                full_name=participant.full_name,
                                email = participant.email,
                                key=str(participant.key())
                            ),
                            method='POST'
                        )
                    # Send email to the payer the invoice.
                    primary_participant = self.session.get('primary_participant')
                    queue_mail_task(url='/worker/mail/thanks/registration_payment/',
                        params=dict(
                            full_name=primary_participant.full_name,
                            email = primary_participant.email,
                            key=str(primary_participant.key()),
                            transaction_amount=group.transaction_response_amount
                        ),
                        method='POST'
                    )
            else:
                message_title = 'There was an error processing your payment.'
            response = render_template('thank_you.html', message_title=message_title, message_body=response_message + ''' Thank you for registering for the summit. An email confirming your payment and registration shall be sent to you shortly. In case you don't receive the email confirmation within 24 hours or you have any queries, please contact +91 22 66301060 / 22026166 from 10.30 AM IST to 6.30 AM IST''')
        else:
            response = render_template('thank_you.html', message_title="A problem occurred with the billing system.", message_body="We did not receive a proper response from the billing system.")

        self.response.out.write(response)
Exemplo n.º 5
0
 def get(self):
     from ebs.merchant.api import get_ebs_request_parameters
     from models import BillingTransaction
     mode = self.session['ebs_mode']
     settings = BillingSettings.get_settings(mode=mode)
     dr = self.request.get('DR')
     params = get_ebs_request_parameters(dr, settings.secret_key)
     
     transaction = BillingTransaction()
     transaction.response = str(params)
     transaction.put()
     response = render_template('process.html', mode=mode, params=pformat(params, width=40))
     self.response.out.write(response)
Exemplo n.º 6
0
    def post(self):
        from ebs.merchant.api import arc4_encrypt
        return_url = self.request.get('return_url')
        now_string = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')

        amount = self.request.get('amount')
        if not '.' in amount:
            # Make sure the amount contains the fractional part.
            amount = amount + '.00'

        dr = {
            'Amount': Decimal(amount),
            'BillingAddress': self.request.get('address'),
            'BillingCity': self.request.get('city'),
            'BillingCountry': self.request.get('country'),
            'BillingEmail': self.request.get('email'),
            'BillingName': self.request.get('name'),
            'BillingPhone': self.request.get('phone'),
            'BillingPostalCode': self.request.get('postal_code'),
            'BillingState': self.request.get('state'),
            'DateCreated': now_string,
            'DeliveryAddress': self.request.get('ship_postal_address'),
            'DeliveryCity': self.request.get('ship_city'),
            'DeliveryCountry': self.request.get('ship_country'),
            'DeliveryName': self.request.get('ship_name'),
            'DeliveryPhone': self.request.get('ship_phone'),
            'DeliveryPostalCode': self.request.get('ship_postal_code'),
            'DeliveryState': self.request.get('ship_state'),
            'Description': self.request.get('description'),
            'IsFlagged': 'NO',
            'MerchantRefNo': self.request.get('reference_no'),
            'Mode': self.request.get('mode'),
            'PaymentID': random.randint(400000, 600000),
            'ResponseCode': 0,
            'ResponseMessage': 'Transaction Successful',
        }
        
        settings = BillingSettings.get_settings(mode=self.session['ebs_mode'])
        query_string = ebs_urlencode(dr)
        cipher_text = arc4_encrypt(settings.secret_key, query_string)
        encoded_data = b64encode(cipher_text).replace('+', ' ')
        return_url = return_url.replace('{DR}', encoded_data)
        self.redirect(return_url)
Exemplo n.º 7
0
 def get(self):
     test_settings = BillingSettings.get_settings(mode=MODE_DEVELOPMENT)
     production_settings = BillingSettings.get_settings(mode=MODE_PRODUCTION)
     response = render_template('settings.html', settings_saved=False, logout_url=users.create_logout_url('/settings/billing/'), test_settings=test_settings, production_settings=production_settings)
     self.response.out.write(response)
Exemplo n.º 8
0
    def get(self):
        participants = self.session.get('participants', None)
        if participants:
            db.put(participants)
            self.session['participants'] = participants
            total_price = self.session.get('total_price', None)
            tax_amount = self.session.get('tax_amount', None)
            calculated_price = self.session.get('calculated_price', None)
            group = self.session['participant_group']
            #primary_participant = self.session.get('primary_participant')
            primary_participant = Participant.get_primary_participant_for_group(group)
            self.session['primary_participant'] = primary_participant
            participant_count = self.session.get('participant_count')
#           This mail should go in the thank you part after receiving successful payment from payment gateway.
#            for participant in participants:
#                queue_mail_task(url='/worker/mail/thanks/registration/',
#                    params=dict(
#                        full_name=participant.full_name,
#                        email = participant.email,
#                        key=str(participant.key())
#                    ),
#                    method='POST'
#                )
            #primary_participant.put()
            billing_settings = BillingSettings.get_settings(deployment_mode=ebs_mode)

            billing_contact = BillingContact(name=primary_participant.full_name, \
                phone=primary_participant.phone_number, \
                email=primary_participant.email,
                address=primary_participant.address, \
                city=primary_participant.city, \
                postal_code=primary_participant.zip_code, \
                state=primary_participant.state_province, \
                country=primary_participant.country_code)
            shipping_contact = ShippingContact(name=primary_participant.full_name, \
                phone=primary_participant.phone_number, \
                email=primary_participant.email,
                address=primary_participant.address, \
                city=primary_participant.city, \
                postal_code=primary_participant.zip_code, \
                state=primary_participant.state_province, \
                country=primary_participant.country_code)
            billing_information = BillingInformation(account_id=billing_settings.account_id, \
                reference_no=group.key().id(), \
                amount=total_price, \
                mode=ebs_mode, \
                description= str(total_price) + ' for ' + str(participant_count) + ' participant(s) to attend CLO Summit.', \
                return_url=url_join_path(config.ABSOLUTE_ROOT_URL, '/billing/ebs?DR={DR}'))
            d = {}
            d.update(billing_contact.fields())
            d.update(shipping_contact.fields())
            d.update(billing_information.fields())
            form_fields = [(k,v) for (k,v) in d.iteritems()]

            response = render_template('register/payment.html',
                form_fields=form_fields,
                payment_gateway_url=PAYMENT_GATEWAY_URL,
                participants=participants,
                total_price=total_price,
                tax_amount=tax_amount,
                calculated_price=calculated_price)
            self.response.out.write(response)
        else:
            self.redirect('/register/pricing/')