def get_provider_seller_uuid(issuer_key, product_data, provider_names): """Resolve the JWT into a seller uuid.""" if is_marketplace(issuer_key): # The issuer of the JWT is Firefox Marketplace. # This is a special case where we need to find the # actual Solitude/Bango seller_uuid to associate the # product to the right account. try: public_id = product_data['public_id'][0] except KeyError: raise InvalidPublicID( 'Marketplace {key} did not put a ' 'public_id in productData: {product_data}'.format( key=settings.KEY, product_data=product_data ) ) log.info('Got public_id from Marketplace app purchase') else: # The issuer of the JWT is the seller. # Resolve this into the seller uuid. public_id = issuer_key log.info('Got public_id from in-app purchase') product = client.slumber.generic.product.get_object_or_404( public_id=public_id) seller = (client.slumber.generic.seller(uri_to_pk(product['seller'])) .get_object_or_404()) generic_seller_uuid = seller['uuid'] return product, seller, generic_seller_uuid
def get_provider_seller_uuid(issuer_key, product_data, provider_names): """Resolve the JWT into a seller uuid.""" if is_marketplace(issuer_key): # The issuer of the JWT is Firefox Marketplace. # This is a special case where we need to find the # actual Solitude/Bango seller_uuid to associate the # product to the right account. try: public_id = product_data['public_id'][0] except KeyError: raise InvalidPublicID( 'Marketplace {key} did not put a ' 'public_id in productData: {product_data}'.format( key=settings.KEY, product_data=product_data)) log.info('Got public_id from Marketplace app purchase') else: # The issuer of the JWT is the seller. # Resolve this into the seller uuid. public_id = issuer_key log.info('Got public_id from in-app purchase') product = client.slumber.generic.product.get_object_or_404( public_id=public_id) seller = (client.slumber.generic.seller(uri_to_pk( product['seller'])).get_object_or_404()) generic_seller_uuid = seller['uuid'] return product, seller, generic_seller_uuid
def get_provider_seller_uuid(issuer_key, product_data, provider_names): """Resolve the JWT into a seller uuid.""" if is_marketplace(issuer_key): # The issuer of the JWT is Firefox Marketplace. # This is a special case where we need to find the # actual Solitude/Bango seller_uuid to associate the # product to the right account. try: public_id = product_data['public_id'][0] except KeyError: raise ValueError( 'Marketplace {key} did not put a ' 'public_id in productData: {product_data}'.format( key=settings.KEY, product_data=product_data ) ) log.info('Got public_id from Marketplace app purchase') else: # The issuer of the JWT is the seller. # Resolve this into the seller uuid. public_id = issuer_key log.info('Got public_id from in-app purchase') product = client.slumber.generic.product.get_object_or_404( public_id=public_id) seller = (client.slumber.generic.seller(uri_to_pk(product['seller'])) .get_object_or_404()) generic_seller_uuid = seller['uuid'] for provider in provider_names: if product['seller_uuids'].get(provider, None) is not None: provider_seller_uuid = product['seller_uuids'][provider] log.info('Using provider seller uuid {s} for provider ' '{p} and for public_id {i}, generic seller uuid {u}' .format(s=provider_seller_uuid, u=generic_seller_uuid, p=provider, i=public_id)) return (ProviderHelper(provider), provider_seller_uuid, generic_seller_uuid) raise ValueError( 'Unable to find a valid seller_uuid for public_id {public_id} ' 'using providers: {providers}'.format( public_id=public_id, providers=provider_names))