def _do_create(self, profile_data): """ Creates a new profile in the PayPal account with the specified id, using the specified data. """ profile = WebProfile(profile_data) result = profile.create() if not result: raise CommandError("Could not create web profile: {}".format(profile.error)) log.info("Created profile `%s` (id=%s).", profile.name, profile.id) return profile
def _inverse_paypal_profile_info(self): paypal = self._get_paypal_api() for record in self: if not record.paypal_profile_info: continue info = json.loads(record.paypal_profile_info) if record.paypal_profile_id: web_profile = WebProfile.find(record.paypal_profile_id, api=paypal) if not web_profile.update(info): raise UserError( _("Error updating paypal profile:\n %s") % web_profile.error) else: web_profile = WebProfile(info, api=paypal) if not web_profile.create(): raise UserError( _("Error creating paypal profile:\n %s") % web_profile.error) record.paypal_profile_id = web_profile.id
import string logging.basicConfig(level=logging.INFO) # Name needs to be unique so just generating a random one wpn = ''.join(random.choice(string.ascii_uppercase) for i in range(12)) web_profile = WebProfile({ "name": wpn, "presentation": { "brand_name": "YeowZa Paypal", "logo_image": "http://s3-ec.buzzfed.com/static/2014-07/18/8/enhanced/webdr02/anigif_enhanced-buzz-21087-1405685585-12.gif", "locale_code": "US" }, "input_fields": { "allow_note": True, "no_shipping": 1, "address_override": 1 }, "flow_config": { "landing_page_type": "billing", "bank_txn_pending_url": "http://www.yeowza.com" } }) if web_profile.create(): print(("Web Profile[%s] created successfully" % (web_profile.id))) else: print((web_profile.error)) payment = Payment({