Пример #1
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/')