当前位置: 首页>>代码示例>>Python>>正文


Python PayPalInterface.refund_transaction方法代码示例

本文整理汇总了Python中vendor.paypalapi.interface.PayPalInterface.refund_transaction方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalInterface.refund_transaction方法的具体用法?Python PayPalInterface.refund_transaction怎么用?Python PayPalInterface.refund_transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vendor.paypalapi.interface.PayPalInterface的用法示例。


在下文中一共展示了PayPalInterface.refund_transaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: refund_premium

# 需要导入模块: from vendor.paypalapi.interface import PayPalInterface [as 别名]
# 或者: from vendor.paypalapi.interface.PayPalInterface import refund_transaction [as 别名]
 def refund_premium(self):
     refunded = False
     
     if self.stripe_id:
         stripe.api_key = settings.STRIPE_SECRET
         stripe_customer = stripe.Customer.retrieve(self.stripe_id)
         stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
         stripe_payments[0].refund()
         refunded = stripe_payments[0].amount/100
         logging.user(self.user, "~FRRefunding stripe payment: $%s" % refunded)
         self.cancel_premium()
     else:
         paypal_opts = {
             'API_ENVIRONMENT': 'PRODUCTION',
             'API_USERNAME': settings.PAYPAL_API_USERNAME,
             'API_PASSWORD': settings.PAYPAL_API_PASSWORD,
             'API_SIGNATURE': settings.PAYPAL_API_SIGNATURE,
         }
         paypal = PayPalInterface(**paypal_opts)
         transaction = PayPalIPN.objects.filter(custom=self.user.username,
                                                txn_type='subscr_payment')[0]
         refund = paypal.refund_transaction(transaction.txn_id)
         refunded = int(float(refund['raw']['TOTALREFUNDEDAMOUNT'][0]))
         logging.user(self.user, "~FRRefunding paypal payment: $%s" % refunded)
         self.cancel_premium()
     
     return refunded
开发者ID:343max,项目名称:NewsBlur,代码行数:29,代码来源:models.py

示例2: refund_premium

# 需要导入模块: from vendor.paypalapi.interface import PayPalInterface [as 别名]
# 或者: from vendor.paypalapi.interface.PayPalInterface import refund_transaction [as 别名]
    def refund_premium(self, partial=False):
        refunded = False

        if self.stripe_id:
            stripe.api_key = settings.STRIPE_SECRET
            stripe_customer = stripe.Customer.retrieve(self.stripe_id)
            stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
            if partial:
                stripe_payments[0].refund(amount=1200)
                refunded = 12
            else:
                stripe_payments[0].refund()
                self.cancel_premium()
                refunded = stripe_payments[0].amount / 100
            logging.user(self.user, "~FRRefunding stripe payment: $%s" % refunded)
        else:
            paypal_opts = {
                "API_ENVIRONMENT": "PRODUCTION",
                "API_USERNAME": settings.PAYPAL_API_USERNAME,
                "API_PASSWORD": settings.PAYPAL_API_PASSWORD,
                "API_SIGNATURE": settings.PAYPAL_API_SIGNATURE,
            }
            paypal = PayPalInterface(**paypal_opts)
            transaction = PayPalIPN.objects.filter(custom=self.user.username, txn_type="subscr_payment")[0]
            refund = paypal.refund_transaction(transaction.txn_id)
            try:
                refunded = int(float(refund.raw["TOTALREFUNDEDAMOUNT"][0]))
            except KeyError:
                refunded = int(transaction.payment_gross)
            logging.user(self.user, "~FRRefunding paypal payment: $%s" % refunded)
            self.cancel_premium()

        return refunded
开发者ID:kranthikumar,项目名称:NewsBlur,代码行数:35,代码来源:models.py

示例3: refund_premium

# 需要导入模块: from vendor.paypalapi.interface import PayPalInterface [as 别名]
# 或者: from vendor.paypalapi.interface.PayPalInterface import refund_transaction [as 别名]
    def refund_premium(self, partial=False):
        refunded = False
        
        if self.stripe_id:
            stripe.api_key = settings.STRIPE_SECRET
            stripe_customer = stripe.Customer.retrieve(self.stripe_id)
            stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
            if partial:
                stripe_payments[0].refund(amount=1200)
                refunded = 12
            else:
                stripe_payments[0].refund()
                self.cancel_premium()
                refunded = stripe_payments[0].amount/100
            logging.user(self.user, "~FRRefunding stripe payment: $%s" % refunded)
        else:
            self.cancel_premium()

            paypal_opts = {
                'API_ENVIRONMENT': 'PRODUCTION',
                'API_USERNAME': settings.PAYPAL_API_USERNAME,
                'API_PASSWORD': settings.PAYPAL_API_PASSWORD,
                'API_SIGNATURE': settings.PAYPAL_API_SIGNATURE,
                'API_CA_CERTS': False,
            }
            paypal = PayPalInterface(**paypal_opts)
            transactions = PayPalIPN.objects.filter(custom=self.user.username,
                                                    txn_type='subscr_payment'
                                                    ).order_by('-payment_date')
            if not transactions:
                transactions = PayPalIPN.objects.filter(payer_email=self.user.email,
                                                        txn_type='subscr_payment'
                                                        ).order_by('-payment_date')
            if transactions:
                transaction = transactions[0]
                refund = paypal.refund_transaction(transaction.txn_id)
                try:
                    refunded = int(float(refund.raw['TOTALREFUNDEDAMOUNT'][0]))
                except KeyError:
                    refunded = int(transaction.payment_gross)
                logging.user(self.user, "~FRRefunding paypal payment: $%s" % refunded)
            else:
                logging.user(self.user, "~FRCouldn't refund paypal payment: not found by username or email")
                refunded = 0
                    
        
        return refunded
开发者ID:semai,项目名称:NewsBlur,代码行数:49,代码来源:models.py


注:本文中的vendor.paypalapi.interface.PayPalInterface.refund_transaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。