forked from CGM_Public/pretix_original
PPv2 APM: Create referenced PPObjects for APM Orders; enable webhooks to capture them
This commit is contained in:
@@ -586,6 +586,9 @@ class PaypalMethod(BasePaymentProvider):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
response = self.client.execute(paymentreq)
|
response = self.client.execute(paymentreq)
|
||||||
|
|
||||||
|
if payment:
|
||||||
|
ReferencedPayPalObject.objects.get_or_create(order=payment.order, payment=payment, reference=response.result.id)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
if "RESOURCE_NOT_FOUND" in str(e):
|
if "RESOURCE_NOT_FOUND" in str(e):
|
||||||
messages.error(request, _('Your payment has failed due to a known issue within PayPal. Please try '
|
messages.error(request, _('Your payment has failed due to a known issue within PayPal. Please try '
|
||||||
|
|||||||
@@ -482,8 +482,8 @@ def webhook(request, *args, **kwargs):
|
|||||||
amount=payment.amount - known_sum
|
amount=payment.amount - known_sum
|
||||||
)
|
)
|
||||||
elif payment.state in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED,
|
elif payment.state in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED,
|
||||||
OrderPayment.PAYMENT_STATE_CANCELED, OrderPayment.PAYMENT_STATE_FAILED) \
|
OrderPayment.PAYMENT_STATE_CANCELED, OrderPayment.PAYMENT_STATE_FAILED):
|
||||||
and sale['status'] == 'COMPLETED':
|
if sale['status'] == 'COMPLETED':
|
||||||
any_captures = False
|
any_captures = False
|
||||||
all_captures_completed = True
|
all_captures_completed = True
|
||||||
for purchaseunit in sale['purchase_units']:
|
for purchaseunit in sale['purchase_units']:
|
||||||
@@ -505,6 +505,9 @@ def webhook(request, *args, **kwargs):
|
|||||||
payment.confirm()
|
payment.confirm()
|
||||||
except Quota.QuotaExceededException:
|
except Quota.QuotaExceededException:
|
||||||
pass
|
pass
|
||||||
|
elif sale['status'] == 'APPROVED':
|
||||||
|
request.session['payment_paypal_oid'] = payment.info_data['id']
|
||||||
|
payment.payment_provider.execute_payment(request, payment)
|
||||||
|
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user