Ejemplo n.º 1
0
    def get_or_create_generic_product(self, app, secret=None):
        product_data = {
            'public_id': self.get_or_create_public_id(app),
        }

        log.info('Checking generic seller exists: {0}'.format(product_data))
        try:
            generic = self.generic.product.get_object_or_404(**product_data)
        except ObjectDoesNotExist:
            seller_uuid = get_uuid('seller')
            seller = self.generic.seller.post(data={'uuid': seller_uuid})

            log.info('Creating a new Generic Solitude '
                     'Seller {seller_uuid} for app {app}'.format(
                         seller_uuid=seller_uuid,
                         app=app,
                     ))

            product_data.update({
                'external_id': make_external_id(app),
                'seller': seller['resource_uri'],
                'secret': secret or generate_key(48),
                'access': ACCESS_PURCHASE,
            })
            generic = self.generic.product.post(data=product_data)

            log.info('Creating a new Generic Solitude Product '
                     '{public_id} for app {app}'.format(
                         public_id=product_data['public_id'],
                         app=app,
                     ))

        return generic
Ejemplo n.º 2
0
    def get_or_create_generic_product(self, app, secret=None):
        product_data = {
            'public_id': self.get_or_create_public_id(app),
        }

        log.info('Checking generic seller exists: {0}'.format(product_data))
        try:
            generic = self.generic.product.get_object_or_404(**product_data)
        except ObjectDoesNotExist:
            seller_uuid = get_uuid('seller')
            seller = self.generic.seller.post(data={'uuid': seller_uuid})

            log.info('Creating a new Generic Solitude '
                     'Seller {seller_uuid} for app {app}'.format(
                         seller_uuid=seller_uuid,
                         app=app,
                     ))

            product_data.update({
                'external_id': make_external_id(app),
                'seller': seller['resource_uri'],
                'secret': secret or generate_key(48),
                'access': ACCESS_PURCHASE,
            })
            generic = self.generic.product.post(data=product_data)

            log.info('Creating a new Generic Solitude Product '
                     '{public_id} for app {app}'.format(
                         public_id=product_data['public_id'],
                         app=app,
                     ))

        return generic
def get_generic_product(app):
    if app.app_payment_accounts.exists():
        for account in app.app_payment_accounts.all():
            print (
                'Looking up public_id for app '
                '{app} using account {account}'
            ).format(
                app=app,
                account=account.payment_account.seller_uri)
            try:
                generic_product = Provider.generic.product.get_object(
                    seller=uri_to_pk(account.payment_account.seller_uri),
                    external_id=make_external_id(app))
                print (
                    'Found generic product {product} for '
                    'app {app} using account {account}'
                ).format(
                    product=generic_product['public_id'],
                    app=app,
                    account=account)
                return generic_product
            except ObjectDoesNotExist:
                pass
            except MultipleObjectsReturned:
                print 'Found multiple generic products for app {app}'.format(
                    app=app)
        print 'Unable to find a generic product for app {app}'.format(app=app)
Ejemplo n.º 4
0
    def get_or_create_generic_product(self, app, secret=None):
        product_data = {"public_id": self.get_or_create_public_id(app)}

        log.info("Checking generic seller exists: {0}".format(product_data))
        try:
            generic = self.generic.product.get_object_or_404(**product_data)
        except ObjectDoesNotExist:
            seller_uuid = get_uuid("seller")
            seller = self.generic.seller.post(data={"uuid": seller_uuid})

            log.info(
                "Creating a new Generic Solitude "
                "Seller {seller_uuid} for app {app}".format(seller_uuid=seller_uuid, app=app)
            )

            product_data.update(
                {
                    "external_id": make_external_id(app),
                    "seller": seller["resource_uri"],
                    "secret": secret or generate_key(48),
                    "access": ACCESS_PURCHASE,
                }
            )
            generic = self.generic.product.post(data=product_data)

            log.info(
                "Creating a new Generic Solitude Product "
                "{public_id} for app {app}".format(public_id=product_data["public_id"], app=app)
            )

        return generic
def get_generic_product(app):
    if app.app_payment_accounts.exists():
        account = app.app_payment_accounts.all()[:1].get()
        generic_product = Provider.generic.product.get_object(
            seller=uri_to_pk(account.payment_account.seller_uri),
            external_id=make_external_id(app),
        )
        return generic_product
Ejemplo n.º 6
0
def get_generic_product(app):
    if app.app_payment_accounts.exists():
        account = app.app_payment_accounts.all()[:1].get()
        generic_product = Provider.generic.product.get_object(
            seller=uri_to_pk(account.payment_account.seller_uri),
            external_id=make_external_id(app),
        )
        return generic_product
def get_generic_product(app):
    if app.app_payment_accounts.exists():
        for account in app.app_payment_accounts.all():
            print(
                'Looking up public_id for app '
                '{app} using account {account}').format(
                    app=app, account=account.payment_account.seller_uri)
            try:
                generic_product = Provider.generic.product.get_object(
                    seller=uri_to_pk(account.payment_account.seller_uri),
                    external_id=make_external_id(app))
                print(
                    'Found generic product {product} for '
                    'app {app} using account {account}').format(
                        product=generic_product['public_id'],
                        app=app,
                        account=account)
                return generic_product
            except ObjectDoesNotExist:
                pass
            except MultipleObjectsReturned:
                print 'Found multiple generic products for app {app}'.format(
                    app=app)
        print 'Unable to find a generic product for app {app}'.format(app=app)
Ejemplo n.º 8
0
 def external_id(self):
     return make_external_id(self.webapp)
Ejemplo n.º 9
0
 def external_id(self):
     return 'inapp.{0}'.format(make_external_id(self.inapp))
Ejemplo n.º 10
0
 def external_id(self):
     return make_external_id(self.webapp)
Ejemplo n.º 11
0
 def external_id(self):
     return 'inapp.{0}'.format(make_external_id(self.inapp))