Example #1
0
    def __prepare_cart_items(self):
        variant_ids = self.order.product_variants_ids
        if len(variant_ids) > 1:
            raise PaypalDataError("Ordered more then 1 variant: %r" %
                                  variant_ids)
        variant_id = list(variant_ids)[0]
        cart_items_request_params = {}
        tax = current_app.config['SHOPS'][current_app.config['SHOP_ID']]['tax']
        product = BaseProduct.objects(
            __raw__={
                'product_variants.$id': ObjectId(variant_id)
            }).first()
        goods, delivery = self.order.get_goods_delivery_for_variant(variant_id)

        for idx, item in enumerate(goods):
            item_category = current_app.config['DELIVERY_TO_PAYPAL'][delivery]

            item_descr = _("Row {rowNumber} Seat {seatNumber}").format(
                **item.details)
            description = u'{} [{}]'.format(product.name, item_descr)

            invoice_id = self.gen_invoice_id(self.order.id, item.id)

            cart_items_request_params.update({
                'PAYMENTREQUEST_{}_PAYMENTREQUESTID'.format(idx):
                invoice_id,
                'PAYMENTREQUEST_{}_SELLERPAYPALACCOUNTID'.format(idx):
                self.settings['EMAIL'],
                'PAYMENTREQUEST_{}_AMT'.format(idx):
                item.price,
                'PAYMENTREQUEST_{}_PAYMENTACTION'.format(idx):
                ACTION,
                'PAYMENTREQUEST_{}_CURRENCYCODE'.format(idx):
                CURRENCY,
                'PAYMENTREQUEST_{}_DESC'.format(idx):
                description,
                'PAYMENTREQUEST_{}_INVNUM'.format(idx):
                invoice_id,
                'L_PAYMENTREQUEST_{}_ITEMCATEGORY0'.format(idx):
                item_category,
                'L_PAYMENTREQUEST_{}_TAXAMT0'.format(idx):
                Decimal(tax),
                'L_PAYMENTREQUEST_{}_QTY0'.format(idx):
                1,
                'L_PAYMENTREQUEST_{}_AMT0'.format(idx):
                item.price,
                'L_PAYMENTREQUEST_{}_NAME0'.format(idx):
                product.name,
                'L_PAYMENTREQUEST_{}_DESC0'.format(idx):
                item.details_verbose
            })

        return cart_items_request_params
Example #2
0
 def __prepare_cart_items(self):
     cart_items_request_params = {}
     tax = current_app.config['SHOPS'][current_app.config['SHOP_ID']]['tax']
     for idx, item in enumerate(self.order.goods):
         product = BaseProduct.objects(pk=item.product_id).first()
         cart_items_request_params.update({
             'L_PAYMENTREQUEST_0_ITEMCATEGORY{}'.format(idx): 'Digital',
             'L_PAYMENTREQUEST_0_TAXAMT{}'.format(idx): Decimal(tax),
             'L_PAYMENTREQUEST_0_QTY{}'.format(idx): item.amount,
             'L_PAYMENTREQUEST_0_AMT{}'.format(idx): item.price,
             'L_PAYMENTREQUEST_0_NAME{}'.format(idx): item.details_verbose,
             'L_PAYMENTREQUEST_0_DESC{}'.format(idx): product.name,
         })
     return cart_items_request_params
Example #3
0
 def __prepare_cart_items(self):
     cart_items_request_params = {}
     tax = current_app.config['SHOPS'][current_app.config['SHOP_ID']]['tax']
     for idx, item in enumerate(self.order.goods):
         product = BaseProduct.objects(pk=item.product_id).first()
         cart_items_request_params.update({
             'L_PAYMENTREQUEST_0_ITEMCATEGORY{}'.format(idx):
             'Digital',
             'L_PAYMENTREQUEST_0_TAXAMT{}'.format(idx):
             Decimal(tax),
             'L_PAYMENTREQUEST_0_QTY{}'.format(idx):
             item.amount,
             'L_PAYMENTREQUEST_0_AMT{}'.format(idx):
             item.price,
             'L_PAYMENTREQUEST_0_NAME{}'.format(idx):
             item.details_verbose,
             'L_PAYMENTREQUEST_0_DESC{}'.format(idx):
             product.name,
         })
     return cart_items_request_params
Example #4
0
    def __prepare_cart_items(self):
        variant_ids = self.order.product_variants_ids
        if len(variant_ids) > 1:
            raise PaypalDataError("Ordered more then 1 variant: %r" %
                                  variant_ids)
        variant_id = list(variant_ids)[0]
        cart_items_request_params = {}
        tax = current_app.config['SHOPS'][current_app.config['SHOP_ID']]['tax']
        product = BaseProduct.objects(__raw__={
            'product_variants.$id': ObjectId(variant_id)
        }).first()
        goods, delivery = self.order.get_goods_delivery_for_variant(variant_id)

        for idx, item in enumerate(goods):
            item_category = current_app.config['DELIVERY_TO_PAYPAL'][delivery]

            item_descr = _("Row {rowNumber} Seat {seatNumber}").format(**item.details)
            description = u'{} [{}]'.format(product.name, item_descr)

            invoice_id = self.gen_invoice_id(self.order.id, item.id)

            cart_items_request_params.update({
                'PAYMENTREQUEST_{}_PAYMENTREQUESTID'.format(idx): invoice_id,
                'PAYMENTREQUEST_{}_SELLERPAYPALACCOUNTID'.format(idx): self.settings['EMAIL'],
                'PAYMENTREQUEST_{}_AMT'.format(idx): item.price,
                'PAYMENTREQUEST_{}_PAYMENTACTION'.format(idx): ACTION,
                'PAYMENTREQUEST_{}_CURRENCYCODE'.format(idx): CURRENCY,
                'PAYMENTREQUEST_{}_DESC'.format(idx): description,
                'PAYMENTREQUEST_{}_INVNUM'.format(idx): invoice_id,
                'L_PAYMENTREQUEST_{}_ITEMCATEGORY0'.format(idx): item_category,
                'L_PAYMENTREQUEST_{}_TAXAMT0'.format(idx): Decimal(tax),
                'L_PAYMENTREQUEST_{}_QTY0'.format(idx): 1,
                'L_PAYMENTREQUEST_{}_AMT0'.format(idx): item.price,
                'L_PAYMENTREQUEST_{}_NAME0'.format(idx): product.name,
                'L_PAYMENTREQUEST_{}_DESC0'.format(idx): item.details_verbose
            })

        return cart_items_request_params
Example #5
0
 def product_count(self):
     return BaseProduct.objects(created_by=self.id).count()
Example #6
0
 def product_count(self):
     return BaseProduct.objects(created_by=self.id).count()