payfip_ws: consider cancelled transaction as still waiting for a resolution (#71155)
This commit is contained in:
parent
97b6bac733
commit
1841f1fa4a
|
@ -327,7 +327,14 @@ class Payment(PaymentCommon):
|
||||||
if e.code == 'P5' and delta < threshold:
|
if e.code == 'P5' and delta < threshold:
|
||||||
return PaymentResponse(result=WAITING, signed=True, order_id=transaction_id)
|
return PaymentResponse(result=WAITING, signed=True, order_id=transaction_id)
|
||||||
raise e
|
raise e
|
||||||
return self.payfip_response_to_eopayment_response(idop, response)
|
eopayment_response = self.payfip_response_to_eopayment_response(idop, response)
|
||||||
|
# convert CANCELLED to WAITING during the first 20 minutes
|
||||||
|
if eopayment_response.result == CANCELLED and delta < threshold:
|
||||||
|
eopayment_response.result = WAITING
|
||||||
|
eopayment_response.bank_status = (
|
||||||
|
'%s - still waiting as idop is still active' % eopayment_response.bank_status
|
||||||
|
)
|
||||||
|
return eopayment_response
|
||||||
|
|
||||||
def response(self, query_string, **kwargs):
|
def response(self, query_string, **kwargs):
|
||||||
fields = parse_qs(query_string, True)
|
fields = parse_qs(query_string, True)
|
||||||
|
|
|
@ -393,8 +393,8 @@ def test_payment_cancelled(history, backend):
|
||||||
assert url == 'https://www.payfip.gouv.fr/tpa/paiementws.web?idop=cc0cb210-1cd4-11ea-8cca-0213ad91a103'
|
assert url == 'https://www.payfip.gouv.fr/tpa/paiementws.web?idop=cc0cb210-1cd4-11ea-8cca-0213ad91a103'
|
||||||
|
|
||||||
response = backend.response('idop=%s' % payment_id)
|
response = backend.response('idop=%s' % payment_id)
|
||||||
assert response.result == eopayment.CANCELLED
|
assert response.result == eopayment.WAITING
|
||||||
assert response.bank_status == 'cancelled CB'
|
assert response.bank_status == 'cancelled CB - still waiting as idop is still active'
|
||||||
assert response.order_id == payment_id
|
assert response.order_id == payment_id
|
||||||
assert response.transaction_id == '201912261758460053903194 cc0cb210-1cd4-11ea-8cca-0213ad91a103'
|
assert response.transaction_id == '201912261758460053903194 cc0cb210-1cd4-11ea-8cca-0213ad91a103'
|
||||||
|
|
||||||
|
@ -406,7 +406,17 @@ def test_payment_status_cancelled(history, backend, freezer):
|
||||||
response = backend.payment_status(
|
response = backend.payment_status(
|
||||||
transaction_id='cc0cb210-1cd4-11ea-8cca-0213ad91a103', transaction_date=now
|
transaction_id='cc0cb210-1cd4-11ea-8cca-0213ad91a103', transaction_date=now
|
||||||
)
|
)
|
||||||
|
assert response.result == eopayment.WAITING
|
||||||
|
assert response.bank_status == 'cancelled CB - still waiting as idop is still active'
|
||||||
|
|
||||||
|
freezer.move_to(datetime.timedelta(minutes=20, seconds=1))
|
||||||
|
|
||||||
|
history.counter = 1 # only the response
|
||||||
|
response = backend.payment_status(
|
||||||
|
transaction_id='cc0cb210-1cd4-11ea-8cca-0213ad91a103', transaction_date=now
|
||||||
|
)
|
||||||
assert response.result == eopayment.CANCELLED
|
assert response.result == eopayment.CANCELLED
|
||||||
|
assert response.bank_status == 'cancelled CB'
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_objet():
|
def test_normalize_objet():
|
||||||
|
|
Loading…
Reference in New Issue