-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2705cf6
commit af0a140
Showing
7 changed files
with
412 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from hope_payment_gateway.apps.gateway.models import FinancialServiceProvider, FinancialServiceProviderConfig | ||
from hope_payment_gateway.apps.gateway.registry import FSPProcessor | ||
|
||
|
||
class WesternUnionHandler(FSPProcessor): | ||
|
||
def get_configuration(self, config_key, delivery_mechanism): | ||
wu = FinancialServiceProvider.objects.get(vision_vendor_number="1900723202") | ||
try: | ||
config = FinancialServiceProviderConfig.objects.get( | ||
key=config_key, fsp=wu, delivery_mechanism__code=delivery_mechanism | ||
).configuration | ||
except FinancialServiceProviderConfig.DoesNotExist: | ||
config = wu.configuration | ||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from rest_framework.response import Response | ||
from rest_framework.status import HTTP_400_BAD_REQUEST | ||
from viewflow.fsm import TransitionNotAllowed | ||
|
||
from hope_payment_gateway.apps.fsp.moneygram.client import MoneyGramClient | ||
from hope_payment_gateway.apps.gateway.flows import PaymentRecordFlow | ||
from hope_payment_gateway.apps.gateway.models import PaymentRecord | ||
|
||
|
||
def quote_transaction(payload): | ||
client = MoneyGramClient() | ||
response = client.quote(payload) | ||
return response | ||
|
||
|
||
def create_transaction(payload): | ||
client = MoneyGramClient() | ||
response = client.create_transaction(payload) | ||
if response: | ||
body = response.json() | ||
record_code = payload["payment_record_code"] | ||
pr = PaymentRecord.objects.get(record_code=record_code) | ||
pr.fsp_code = body["referenceNumber"] | ||
pr.success = True | ||
pr.payout_amount = body["receiveAmount"]["amount"]["value"] | ||
pr.extra_data.update( | ||
{ | ||
"fee": body["receiveAmount"]["fees"]["value"], | ||
"fee_currency": body["receiveAmount"]["fees"]["currencyCode"], | ||
"taxes": body["receiveAmount"]["taxes"]["value"], | ||
"taxes_currency": body["receiveAmount"]["taxes"]["currencyCode"], | ||
"expectedPayoutDate": body["expectedPayoutDate"], | ||
"transactionId": body["transactionId"], | ||
} | ||
) | ||
try: | ||
flow = PaymentRecordFlow(pr) | ||
flow.store() | ||
except TransitionNotAllowed as e: | ||
response = Response({"transition_not_allowed": str(e)}, status=HTTP_400_BAD_REQUEST) | ||
Check warning Code scanning / CodeQL Information exposure through an exception Medium Stack trace information Error loading related location Loading |
||
return response |
Oops, something went wrong.