def create_temporary_web_profile(self, locale_code): """ Generates a temporary Paypal WebProfile that carries the locale setting for a Paypal Payment and returns the id of the WebProfile """ try: web_profile = paypalrestsdk.WebProfile( { "name": str(uuid.uuid1()), # Generate a unique identifier "presentation": { "locale_code": locale_code }, "temporary": True # Persists for 3 hours }, api=self.paypal_api) if web_profile.create(): msg = "Web Profile[%s] for locale %s created successfully" % ( web_profile.id, web_profile.presentation.locale_code) logger.info(msg) return web_profile.id msg = "Web profile creation encountered error [%s]. Will continue without one" % ( web_profile.error) logger.warning(msg) return None except Exception: # pylint: disable=broad-except logger.warning( "Creating PayPal WebProfile resulted in exception. Will continue without one." ) return None
def create_profile(paypal): web_profile = paypalrestsdk.WebProfile( { "name": 'Adaptoo 2', "presentation": { "brand_name": "Adaptoo Paypal", "logo_image": ("http://www.adaptoo.com/skin/frontend/" "adaptoo/default/images/logo.gif"), "locale_code": "FR" }, "input_fields": { "no_shipping": 1, "address_override": 1 }, "flow_config": { "user_action": "commit" } }, api=paypal) if web_profile.create(): _logger.info("Web Profile[%s] created successfully", web_profile.id) else: _logger.error('%s', web_profile.error)
def getWebProfile(): # Gets Paypal Web Profile wpn = ''.join(random.choice(string.ascii_uppercase) for i in range(12)) web_profile = paypalrestsdk.WebProfile({ "name": wpn, # "temporary": "true", "presentation": { "brand_name": "scholarium", "logo_image": "https://drive.google.com/open?id=0B4pA_9bw5MghZEVuQmJGaS1FSFU", "locale_code": "AT" }, "input_fields": { "allow_note": True, "no_shipping": 1, "address_override": 1 }, "flow_config": { "landing_page_type": "login", "bank_txn_pending_url": 'http://' + Site.objects.get(pk=settings.SITE_ID).domain + reverse('gast_zahlung'), "user_action": "commit" } }) if web_profile.create(): print("Web Profile[%s] created successfully" % (web_profile.id)) return web_profile else: print(web_profile.error) return None
def _web_profile_create(self, **kwargs): web_profile_obj = paypalrestsdk.WebProfile({ "name": kwargs.get("name"), "input_fields": { "allow_note": True, "no_shipping": 1, "address_override": 1 }, "flow_config": { "landing_page_type": "billing", } }, api=self.api) if web_profile_obj.create(): return {"error": 0, "obj": web_profile_obj} else: return {"error": 1, "message": web_profile_obj.error}
def create_web_experience_profile(): web_profile = paypalrestsdk.WebProfile({ "name": "KAMPER", "presentation": { "brand_name": "KAMPER PAYPAL", "logo_image": "https://kamper.co.kr/static/kamper/images/logo.jpg", "locale_code": "KR" }, "input_fields": { "allow_note": True, "no_shipping": 2, "address_override": 1, }, "flow_config": { } }) if web_profile.create(): print("Web Profile[%s] created successfully" % (web_profile.id)) else: print(web_profile.error) return web_profile