Skip to content

Commit

Permalink
fix notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Aug 1, 2024
1 parent 49bd2e0 commit a802646
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/hope_payment_gateway/apps/fsp/western_union/endpoints/nis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from hope_payment_gateway.apps.core.permissions import WhitelistPermission
from hope_payment_gateway.apps.fsp.western_union.endpoints.client import WesternUnionClient
from hope_payment_gateway.apps.fsp.western_union.endpoints.exceptions import InvalidRequest
from hope_payment_gateway.apps.gateway.flows import PaymentRecordFlow
from hope_payment_gateway.apps.gateway.models import PaymentRecord

SUCCESS = "BIS003"
Expand Down Expand Up @@ -80,6 +81,7 @@ def post(self, request):

try:
pr = PaymentRecord.objects.get(fsp_code=fsp_code)
flow = PaymentRecordFlow(pr)
except PaymentRecord.DoesNotExist:
return Response(
{"cannot_find_transaction": f"Cannot find payment with reference {fsp_code}"},
Expand All @@ -89,7 +91,7 @@ def post(self, request):
pr.success = False
try:
if notification_type in [SUCCESS, SUCCESS_APN]:
pr.confirm()
flow.confirm()
pr.success = True
pr.payout_amount = payout_amount / 100
pr.extra_data.update(
Expand All @@ -99,13 +101,13 @@ def post(self, request):
}
)
elif notification_type in [CANCEL, REJECT_APN]:
pr.cancel()
flow.cancel()
elif notification_type == PURGED:
pr.purge()
flow.purge()
elif notification_type == REFUND:
pr.refund()
flow.refund()
else:
pr.fail()
flow.fail()
except TransitionNotAllowed as e:
return Response({"transition_not_allowed": str(e)}, status=HTTP_400_BAD_REQUEST)

Expand Down
5 changes: 3 additions & 2 deletions src/hope_payment_gateway/apps/fsp/western_union/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@app.task() # queue="executors"
def western_union_send_task(vision_vendor_number="1900723202", tag=None, threshold=10000):
"""Task to trigger Western Union payments"""
logging.info(f"Western Union Task started")
logging.info("Western Union Task started")
fsp = FinancialServiceProvider.objects.get(vision_vendor_number=vision_vendor_number)
threshold = threshold or config.WESTERN_UNION_THREASHOLD

Expand All @@ -45,7 +45,8 @@ def western_union_send_task(vision_vendor_number="1900723202", tag=None, thresho
pi.status = PaymentInstructionState.PROCESSED
pi.save()

logging.info(f"Western Union Task completed")
logging.info("Western Union Task completed")


@app.task
def western_union_notify(to_process_ids: List[PaymentRecord]) -> None:
Expand Down

0 comments on commit a802646

Please sign in to comment.