Skip to content

Commit

Permalink
Fixing REST API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Delawen committed Oct 19, 2020
1 parent f004768 commit 89959f4
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions pretix_mercadopago/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,27 +352,15 @@ def matching_id(self, payment: OrderPayment):
# Will be called to get an ID for a matching this payment when comparing
# pretix records with records of an external source.
# This should return the main transaction ID for your API.
sale_id = None
for trans in payment.info_data.get('transactions', []):
for res in trans.get('related_resources', []):
if 'sale' in res and 'id' in res['sale']:
sale_id = res['sale']['id']
return sale_id or payment.info_data.get('id', None)
return payment.info_data.get('external_reference', None)

def api_payment_details(self, payment: OrderPayment):
# Will be called to populate the details parameter of the payment in the REST API.
sale_id = None
for trans in payment.info_data.get('transactions', []):
for res in trans.get('related_resources', []):
if 'sale' in res and 'id' in res['sale']:
sale_id = res['sale']['id']
# Will be called to populate the details parameter
# of the payment in the REST API.
return {
"payer_email": payment.info_data.get('payer', {}).get('payer_info', {}).get('email'),
"payer_id": payment.info_data.get('payer', {}).get('payer_info', {}).get('payer_id'),
"cart_id": payment.info_data.get('cart', None),
"payment_id": payment.info_data.get('id', None),
"sale_id": sale_id,
"payment_info": payment.info
}

####################################################################
# Utility functions #
####################################################################
Expand Down

0 comments on commit 89959f4

Please sign in to comment.