mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
PPv2: Do not PATCH custom_id and description for APMs (#2898)
This commit is contained in:
@@ -615,41 +615,46 @@ class PaypalMethod(BasePaymentProvider):
|
|||||||
'proceed.'))
|
'proceed.'))
|
||||||
|
|
||||||
if pp_captured_order.status == 'APPROVED':
|
if pp_captured_order.status == 'APPROVED':
|
||||||
try:
|
# We are suspecting that some or even all APMs cannot be PATCHed after being approved by the buyer,
|
||||||
custom_id = '{prefix}{orderstring}{postfix}'.format(
|
# without the PayPal Order losing its APPROVED-status again.
|
||||||
prefix='{} '.format(self.settings.prefix) if self.settings.prefix else '',
|
# Since APMs are already created with their proper custom_id and description (at the time the PayPal
|
||||||
orderstring=__('Order {slug}-{code}').format(
|
# Order is created for the APM, we already have pretix order code), we skip the PATCH-request.
|
||||||
slug=self.event.slug.upper(),
|
if payment.order.code not in pp_captured_order.purchase_units[0].custom_id:
|
||||||
code=payment.order.code
|
try:
|
||||||
),
|
custom_id = '{prefix}{orderstring}{postfix}'.format(
|
||||||
postfix=' {}'.format(self.settings.postfix) if self.settings.postfix else ''
|
prefix='{} '.format(self.settings.prefix) if self.settings.prefix else '',
|
||||||
)
|
orderstring=__('Order {slug}-{code}').format(
|
||||||
description = '{prefix}{orderstring}{postfix}'.format(
|
slug=self.event.slug.upper(),
|
||||||
prefix='{} '.format(self.settings.prefix) if self.settings.prefix else '',
|
code=payment.order.code
|
||||||
orderstring=__('Order {order} for {event}').format(
|
),
|
||||||
event=request.event.name,
|
postfix=' {}'.format(self.settings.postfix) if self.settings.postfix else ''
|
||||||
order=payment.order.code
|
)
|
||||||
),
|
description = '{prefix}{orderstring}{postfix}'.format(
|
||||||
postfix=' {}'.format(self.settings.postfix) if self.settings.postfix else ''
|
prefix='{} '.format(self.settings.prefix) if self.settings.prefix else '',
|
||||||
)
|
orderstring=__('Order {order} for {event}').format(
|
||||||
patchreq = OrdersPatchRequest(pp_captured_order.id)
|
event=request.event.name,
|
||||||
patchreq.request_body([
|
order=payment.order.code
|
||||||
{
|
),
|
||||||
"op": "replace",
|
postfix=' {}'.format(self.settings.postfix) if self.settings.postfix else ''
|
||||||
"path": "/purchase_units/@reference_id=='default'/custom_id",
|
)
|
||||||
"value": custom_id[:127],
|
patchreq = OrdersPatchRequest(pp_captured_order.id)
|
||||||
},
|
patchreq.request_body([
|
||||||
{
|
{
|
||||||
"op": "replace",
|
"op": "replace",
|
||||||
"path": "/purchase_units/@reference_id=='default'/description",
|
"path": "/purchase_units/@reference_id=='default'/custom_id",
|
||||||
"value": description[:127],
|
"value": custom_id[:127],
|
||||||
}
|
},
|
||||||
])
|
{
|
||||||
self.client.execute(patchreq)
|
"op": "replace",
|
||||||
except IOError as e:
|
"path": "/purchase_units/@reference_id=='default'/description",
|
||||||
messages.error(request, _('We had trouble communicating with PayPal'))
|
"value": description[:127],
|
||||||
logger.exception('PayPal OrdersPatchRequest: {}'.format(str(e)))
|
}
|
||||||
return
|
])
|
||||||
|
self.client.execute(patchreq)
|
||||||
|
except IOError as e:
|
||||||
|
messages.error(request, _('We had trouble communicating with PayPal'))
|
||||||
|
logger.exception('PayPal OrdersPatchRequest: {}'.format(str(e)))
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
capturereq = OrdersCaptureRequest(pp_captured_order.id)
|
capturereq = OrdersCaptureRequest(pp_captured_order.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user