|
@@ -377,7 +377,6 @@ class PaypalCycleNotify(View):
|
|
|
self.paypal_webhook_log(**PaypalWebHookEventInsert)
|
|
|
if event_type != 'PAYMENT.SALE.COMPLETED':
|
|
|
PAY_LOGGER.info('----event_type异常:{}----'.format(event_type))
|
|
|
- self.find_subscription_transactions(billing_agreement_id)
|
|
|
|
|
|
if resource_type == 'sale' and paypal_body.get('state') == 'completed':
|
|
|
paypalrestsdk.configure(PAYPAL_CRD)
|
|
@@ -579,29 +578,6 @@ class PaypalCycleNotify(View):
|
|
|
PAY_LOGGER.info('PayPal周期扣款异常: errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return HttpResponse('fail', status=500)
|
|
|
|
|
|
- @staticmethod
|
|
|
- def find_subscription_transactions(billing_agreement_id):
|
|
|
- """
|
|
|
- 列出当前订阅扣款事务
|
|
|
- @param billing_agreement_id: 协议id
|
|
|
- @return:
|
|
|
- """
|
|
|
- if not billing_agreement_id:
|
|
|
- return False
|
|
|
- logger = logging.getLogger('pay')
|
|
|
- try:
|
|
|
- paypalrestsdk.configure(PAYPAL_CRD)
|
|
|
- billing_agreement = paypalrestsdk.BillingAgreement.find(billing_agreement_id)
|
|
|
- today = date_time.date.today()
|
|
|
- oneday = date_time.timedelta(days=1)
|
|
|
- yesterday = today - oneday
|
|
|
- start_date = yesterday.strftime('%Y-%m-%d')
|
|
|
- end_date = today.strftime('%Y-%m-%d')
|
|
|
- transactions = billing_agreement.search_transactions(start_date, end_date)
|
|
|
- logger.info('--->列出当前扣款事务{}'.format(transactions))
|
|
|
- except Exception as e:
|
|
|
- logger.info('出错了~查询订阅的事务异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
-
|
|
|
@staticmethod
|
|
|
def config_match_region(country_id):
|
|
|
country_qs = CountryModel.objects.filter(id=country_id).values('region_id')
|