Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add missing currency in action for transaction requests

AjmalPonneth56a19fc94f4c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3565acbe5..dc29ef6d18 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ in 3.17. Use `PaymentSettings.defaultTransactionFlowStrategy` instead.
### Other changes
- Fix error in variant available stock calculation - 13593 by @awaisdar001
+- Add missing currency in action for transaction requests - 13786 by @AjmalPonneth
# 3.15.0 [Unreleased]
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index ea66941b3c..448d89cd2a 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -32724,6 +32724,9 @@ type TransactionAction @doc(category: "Payments") {
"""Transaction request amount. Null when action type is VOID."""
amount: PositiveDecimal
+
+ """Currency code."""
+ currency: String
}
"""
diff --git a/saleor/graphql/webhook/subscription_types.py b/saleor/graphql/webhook/subscription_types.py
index c6bae03da0..3221b14b46 100644
--- a/saleor/graphql/webhook/subscription_types.py
+++ b/saleor/graphql/webhook/subscription_types.py
@@ -1599,6 +1599,7 @@ class TransactionAction(SubscriptionObjectType, AbstractType):
amount = PositiveDecimal(
description="Transaction request amount. Null when action type is VOID.",
)
+ currency = graphene.String(description="Currency code.")
class Meta:
doc_category = DOC_CATEGORY_PAYMENTS
@@ -1609,6 +1610,10 @@ class TransactionAction(SubscriptionObjectType, AbstractType):
return quantize_price(root.action_value, root.transaction.currency)
return None
+ @staticmethod
+ def resolve_currency(root: TransactionActionData, _info: ResolveInfo):
+ return root.transaction.currency
+
class TransactionActionBase(AbstractType):
transaction = graphene.Field(
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
index b75760de26..f94296af8c 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
@@ -25,6 +25,7 @@ subscription {
action {
actionType
amount
+ currency
}
}
}
@@ -93,5 +94,5 @@ def test_transaction_cancel_request(order, webhook_app, permission_manage_paymen
"pspReference": "PSP ref",
"order": {"id": graphene.Node.to_global_id("Order", order.id)},
},
- "action": {"actionType": "CANCEL", "amount": None},
+ "action": {"actionType": "CANCEL", "amount": None, "currency": "USD"},
}
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
index 07ef57b81a..13436c2d81 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_charge_requested.py
@@ -25,6 +25,7 @@ subscription {
action {
actionType
amount
+ currency
}
}
}
@@ -98,5 +99,6 @@ def test_transaction_charge_request(order, webhook_app, permission_manage_paymen
"action": {
"actionType": "CHARGE",
"amount": quantize_price(action_value, "USD"),
+ "currency": "USD",
},
}
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
index ff1e491cca..c83841f87b 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_refund_requested.py
@@ -25,6 +25,7 @@ subscription {
action {
actionType
amount
+ currency
}
}
}
@@ -60,6 +61,7 @@ subscription {
action {
actionType
amount
+ currency
}
}
}
@@ -133,6 +135,7 @@ def test_transaction_refund_request(order, webhook_app, permission_manage_paymen
"action": {
"actionType": "REFUND",
"amount": quantize_price(action_value, "USD"),
+ "currency": "USD",
},
}
@@ -231,5 +234,6 @@ def test_transaction_refund_request_with_granted_refund(
"action": {
"actionType": "REFUND",
"amount": 12.3,
+ "currency": "USD",
},
}