本文整理汇总了Python中r2.models.bidding.PayID.add方法的典型用法代码示例。如果您正苦于以下问题:Python PayID.add方法的具体用法?Python PayID.add怎么用?Python PayID.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.bidding.PayID
的用法示例。
在下文中一共展示了PayID.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_response
# 需要导入模块: from r2.models.bidding import PayID [as 别名]
# 或者: from r2.models.bidding.PayID import add [as 别名]
def process_response(self, res):
from r2.models import Account
fullname = res.merchantcustomerid.contents[0]
name = res.description.contents[0]
customer_id = int(res.customerprofileid.contents[0])
acct = Account._by_name(name)
# make sure we are updating the correct account!
if acct.name == name:
CustomerID.set(acct, customer_id)
else:
raise AuthorizeNetException, "account name doesn't match authorize.net account"
# parse the ship-to list, and make sure the Account is up todate
ship_to = []
for profile in res.findAll("shiptolist"):
a = Address.fromXML(profile)
ShippingAddress.add(acct, a.customerAddressId)
ship_to.append(a)
# parse the payment profiles, and ditto
profiles = []
for profile in res.findAll("paymentprofiles"):
a = Address.fromXML(profile)
cc = CreditCard.fromXML(profile.payment)
payprof = PaymentProfile(a, cc, int(a.customerPaymentProfileId))
PayID.add(acct, a.customerPaymentProfileId)
profiles.append(payprof)
return acct, Profile(acct, profiles, ship_to)
示例2: add_payment_method
# 需要导入模块: from r2.models.bidding import PayID [as 别名]
# 或者: from r2.models.bidding.PayID import add [as 别名]
def add_payment_method(user, address, credit_card, validate=False):
profile_id = CustomerID.get_id(user._id)
payment_method_id = api.create_payment_profile(profile_id, address, credit_card, validate)
if payment_method_id:
PayID.add(user, payment_method_id)
return payment_method_id
示例3: get_or_create_customer_profile
# 需要导入模块: from r2.models.bidding import PayID [as 别名]
# 或者: from r2.models.bidding.PayID import add [as 别名]
def get_or_create_customer_profile(user):
profile_id = CustomerID.get_id(user._id)
if not profile_id:
profile_id = api.create_customer_profile(merchant_customer_id=user._fullname, description=user.name)
CustomerID.set(user, profile_id)
profile = api.get_customer_profile(profile_id)
if not profile or profile.merchantCustomerId != user._fullname:
raise ValueError("error getting customer profile")
for payment_profile in profile.paymentProfiles:
PayID.add(user, payment_profile.customerPaymentProfileId)
return profile