changes
This commit is contained in:
@@ -539,6 +539,61 @@ class PaymentProvider(models.Model):
|
||||
)
|
||||
return None
|
||||
|
||||
# === BUSINESS METHODS - SETTLEMENT === #
|
||||
|
||||
def _poynt_fetch_settlement_transactions(self, date_from, date_to):
|
||||
"""Fetch all transactions from Poynt API for a date range.
|
||||
|
||||
Paginates through results using startOffset. Filters for settled
|
||||
SALE and REFUND transactions.
|
||||
|
||||
:param date date_from: Start date (inclusive).
|
||||
:param date date_to: End date (inclusive).
|
||||
:return: List of transaction dicts from the Poynt API.
|
||||
:rtype: list[dict]
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
# Convert dates to ISO8601 timestamps (start of day / end of day)
|
||||
start_at = f"{date_from}T00:00:00Z"
|
||||
end_at = f"{date_to}T23:59:59Z"
|
||||
|
||||
all_transactions = []
|
||||
offset = 0
|
||||
limit = 100
|
||||
|
||||
while True:
|
||||
params = {
|
||||
'startAt': start_at,
|
||||
'endAt': end_at,
|
||||
'limit': limit,
|
||||
'startOffset': offset,
|
||||
}
|
||||
result = self._poynt_make_request(
|
||||
'GET', 'transactions', params=params,
|
||||
)
|
||||
|
||||
transactions = result.get('transactions', [])
|
||||
if not transactions:
|
||||
# Also check if result itself is a list (API version variance)
|
||||
if isinstance(result, list):
|
||||
transactions = result
|
||||
else:
|
||||
break
|
||||
|
||||
all_transactions.extend(transactions)
|
||||
|
||||
# Check if there are more pages
|
||||
if len(transactions) < limit:
|
||||
break
|
||||
offset += limit
|
||||
|
||||
_logger.info(
|
||||
"Poynt: fetched %d transactions for %s to %s",
|
||||
len(all_transactions), date_from, date_to,
|
||||
)
|
||||
return all_transactions
|
||||
|
||||
def _poynt_notification(self, message, notification_type='info'):
|
||||
"""Return a display_notification action.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user