Пример #1
0
 def do_accept_subscription_signup(self, POST, transaction_id):
     try:
         transaction = SubscriptionTransaction.objects.get(
             pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     purchase = transaction.purchase.subscriptionpurchase
     m = {
         Period.UNIT_DAYS: 'D',
         Period.UNIT_WEEKS: 'W',
         Period.UNIT_MONTHS: 'M',
         Period.UNIT_YEARS: 'Y',
     }
     period1_right = (purchase.item.subscriptionitem.trial_period.count == 0 and 'period1' not in POST) or \
                     (purchase.item.subscriptionitem.trial_period.count != 0 and 'period1' in POST and \
                      POST['period1'] == str(purchase.item.subscriptionitem.trial_period.count)+' '+m[purchase.item.subscriptionitem.trial_period.unit])
     if period1_right and 'period2' not in POST and \
                     Decimal(POST['amount3']) == purchase.item.price and \
                     POST['period3'] == str(purchase.item.subscriptionitem.payment_period.count)+' '+m[purchase.item.subscriptionitem.payment_period.unit] and \
                     POST['mc_currency'] == purchase.item.currency:
         self.do_subscription_or_recurring_created(transaction, POST,
                                                   POST['subscr_id'])
     else:
         logger.warning("Wrong subscription signup data")
Пример #2
0
 def post(self, request):
     try:
         self.do_post(request)
     except KeyError as e:
         logger.warning("PayPal IPN var %s is missing" % e)
     except:
         import traceback
         traceback.print_exc()
     return HttpResponse('', content_type="text/plain")
Пример #3
0
 def do_appect_refund(self, POST, transaction_id):
     try:
         transaction = BaseTransaction.objects.get(pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     if POST['mc_currency'] == transaction.purchase.item.currency:
         transaction.payment.refund_payment()
     else:
         logger.warning("Wrong refund currency.")
Пример #4
0
 def do_do_post(self, POST, request):
     debug = settings.PAYPAL_DEBUG
     url = 'https://www.sandbox.paypal.com' if debug else 'https://www.paypal.com'
     r = requests.post(
         url + '/cgi-bin/webscr',
         'cmd=_notify-validate&' + request.body.decode(
             POST.get('charset') or request.content_params['charset']),
         headers={'content-type': request.content_type
                  })  # message must use the same encoding as the original
     if r.text == 'VERIFIED':
         self.verified_post(POST, request)
     else:
         logger.warning("PayPal verification not passed")
Пример #5
0
 def accept_recurring_signup(self, POST, transaction_id):
     try:
         transaction = SubscriptionTransaction.objects.get(
             pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     if 'period1' not in POST and 'period2' not in POST and \
                     Decimal(POST['mc_amount3']) == transaction.purchase.item.price + transaction.purchase.shipping + transaction.purchase.tax and \
                     POST['mc_currency'] == transaction.purchase.item.currency and \
                     POST['period3'] in self.pp_payment_cycles(transaction):
         self.do_subscription_or_recurring_created(
             transaction, POST, POST['recurring_payment_id'])
     else:
         logger.warning("Wrong recurring signup data")
Пример #6
0
 def do_accept_subscription_payment(self, POST, transaction_id):
     # transaction = BaseTransaction.objects.select_for_update().get(pk=transaction_id)  # only inside transaction
     try:
         transaction = SubscriptionTransaction.objects.get(
             pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     purchase = transaction.purchase
     if Decimal(POST['mc_gross']) == purchase.item.price + purchase.shipping + purchase.tax and \
                     POST['mc_currency'] == purchase.item.currency:
         self.do_do_accept_subscription_or_recurring_payment(
             transaction, purchase, POST, POST['subscr_id'])
     else:
         logger.warning("Wrong subscription payment data")
Пример #7
0
 def do_accept_recurring_payment(self, POST, transaction_id):
     # transaction = BaseTransaction.objects.select_for_update().get(pk=transaction_id)  # only inside transaction
     try:
         transaction = SubscriptionTransaction.objects.get(
             pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     if Decimal(POST['amount_per_cycle']) == transaction.purchase.item.price + transaction.purchase.item.shipping + transaction.purchase.item.tax and \
                     POST['payment_cycle'] in self.pp_payment_cycles(transaction.purchase.item):
         self.do_do_accept_subscription_or_recurring_payment(
             transaction, transaction.purchase.item, POST,
             POST['recurring_payment_id'])
     else:
         logger.warning("Wrong recurring payment data")
Пример #8
0
 def do_do_accept_regular_payment(self, POST, transaction_id):
     try:
         transaction = SimpleTransaction.objects.get(pk=transaction_id)
     except BaseTransaction.DoesNotExist:
         traceback.print_exc()
         return
     if Decimal(POST['mc_gross']) == transaction.purchase.item.price and \
                     Decimal(POST['shipping']) == transaction.purchase.shipping and \
                     Decimal(POST['tax']) == transaction.purchase.tax and \
                     POST['mc_currency'] == transaction.purchase.item.currency:
         if self.auto_refund(
                 transaction, transaction.purchase.simplepurchase.
                 prolongpurchase.prolonged, POST):
             return HttpResponse('')
         payment = transaction.on_accept_regular_payment(
             POST['payer_email'])
         self.on_payment(payment)
     else:
         logger.warning("Wrong amount or currency")
Пример #9
0
 def do_post(self, request):
     # 'payment_date', 'time_created' unused
     if request.POST['receiver_email'] == settings.PAYPAL_EMAIL:
         self.do_do_post(request.POST, request)
     else:
         logger.warning("Wrong PayPal email")