Skip to content

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

Rename 'transaction_type' to 'kind'

Pacu247df0e3a6d4e
diff --git a/docs/architecture/payments.rst b/docs/architecture/payments.rst
index a3e5f138e5..50e97049b8 100644
--- a/docs/architecture/payments.rst
+++ b/docs/architecture/payments.rst
@@ -77,7 +77,7 @@ Transactions
Transactions represent attempts to transfer money between your store
and your customers, within a chosen payment method.
-There are 5 possible transaction types:
+There are 5 possible transaction kinds:
+---------+-------------------+----------------------------------------------------------------------------------------------------------------------------+
| Code | GraphQL API value | Description |
diff --git a/docs/guides/payments.rst b/docs/guides/payments.rst
index 983b9f88ea..9ac796c2ec 100644
--- a/docs/guides/payments.rst
+++ b/docs/guides/payments.rst
@@ -58,7 +58,7 @@ Example
txn = Transaction.objects.create(
payment=payment,
- transaction_type=TransactionType.AUTH,
+ kind=Transactions.AUTH,
amount=payment.total,
currency=payment.currency,
gateway_response=get_payment_gateway_response(response),
@@ -84,7 +84,7 @@ Example
# Please note that token from the last AUTH transaction should be used
capture_txn = payment.transactions.filter(
- transaction_type=TransactionType.CAPTURE).first()
+ kind=Transactions.CAPTURE).first()
transaction_token = capture_txn.token
# Handle connecting to the gateway and sending the refund request here
@@ -92,7 +92,7 @@ Example
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.REFUND,
+ kind=Transactions.REFUND,
amount=amount,
currency=payment.currency,
token=response.transaction.id,
@@ -117,7 +117,7 @@ Example
# Please note that token from the last AUTH transaction should be used
auth_transaction = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
transaction_token = auth_transaction.token
# Handle connecting to the gateway and sending the capture request here
@@ -125,7 +125,7 @@ Example
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.CAPTURE,
+ kind=Transactions.CAPTURE,
amount=amount,
currency=payment.currency,
token=response.transaction.id,
@@ -149,7 +149,7 @@ Example
# Please note that token from the last AUTH transaction should be used
auth_transaction = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
transaction_token = auth_transaction.token
# Handle connecting to the gateway and sending the void request here
@@ -157,7 +157,7 @@ Example
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.VOID,
+ kind=Transactions.VOID,
amount=payment.total,
currency=payment.currency,
gateway_response=get_payment_gateway_response(response),
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 7326a32f2b..e65d97c21f 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -27,11 +27,7 @@ from ...menu.models import Menu
from ...order.models import Fulfillment, Order
from ...order.utils import update_order_status
from ...page.models import Page
-<<<<<<< HEAD
-from ...payment import ChargeStatus, TransactionType
-=======
-from ...payment import ChargeStatus, TransactionType, get_payment_gateway
->>>>>>> Rename Payment Provider to Payment GAteway, Payment's variant to Payment's gateway
+from ...payment import ChargeStatus, Transactions, get_payment_gateway
from ...payment.models import Payment
from ...payment.utils import get_billing_data
from ...product.models import (
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index d5f11ede2f..a6140115a0 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1899,7 +1899,7 @@ type Transaction implements Node {
created: DateTime!
payment: Payment!
token: String!
- transactionType: TransactionTransactionType!
+ kind: TransactionKind!
isSuccess: Boolean!
currency: String!
amount: Float!
@@ -1917,7 +1917,7 @@ type TransactionCountableEdge {
cursor: String!
}
-enum TransactionTransactionType {
+enum TransactionKind {
AUTH
CAPTURE
REFUND
diff --git a/saleor/order/models.py b/saleor/order/models.py
index a0a597c801..875040de92 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -22,7 +22,7 @@ from ..core.utils.json_serializer import CustomJsonEncoder
from ..core.utils.taxes import ZERO_TAXED_MONEY, zero_money
from ..core.weight import WeightUnits, zero_weight
from ..discount.models import Voucher
-from ..payment import ChargeStatus, TransactionType
+from ..payment import ChargeStatus, Transactions
from ..shipping.models import ShippingMethod
@@ -187,7 +187,7 @@ class Order(models.Model):
# payment gateways in the future.
return self.payments.filter(
is_active=True,
- transactions__transaction_type=TransactionType.AUTH).exists()
+ transactions__kind=Transactions.AUTH).exists()
@property
def quantity_fulfilled(self):
diff --git a/saleor/order/views.py b/saleor/order/views.py
index ce1ad5c9c3..48840693fb 100644
--- a/saleor/order/views.py
+++ b/saleor/order/views.py
@@ -15,7 +15,7 @@ from . import FulfillmentStatus
from ..account.forms import LoginForm
from ..account.models import User
from ..core.utils import get_client_ip
-from ..payment import ChargeStatus, PaymentError, TransactionType, get_payment_gateway
+from ..payment import ChargeStatus, PaymentError, Transactions, get_payment_gateway
from ..payment.forms import get_form_for_payment
from ..payment.models import Payment
from ..payment.utils import get_billing_data
@@ -61,7 +61,7 @@ def payment(request, token):
waiting_payment = payments.filter(
is_active=True,
charge_status=ChargeStatus.NOT_CHARGED,
- transactions__transaction_type=TransactionType.AUTH).first()
+ transactions__kind=Transactions.AUTH).first()
if not waiting_payment:
waiting_payment_form = None
else:
diff --git a/saleor/payment/__init__.py b/saleor/payment/__init__.py
index ed62ddb145..3f74de1191 100644
--- a/saleor/payment/__init__.py
+++ b/saleor/payment/__init__.py
@@ -19,7 +19,7 @@ class CustomPaymentChoices:
(MANUAL, pgettext_lazy('Custom payment choice type', 'Manual'))]
-class TransactionType:
+class Transactions:
"""
- Authorization: An amount reserved against the customer's funding
source. Money does not change hands until the
@@ -38,11 +38,11 @@ class TransactionType:
# FIXME we could use another status like WAITING_FOR_AUTH for transactions
# Which were authorized, but needs to be confirmed manually by staff
# eg. Braintree with "submit_for_settlement" enabled
- CHOICES = [(AUTH, pgettext_lazy('transaction type', 'Authorization')),
- (CHARGE, pgettext_lazy('transaction type', 'Charge')),
- (REFUND, pgettext_lazy('transaction type', 'Refund')),
- (CAPTURE, pgettext_lazy('transaction type', 'Capture')),
- (VOID, pgettext_lazy('transaction type', 'Void'))]
+ CHOICES = [(AUTH, pgettext_lazy('transaction kind', 'Authorization')),
+ (CHARGE, pgettext_lazy('transaction kind', 'Charge')),
+ (REFUND, pgettext_lazy('transaction kind', 'Refund')),
+ (CAPTURE, pgettext_lazy('transaction kind', 'Capture')),
+ (VOID, pgettext_lazy('transaction kind', 'Void'))]
class ChargeStatus:
diff --git a/saleor/payment/forms.py b/saleor/payment/forms.py
index e842a58a33..0c0b6cd340 100644
--- a/saleor/payment/forms.py
+++ b/saleor/payment/forms.py
@@ -3,7 +3,7 @@ from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils.translation import pgettext_lazy
-from . import ChargeStatus, TransactionType, get_payment_gateway
+from . import ChargeStatus, Transactions, get_payment_gateway
from .models import Payment
from .utils import gateway_authorize, gateway_capture, gateway_refund
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.py
index 2354397efb..102213359f 100644
--- a/saleor/payment/gateways/braintree/__init__.py
+++ b/saleor/payment/gateways/braintree/__init__.py
@@ -8,7 +8,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import pgettext_lazy
from prices import Money
-from ... import TransactionType
+from ... import Transactions
from ...models import Payment, Transaction
from ...utils import create_transaction
@@ -71,12 +71,12 @@ def get_error_for_client(errors: List) -> str:
def transaction_and_incorrect_token_error(
payment: Payment,
token: str,
- type: TransactionType,
+ type: Transactions,
amount: Decimal = None) -> Tuple[Transaction, str]:
amount = amount or payment.total
txn = create_transaction(
payment=payment,
- transaction_type=type,
+ kind=type,
currency=payment.currency,
amount=amount,
gateway_response={},
@@ -158,12 +158,12 @@ def authorize(
**get_customer_data(payment)})
except braintree_sdk.exceptions.NotFoundError:
return transaction_and_incorrect_token_error(
- payment, type=TransactionType.AUTH, token=transaction_token)
+ payment, type=Transactions.AUTH, token=transaction_token)
gateway_response = extract_gateway_response(result)
error = get_error_for_client(gateway_response['errors'])
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.AUTH,
+ kind=Transactions.AUTH,
amount=gateway_response.pop('amount', payment.total),
currency=gateway_response.pop('currency', payment.currency),
gateway_response=gateway_response,
@@ -178,14 +178,14 @@ def capture(
**connection_params: Dict) -> Tuple[Transaction, str]:
gateway = get_braintree_gateway(**connection_params)
auth_transaction = payment.transactions.filter(
- transaction_type=TransactionType.AUTH, is_success=True).first()
+ kind=Transactions.AUTH, is_success=True).first()
try:
result = gateway.transaction.submit_for_settlement(
transaction_id=auth_transaction.token, amount=str(amount))
except braintree_sdk.exceptions.NotFoundError:
return transaction_and_incorrect_token_error(
payment,
- type=TransactionType.CAPTURE,
+ type=Transactions.CAPTURE,
token=auth_transaction.token,
amount=amount)
@@ -194,7 +194,7 @@ def capture(
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.CAPTURE,
+ kind=Transactions.CAPTURE,
amount=gateway_response.pop('amount', amount),
currency=gateway_response.pop('currency', payment.currency),
token=getattr(result.transaction, 'id', ''),
@@ -208,19 +208,19 @@ def void(
**connection_params: Dict) -> Tuple[Transaction, str]:
gateway = get_braintree_gateway(**connection_params)
auth_transaction = payment.transactions.filter(
- transaction_type=TransactionType.AUTH, is_success=True).first()
+ kind=Transactions.AUTH, is_success=True).first()
try:
result = gateway.transaction.void(
transaction_id=auth_transaction.token)
except braintree_sdk.exceptions.NotFoundError:
return transaction_and_incorrect_token_error(
- payment, type=TransactionType.VOID, token=auth_transaction.token)
+ payment, type=Transactions.VOID, token=auth_transaction.token)
gateway_response = extract_gateway_response(result)
error = get_error_for_client(gateway_response['errors'])
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.VOID,
+ kind=Transactions.VOID,
amount=gateway_response.pop('amount', payment.total),
currency=gateway_response.pop('currency', payment.currency),
gateway_response=gateway_response,
@@ -235,21 +235,21 @@ def refund(
**connection_params: Dict) -> Tuple[Transaction, str]:
gateway = get_braintree_gateway(**connection_params)
capture_txn = payment.transactions.filter(
- transaction_type=TransactionType.CAPTURE, is_success=True).first()
+ kind=Transactions.CAPTURE, is_success=True).first()
try:
result = gateway.transaction.refund(
transaction_id=capture_txn.token,
amount_or_options=str(amount))
except braintree_sdk.exceptions.NotFoundError:
return transaction_and_incorrect_token_error(
- payment, type=TransactionType.REFUND, token=capture_txn.token,
+ payment, type=Transactions.REFUND, token=capture_txn.token,
amount=amount)
gateway_response = extract_gateway_response(result)
error = get_error_for_client(gateway_response['errors'])
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.REFUND,
+ kind=Transactions.REFUND,
amount=gateway_response.pop('amount', amount),
currency=gateway_response.pop('currency', payment.currency),
token=getattr(result.transaction, 'id', ''),
diff --git a/saleor/payment/gateways/dummy/__init__.py b/saleor/payment/gateways/dummy/__init__.py
index 33fd1b6b50..5aa49fc427 100644
--- a/saleor/payment/gateways/dummy/__init__.py
+++ b/saleor/payment/gateways/dummy/__init__.py
@@ -5,7 +5,7 @@ from typing import Dict
from django.conf import settings
from prices import Money
-from ... import TransactionType
+from ... import Transactions
from ...models import Payment
from ...utils import create_transaction
@@ -25,7 +25,7 @@ def authorize(payment: Payment, transaction_token: str, **connection_params):
error = 'Unable to authorize transaction'
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.AUTH,
+ kind=Transactions.AUTH,
amount=payment.total,
currency=payment.currency,
gateway_response={},
@@ -41,7 +41,7 @@ def void(payment: Payment, **connection_params: Dict):
error = 'Unable to void transaction'
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.VOID,
+ kind=Transactions.VOID,
amount=payment.total,
currency=payment.currency,
gateway_response={},
@@ -57,7 +57,7 @@ def capture(payment: Payment, amount: Decimal):
error = 'Unable to process capture'
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.CAPTURE,
+ kind=Transactions.CAPTURE,
amount=amount,
currency=payment.currency,
token=str(uuid.uuid4()),
@@ -72,7 +72,7 @@ def refund(payment: Payment, amount: Decimal):
error = 'Unable to process refund'
txn = create_transaction(
payment=payment,
- transaction_type=TransactionType.REFUND,
+ kind=Transactions.REFUND,
amount=amount,
currency=payment.currency,
token=str(uuid.uuid4()),
diff --git a/saleor/payment/migrations/0001_initial.py b/saleor/payment/migrations/0001_initial.py
index f5492d157c..cfd7507572 100644
--- a/saleor/payment/migrations/0001_initial.py
+++ b/saleor/payment/migrations/0001_initial.py
@@ -53,7 +53,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True)),
('token', models.CharField(blank=True, default='', max_length=64)),
- ('transaction_type', models.CharField(choices=[('auth', 'Authorization'), ('capture', 'Charge'), ('refund', 'Refund'), ('capture', 'Capture'), ('void', 'Void')], max_length=10)),
+ ('kind', models.CharField(choices=[('auth', 'Authorization'), ('capture', 'Charge'), ('refund', 'Refund'), ('capture', 'Capture'), ('void', 'Void')], max_length=10)),
('is_success', models.BooleanField(default=False)),
('currency', models.CharField(max_length=10)),
('amount', models.DecimalField(decimal_places=2, default=Decimal('0.0'), max_digits=12)),
diff --git a/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py b/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
index 33370cbf77..b343cec6f7 100644
--- a/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
+++ b/saleor/payment/migrations/0002_transfer_payment_to_payment_method.py
@@ -3,7 +3,7 @@ from django.db import migrations
from prices import Money
from django.conf import settings
-from .. import ChargeStatus, TransactionType
+from .. import ChargeStatus, Transactions
from ..models import Transaction
class PaymentStatus:
@@ -39,10 +39,10 @@ def get_is_active(status, payment):
return True
-def create_transaction(method, transaction_type, created, amount, is_success):
+def create_transaction(method, kind, created, amount, is_success):
return method.transactions.create(
created=created,
- transaction_type=transaction_type,
+ kind=kind,
is_success=is_success,
amount=amount,
gateway_response={})
@@ -56,27 +56,27 @@ def create_transactions(method, payment):
# Other payments needed to be authorized first
created = payment.created
create_transaction(
- method=method, transaction_type=TransactionType.AUTH,
+ method=method, kind=Transactions.AUTH,
created=created, amount=payment.total, currency=payment.currency,
is_success=True, token=payment.transaction_id)
# This kind of payment needs an unsuccessful capture transaction
if payment.status in [PaymentStatus.ERROR, PaymentStatus.REJECTED]:
create_transaction(
- method=method, transaction_type=TransactionType.CAPTURE,
+ method=method, kind=Transactions.CAPTURE,
created=created, amount=payment.total, currency=payment.currency,
is_success=False, token=payment.transaction_id)
return
# Two other payments left - CONFIRMED and REFUNDED needs to be captured
create_transaction(
- method=method, transaction_type=TransactionType.CAPTURE,
+ method=method, kind=Transactions.CAPTURE,
created=created, amount=payment.total, currency=payment.currency,
is_success=True, token=payment.transaction_id)
# If payment was refunded, we need to create a refund transaction for it
if payment.status == PaymentStatus.REFUNDED:
create_transaction(
- method=method, transaction_type=TransactionType.REFUND,
+ method=method, kind=Transactions.REFUND,
created=created, amount=payment.total, currency=payment.currency,
is_success=True, token=payment.transaction_id)
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index 4b72a47f2a..a068274019 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -7,7 +7,7 @@ from django.db import models
from django_prices.models import MoneyField
from prices import Money
-from . import ChargeStatus, CustomPaymentChoices, TransactionType
+from . import ChargeStatus, CustomPaymentChoices, Transactions
from ..checkout.models import Cart
from ..core.utils.taxes import zero_money
from ..order.models import Order
@@ -89,7 +89,7 @@ class Payment(models.Model):
def get_auth_transaction(self):
txn = self.transactions.get(
- transaction_type=TransactionType.AUTH, is_success=True)
+ kind=Transactions.AUTH, is_success=True)
return txn
def authorize(self, transaction_token):
@@ -138,8 +138,8 @@ class Transaction(models.Model):
payment = models.ForeignKey(
Payment, related_name='transactions', on_delete=models.PROTECT)
token = models.CharField(max_length=64, blank=True, default='')
- transaction_type = models.CharField(
- max_length=10, choices=TransactionType.CHOICES)
+ kind = models.CharField(
+ max_length=10, choices=Transactions.CHOICES)
# FIXME probably we should have error/pending/success status instead of
# a bool, eg for payments with 3d secure
is_success = models.BooleanField(default=False)
@@ -156,4 +156,4 @@ class Transaction(models.Model):
def __repr__(self):
return 'Transaction(created=%s, type=%s, is_success=%s)' % (
- self.created, self.transaction_type, self.is_success)
+ self.created, self.kind, self.is_success)
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index 71c9e12120..85c9f09c58 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -83,7 +83,7 @@ def create_payment(**payment_data):
def create_transaction(
payment: Payment,
token: str,
- transaction_type: str,
+ kind: str,
is_success: bool,
amount: Decimal,
currency: str,
@@ -93,7 +93,7 @@ def create_transaction(
txn, _ = Transaction.objects.get_or_create(
payment=payment,
token=token,
- transaction_type=transaction_type,
+ kind=kind,
is_success=is_success,
amount=amount,
currency=currency,
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.py
index acb3cd606c..d02d454944 100644
--- a/tests/api/test_checkout.py
+++ b/tests/api/test_checkout.py
@@ -7,7 +7,7 @@ from tests.api.utils import get_graphql_content
from saleor.checkout.models import Cart
from saleor.order.models import Order
-from saleor.payment import TransactionType
+from saleor.payment import Transactions
def test_checkout_create(user_api_client, variant, graphql_address_data):
diff --git a/tests/api/test_payment.py b/tests/api/test_payment.py
index 2e30382bb2..4513f010c2 100644
--- a/tests/api/test_payment.py
+++ b/tests/api/test_payment.py
@@ -2,7 +2,7 @@ import graphene
from tests.api.utils import get_graphql_content
from saleor.payment.models import (
- ChargeStatus, Payment, Transaction, TransactionType)
+ ChargeStatus, Payment, Transaction, Transactions)
VOID_QUERY = """
mutation PaymentVoid($paymentId: ID!) {
@@ -35,7 +35,7 @@ def test_payment_void_success(
assert payment_dummy.is_active == False
assert payment_dummy.transactions.count() == 1
txn = payment_dummy.transactions.first()
- assert txn.transaction_type == TransactionType.VOID
+ assert txn.kind == Transactions.VOID
def test_payment_charge_gateway_error(
@@ -60,7 +60,7 @@ def test_payment_charge_gateway_error(
assert payment_dummy.is_active == True
assert payment_dummy.transactions.count() == 1
txn = payment_dummy.transactions.first()
- assert txn.transaction_type == TransactionType.VOID
+ assert txn.kind == Transactions.VOID
assert not txn.is_success
@@ -71,7 +71,7 @@ CREATE_QUERY = """
transactions(first: 1) {
edges {
node {
- transactionType,
+ kind,
token
}
}
@@ -152,7 +152,7 @@ def test_payment_charge_success(
assert payment.charge_status == ChargeStatus.CHARGED
assert payment.transactions.count() == 1
txn = payment.transactions.first()
- assert txn.transaction_type == TransactionType.CHARGE
+ assert txn.kind == Transactions.CHARGE
def test_payment_charge_gateway_error(
@@ -179,7 +179,7 @@ def test_payment_charge_gateway_error(
assert payment.charge_status == ChargeStatus.NOT_CHARGED
assert payment.transactions.count() == 1
txn = payment.transactions.first()
- assert txn.transaction_type == TransactionType.CHARGE
+ assert txn.kind == Transactions.CHARGE
assert not txn.is_success
@@ -220,7 +220,7 @@ def test_payment_refund_success(
assert payment.charge_status == ChargeStatus.FULLY_REFUNDED
assert payment.transactions.count() == 1
txn = payment.transactions.first()
- assert txn.transaction_type == TransactionType.REFUND
+ assert txn.kind == Transactions.REFUND
def test_payment_refund_error(
@@ -249,7 +249,7 @@ def test_payment_refund_error(
assert payment.charge_status == ChargeStatus.CHARGED
assert payment.transactions.count() == 1
txn = payment.transactions.first()
- assert txn.transaction_type == TransactionType.REFUND
+ assert txn.kind == Transactions.REFUND
assert not txn.is_success
diff --git a/tests/conftest.py b/tests/conftest.py
index d08d3b6dbe..de808bf2b2 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -28,7 +28,7 @@ from saleor.order import OrderStatus, OrderEvents
from saleor.order.models import Order, OrderEvent
from saleor.order.utils import recalculate_order
from saleor.page.models import Page
-from saleor.payment import ChargeStatus, TransactionType
+from saleor.payment import ChargeStatus, Transactions
from saleor.payment.models import Payment
from saleor.product.models import (
Attribute, AttributeTranslation, AttributeValue, Category, Collection,
@@ -476,7 +476,7 @@ def payment_txn_preauth(order_with_lines, payment_dummy):
payment.transactions.create(
amount=payment.total,
- transaction_type=TransactionType.AUTH,
+ kind=Transactions.AUTH,
gateway_response={},
is_success=True)
return payment
@@ -493,7 +493,7 @@ def payment_txn_captured(order_with_lines, payment_dummy):
payment.transactions.create(
amount=payment.total,
- transaction_type=TransactionType.CAPTURE,
+ kind=Transactions.CAPTURE,
gateway_response={},
is_success=True)
return payment
@@ -510,7 +510,7 @@ def payment_txn_refunded(order_with_lines, payment_dummy):
payment.transactions.create(
amount=payment.total,
- transaction_type=TransactionType.REFUND,
+ kind=Transactions.REFUND,
gateway_response={},
is_success=True)
return payment
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
index 8ed7aaa9aa..27f4cd01d2 100644
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -18,7 +18,7 @@ from saleor.order import (
FulfillmentStatus, OrderEvents, OrderEventsEmails, OrderStatus)
from saleor.order.models import Order, OrderEvent, OrderLine
from saleor.order.utils import add_variant_to_order, change_order_line_quantity
-from saleor.payment import ChargeStatus, TransactionType
+from saleor.payment import ChargeStatus, Transactions
from saleor.product.models import ProductVariant
from saleor.shipping.models import ShippingZone
@@ -211,7 +211,7 @@ def test_view_void_order_payment_preauth(
assert order_payment.charge_status == ChargeStatus.NOT_CHARGED
last_transaction = order_payment.transactions.latest('pk')
- assert last_transaction.transaction_type == TransactionType.VOID
+ assert last_transaction.kind == Transactions.VOID
assert order_payment.captured_amount == Decimal('0.00')
diff --git a/tests/test_order.py b/tests/test_order.py
index 5a1cba5dbe..cadcf900a6 100644
--- a/tests/test_order.py
+++ b/tests/test_order.py
@@ -478,7 +478,7 @@ def test_order_payment_flow(
assert payment.total == order.total.gross.amount
assert payment.currency == order.total.gross.currency
assert payment.transactions.count() == 1
- assert payment.transactions.first().transaction_type == 'auth'
+ assert payment.transactions.first().kind == 'auth'
def test_create_user_after_order(order, client):
diff --git a/tests/test_payment.py b/tests/test_payment.py
index 1d7c597808..56600cbf6b 100644
--- a/tests/test_payment.py
+++ b/tests/test_payment.py
@@ -7,7 +7,7 @@ from prices import Money
from saleor.order import OrderEvents, OrderEventsEmails
from saleor.payment import (
- ChargeStatus, PaymentError, TransactionType, get_payment_gateway)
+ ChargeStatus, PaymentError, Transactions, get_payment_gateway)
from saleor.payment.utils import (
create_payment, create_transaction, gateway_authorize, gateway_capture,
gateway_get_transaction_token, gateway_refund, gateway_void,
@@ -22,7 +22,7 @@ def transaction_data(payment_dummy, settings):
return {
'payment': payment_dummy,
'token': 'token',
- 'transaction_type': TransactionType.CAPTURE,
+ 'kind': Transactions.CAPTURE,
'is_success': True,
'amount': Decimal('10.00'),
'currency': settings.DEFAULT_CURRENCY,
@@ -135,7 +135,7 @@ def test_create_transaction(transaction_data):
assert txn.payment == transaction_data['payment']
assert txn.token == transaction_data['token']
- assert txn.transaction_type == transaction_data['transaction_type']
+ assert txn.kind == transaction_data['kind']
assert txn.is_success == transaction_data['is_success']
assert txn.amount == transaction_data['amount']
assert txn.gateway_response == transaction_data['gateway_response']
diff --git a/tests/test_payment_braintree.py b/tests/test_payment_braintree.py
index 01eb28eaa6..b7995c962e 100644
--- a/tests/test_payment_braintree.py
+++ b/tests/test_payment_braintree.py
@@ -10,7 +10,7 @@ from braintree.validation_error import ValidationError
from django.core.exceptions import ImproperlyConfigured
from prices import Money
-from saleor.payment import TransactionType
+from saleor.payment import Transactions
from saleor.payment.gateways.braintree import (
CONFIRM_MANUALLY, THREE_D_SECURE_REQUIRED, authorize, capture,
extract_gateway_response, get_transaction_token, get_customer_data,
@@ -232,7 +232,7 @@ def test_authorize_incorrect_token(
result = authorize(payment, token)
assert result == expected_result
mock_transaction.assert_called_once_with(
- payment, type=TransactionType.AUTH, token=token)
+ payment, type=Transactions.AUTH, token=token)
@pytest.mark.integration
@@ -246,7 +246,7 @@ def test_authorize(
assert not error
assert txn.payment == payment
- assert txn.transaction_type == TransactionType.AUTH
+ assert txn.kind == Transactions.AUTH
assert txn.amount == braintree_success_response.transaction.amount
assert txn.currency == braintree_success_response.transaction.currency_iso_code
assert txn.gateway_response == success_gateway_response(
@@ -277,7 +277,7 @@ def test_refund(
assert not error
assert txn.payment == payment
- assert txn.transaction_type == TransactionType.REFUND
+ assert txn.kind == Transactions.REFUND
assert txn.amount == braintree_success_response.transaction.amount
assert txn.currency == braintree_success_response.transaction.currency_iso_code
assert txn.gateway_response == success_gateway_response(
@@ -286,7 +286,7 @@ def test_refund(
assert txn.is_success == braintree_success_response.is_success
capture_txn = payment.transactions.filter(
- transaction_type=TransactionType.CAPTURE).first()
+ kind=Transactions.CAPTURE).first()
mock_response.assert_called_once_with(
amount_or_options=str(amount), transaction_id=capture_txn.token)
@@ -306,9 +306,9 @@ def test_refund_incorrect_token(
result = refund(payment, amount)
assert result == expected_result
capture_txn = payment.transactions.filter(
- transaction_type=TransactionType.CAPTURE).first()
+ kind=Transactions.CAPTURE).first()
mock_transaction.assert_called_once_with(
- payment, type=TransactionType.REFUND, token=capture_txn.token,
+ payment, type=Transactions.REFUND, token=capture_txn.token,
amount=amount)
@@ -345,7 +345,7 @@ def test_capture(
assert not error
assert txn.payment == payment
- assert txn.transaction_type == TransactionType.CAPTURE
+ assert txn.kind == Transactions.CAPTURE
assert txn.amount == braintree_success_response.transaction.amount
assert txn.currency == braintree_success_response.transaction.currency_iso_code
assert txn.gateway_response == success_gateway_response(
@@ -354,7 +354,7 @@ def test_capture(
assert txn.is_success == braintree_success_response.is_success
auth_txn = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
mock_response.assert_called_once_with(
amount=str(amount), transaction_id=auth_txn.token)
@@ -376,9 +376,9 @@ def test_capture_incorrect_token(
result = capture(payment, amount)
assert result == expected_result
auth_txn = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
mock_transaction.assert_called_once_with(
- payment, type=TransactionType.CAPTURE, token=auth_txn.token,
+ payment, type=Transactions.CAPTURE, token=auth_txn.token,
amount=amount)
@@ -413,7 +413,7 @@ def test_void(
assert not error
assert txn.payment == payment
- assert txn.transaction_type == TransactionType.VOID
+ assert txn.kind == Transactions.VOID
assert txn.amount == braintree_success_response.transaction.amount
assert txn.currency == braintree_success_response.transaction.currency_iso_code
assert txn.gateway_response == success_gateway_response(
@@ -422,7 +422,7 @@ def test_void(
assert txn.is_success == braintree_success_response.is_success
auth_txn = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
mock_response.assert_called_once_with(transaction_id=auth_txn.token)
@@ -440,9 +440,9 @@ def test_void_incorrect_token(
result = void(payment)
assert result == expected_result
auth_txn = payment.transactions.filter(
- transaction_type=TransactionType.AUTH).first()
+ kind=Transactions.AUTH).first()
mock_transaction.assert_called_once_with(
- payment, type=TransactionType.VOID, token=auth_txn.token)
+ payment, type=Transactions.VOID, token=auth_txn.token)
@pytest.mark.integration
@@ -465,10 +465,10 @@ def test_void_error_response(
def test_transaction_and_incorrect_token_error_helper(payment_dummy, settings):
amount = Decimal('10.00')
txn, error = transaction_and_incorrect_token_error(
- payment_dummy, 'example-token', TransactionType.AUTH, amount=amount)
+ payment_dummy, 'example-token', Transactions.AUTH, amount=amount)
assert error == INCORRECT_TOKEN_ERROR
assert not txn.is_success
- assert txn.transaction_type == TransactionType.AUTH
+ assert txn.kind == Transactions.AUTH
assert txn.token == 'example-token'
assert not txn.gateway_response
assert txn.amount == amount
@@ -477,5 +477,5 @@ def test_transaction_and_incorrect_token_error_helper(payment_dummy, settings):
def test_transaction_and_incorrect_token_error_helper_no_amount(payment_dummy):
txn, error = transaction_and_incorrect_token_error(
- payment_dummy, 'example-token', TransactionType.AUTH)
+ payment_dummy, 'example-token', Transactions.AUTH)
assert txn.amount == payment_dummy.total
diff --git a/tests/test_payment_dummy.py b/tests/test_payment_dummy.py
index 9ca4d4b882..177adde67c 100644
--- a/tests/test_payment_dummy.py
+++ b/tests/test_payment_dummy.py
@@ -2,13 +2,13 @@ from decimal import Decimal
import pytest
-from saleor.payment import ChargeStatus, PaymentError, TransactionType
+from saleor.payment import ChargeStatus, PaymentError, Transactions
def test_authorize(payment_dummy):
txn = payment_dummy.authorize(transaction_token='Fake')
assert txn.is_success
- assert txn.transaction_type == TransactionType.AUTH
+ assert txn.kind == Transactions.AUTH
assert txn.payment == payment_dummy
payment_dummy.refresh_from_db()
assert payment_dummy.is_active
@@ -19,7 +19,7 @@ def test_authorize_gateway_error(payment_dummy, monkeypatch):
'saleor.payment.gateways.dummy.dummy_success', lambda: False)
with pytest.raises(PaymentError):
txn = payment_dummy.authorize(transaction_token='Fake')
- assert txn.transaction_type == TransactionType.AUTH
+ assert txn.kind == Transactions.AUTH
assert not txn.is_success
assert txn.payment == payment_dummy
@@ -29,7 +29,7 @@ def test_void_success(payment_dummy):
assert payment_dummy.charge_status == ChargeStatus.NOT_CHARGED
txn = payment_dummy.void()
assert txn.is_success
- assert txn.transaction_type == TransactionType.VOID
+ assert txn.kind == Transactions.VOID
assert txn.payment == payment_dummy
payment_dummy.refresh_from_db()
assert not payment_dummy.is_active
@@ -57,7 +57,7 @@ def test_void_gateway_error(payment_dummy, monkeypatch):
'saleor.payment.gateways.dummy.dummy_success', lambda: False)
with pytest.raises(PaymentError):
txn = payment_dummy.void()
- assert txn.transaction_type == TransactionType.VOID
+ assert txn.kind == Transactions.VOID
assert not txn.is_success
assert txn.payment == payment_dummy
@@ -96,7 +96,7 @@ def test_charge_gateway_error(payment_dummy, monkeypatch):
'saleor.payment.gateways.dummy.dummy_success', lambda: False)
with pytest.raises(PaymentError):
txn = payment_dummy.capture(80)
- assert txn.transaction_type == TransactionType.CHARGE
+ assert txn.kind == Transactions.CHARGE
assert not txn.is_success
assert txn.payment == payment_dummy
@@ -114,7 +114,7 @@ def test_refund_success(
payment.captured_amount = initial_captured_amount
payment.save()
txn = payment.refund(refund_amount)
- assert txn.transaction_type == TransactionType.REFUND
+ assert txn.kind == Transactions.REFUND
assert txn.is_success
assert txn.payment == payment
assert payment.charge_status == final_charge_status
@@ -151,7 +151,7 @@ def test_refund_gateway_error(payment_dummy, monkeypatch):
payment.refresh_from_db()
txn = payment.transactions.first()
- assert txn.transaction_type == TransactionType.REFUND
+ assert txn.kind == Transactions.REFUND
assert not txn.is_success
assert txn.payment == payment
assert payment.charge_status == ChargeStatus.CHARGED