Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename 'transaction_type' to 'kind'
Pacu247df0e3a6d4e
diff --git a/docs/architecture/payments.rst b/docs/architecture/payments.rstindex a3e5f138e5..50e97049b8 100644--- a/docs/architecture/payments.rst+++ b/docs/architecture/payments.rst@@ -77,7 +77,7 @@ TransactionsTransactions represent attempts to transfer money between your storeand 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.rstindex 983b9f88ea..9ac796c2ec 100644--- a/docs/guides/payments.rst+++ b/docs/guides/payments.rst@@ -58,7 +58,7 @@ Exampletxn = 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 usedcapture_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 @@ Exampletxn = 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 usedauth_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 @@ Exampletxn = 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 usedauth_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 @@ Exampletxn = 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.pyindex 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 Menufrom ...order.models import Fulfillment, Orderfrom ...order.utils import update_order_statusfrom ...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_gatewayfrom ...payment.models import Paymentfrom ...payment.utils import get_billing_datafrom ...product.models import (diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 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 {AUTHCAPTUREREFUNDdiff --git a/saleor/order/models.py b/saleor/order/models.pyindex a0a597c801..875040de92 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -22,7 +22,7 @@ from ..core.utils.json_serializer import CustomJsonEncoderfrom ..core.utils.taxes import ZERO_TAXED_MONEY, zero_moneyfrom ..core.weight import WeightUnits, zero_weightfrom ..discount.models import Voucher-from ..payment import ChargeStatus, TransactionType+from ..payment import ChargeStatus, Transactionsfrom ..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()@propertydef quantity_fulfilled(self):diff --git a/saleor/order/views.py b/saleor/order/views.pyindex ce1ad5c9c3..48840693fb 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -15,7 +15,7 @@ from . import FulfillmentStatusfrom ..account.forms import LoginFormfrom ..account.models import Userfrom ..core.utils import get_client_ip-from ..payment import ChargeStatus, PaymentError, TransactionType, get_payment_gateway+from ..payment import ChargeStatus, PaymentError, Transactions, get_payment_gatewayfrom ..payment.forms import get_form_for_paymentfrom ..payment.models import Paymentfrom ..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 = Noneelse:diff --git a/saleor/payment/__init__.py b/saleor/payment/__init__.pyindex 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 fundingsource. 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.pyindex e842a58a33..0c0b6cd340 100644--- a/saleor/payment/forms.py+++ b/saleor/payment/forms.py@@ -3,7 +3,7 @@ from django.conf import settingsfrom django.core.exceptions import ValidationErrorfrom django.utils.translation import pgettext_lazy-from . import ChargeStatus, TransactionType, get_payment_gateway+from . import ChargeStatus, Transactions, get_payment_gatewayfrom .models import Paymentfrom .utils import gateway_authorize, gateway_capture, gateway_refunddiff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.pyindex 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 ImproperlyConfiguredfrom django.utils.translation import pgettext_lazyfrom prices import Money-from ... import TransactionType+from ... import Transactionsfrom ...models import Payment, Transactionfrom ...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.totaltxn = 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__.pyindex 33fd1b6b50..5aa49fc427 100644--- a/saleor/payment/gateways/dummy/__init__.py+++ b/saleor/payment/gateways/dummy/__init__.py@@ -5,7 +5,7 @@ from typing import Dictfrom django.conf import settingsfrom prices import Money-from ... import TransactionType+from ... import Transactionsfrom ...models import Paymentfrom ...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.pyindex 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.pyindex 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 migrationsfrom prices import Moneyfrom django.conf import settings-from .. import ChargeStatus, TransactionType+from .. import ChargeStatus, Transactionsfrom ..models import Transactionclass 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 firstcreated = payment.createdcreate_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 transactionif 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 capturedcreate_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 itif 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.pyindex 4b72a47f2a..a068274019 100644--- a/saleor/payment/models.py+++ b/saleor/payment/models.py@@ -7,7 +7,7 @@ from django.db import modelsfrom django_prices.models import MoneyFieldfrom prices import Money-from . import ChargeStatus, CustomPaymentChoices, TransactionType+from . import ChargeStatus, CustomPaymentChoices, Transactionsfrom ..checkout.models import Cartfrom ..core.utils.taxes import zero_moneyfrom ..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 txndef 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 secureis_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.pyindex 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.pyindex 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_contentfrom saleor.checkout.models import Cartfrom saleor.order.models import Order-from saleor.payment import TransactionType+from saleor.payment import Transactionsdef test_checkout_create(user_api_client, variant, graphql_address_data):diff --git a/tests/api/test_payment.py b/tests/api/test_payment.pyindex 2e30382bb2..4513f010c2 100644--- a/tests/api/test_payment.py+++ b/tests/api/test_payment.py@@ -2,7 +2,7 @@ import graphenefrom tests.api.utils import get_graphql_contentfrom 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 == Falseassert payment_dummy.transactions.count() == 1txn = payment_dummy.transactions.first()- assert txn.transaction_type == TransactionType.VOID+ assert txn.kind == Transactions.VOIDdef test_payment_charge_gateway_error(@@ -60,7 +60,7 @@ def test_payment_charge_gateway_error(assert payment_dummy.is_active == Trueassert payment_dummy.transactions.count() == 1txn = payment_dummy.transactions.first()- assert txn.transaction_type == TransactionType.VOID+ assert txn.kind == Transactions.VOIDassert 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.CHARGEDassert payment.transactions.count() == 1txn = payment.transactions.first()- assert txn.transaction_type == TransactionType.CHARGE+ assert txn.kind == Transactions.CHARGEdef test_payment_charge_gateway_error(@@ -179,7 +179,7 @@ def test_payment_charge_gateway_error(assert payment.charge_status == ChargeStatus.NOT_CHARGEDassert payment.transactions.count() == 1txn = payment.transactions.first()- assert txn.transaction_type == TransactionType.CHARGE+ assert txn.kind == Transactions.CHARGEassert not txn.is_success@@ -220,7 +220,7 @@ def test_payment_refund_success(assert payment.charge_status == ChargeStatus.FULLY_REFUNDEDassert payment.transactions.count() == 1txn = payment.transactions.first()- assert txn.transaction_type == TransactionType.REFUND+ assert txn.kind == Transactions.REFUNDdef test_payment_refund_error(@@ -249,7 +249,7 @@ def test_payment_refund_error(assert payment.charge_status == ChargeStatus.CHARGEDassert payment.transactions.count() == 1txn = payment.transactions.first()- assert txn.transaction_type == TransactionType.REFUND+ assert txn.kind == Transactions.REFUNDassert not txn.is_successdiff --git a/tests/conftest.py b/tests/conftest.pyindex d08d3b6dbe..de808bf2b2 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -28,7 +28,7 @@ from saleor.order import OrderStatus, OrderEventsfrom saleor.order.models import Order, OrderEventfrom saleor.order.utils import recalculate_orderfrom saleor.page.models import Page-from saleor.payment import ChargeStatus, TransactionType+from saleor.payment import ChargeStatus, Transactionsfrom saleor.payment.models import Paymentfrom 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 paymentdiff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 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, OrderLinefrom saleor.order.utils import add_variant_to_order, change_order_line_quantity-from saleor.payment import ChargeStatus, TransactionType+from saleor.payment import ChargeStatus, Transactionsfrom saleor.product.models import ProductVariantfrom saleor.shipping.models import ShippingZone@@ -211,7 +211,7 @@ def test_view_void_order_payment_preauth(assert order_payment.charge_status == ChargeStatus.NOT_CHARGEDlast_transaction = order_payment.transactions.latest('pk')- assert last_transaction.transaction_type == TransactionType.VOID+ assert last_transaction.kind == Transactions.VOIDassert order_payment.captured_amount == Decimal('0.00')diff --git a/tests/test_order.py b/tests/test_order.pyindex 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.amountassert payment.currency == order.total.gross.currencyassert 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.pyindex 1d7c597808..56600cbf6b 100644--- a/tests/test_payment.py+++ b/tests/test_payment.py@@ -7,7 +7,7 @@ from prices import Moneyfrom saleor.order import OrderEvents, OrderEventsEmailsfrom 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.pyindex 01eb28eaa6..b7995c962e 100644--- a/tests/test_payment_braintree.py+++ b/tests/test_payment_braintree.py@@ -10,7 +10,7 @@ from braintree.validation_error import ValidationErrorfrom django.core.exceptions import ImproperlyConfiguredfrom prices import Money-from saleor.payment import TransactionType+from saleor.payment import Transactionsfrom 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_resultmock_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 errorassert txn.payment == payment- assert txn.transaction_type == TransactionType.AUTH+ assert txn.kind == Transactions.AUTHassert txn.amount == braintree_success_response.transaction.amountassert txn.currency == braintree_success_response.transaction.currency_iso_codeassert txn.gateway_response == success_gateway_response(@@ -277,7 +277,7 @@ def test_refund(assert not errorassert txn.payment == payment- assert txn.transaction_type == TransactionType.REFUND+ assert txn.kind == Transactions.REFUNDassert txn.amount == braintree_success_response.transaction.amountassert txn.currency == braintree_success_response.transaction.currency_iso_codeassert txn.gateway_response == success_gateway_response(@@ -286,7 +286,7 @@ def test_refund(assert txn.is_success == braintree_success_response.is_successcapture_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_resultcapture_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 errorassert txn.payment == payment- assert txn.transaction_type == TransactionType.CAPTURE+ assert txn.kind == Transactions.CAPTUREassert txn.amount == braintree_success_response.transaction.amountassert txn.currency == braintree_success_response.transaction.currency_iso_codeassert txn.gateway_response == success_gateway_response(@@ -354,7 +354,7 @@ def test_capture(assert txn.is_success == braintree_success_response.is_successauth_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_resultauth_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 errorassert txn.payment == payment- assert txn.transaction_type == TransactionType.VOID+ assert txn.kind == Transactions.VOIDassert txn.amount == braintree_success_response.transaction.amountassert txn.currency == braintree_success_response.transaction.currency_iso_codeassert txn.gateway_response == success_gateway_response(@@ -422,7 +422,7 @@ def test_void(assert txn.is_success == braintree_success_response.is_successauth_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_resultauth_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_ERRORassert not txn.is_success- assert txn.transaction_type == TransactionType.AUTH+ assert txn.kind == Transactions.AUTHassert txn.token == 'example-token'assert not txn.gateway_responseassert 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.totaldiff --git a/tests/test_payment_dummy.py b/tests/test_payment_dummy.pyindex 9ca4d4b882..177adde67c 100644--- a/tests/test_payment_dummy.py+++ b/tests/test_payment_dummy.py@@ -2,13 +2,13 @@ from decimal import Decimalimport pytest-from saleor.payment import ChargeStatus, PaymentError, TransactionType+from saleor.payment import ChargeStatus, PaymentError, Transactionsdef 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.AUTHassert txn.payment == payment_dummypayment_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.AUTHassert not txn.is_successassert txn.payment == payment_dummy@@ -29,7 +29,7 @@ def test_void_success(payment_dummy):assert payment_dummy.charge_status == ChargeStatus.NOT_CHARGEDtxn = payment_dummy.void()assert txn.is_success- assert txn.transaction_type == TransactionType.VOID+ assert txn.kind == Transactions.VOIDassert txn.payment == payment_dummypayment_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.VOIDassert not txn.is_successassert 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.CHARGEassert not txn.is_successassert txn.payment == payment_dummy@@ -114,7 +114,7 @@ def test_refund_success(payment.captured_amount = initial_captured_amountpayment.save()txn = payment.refund(refund_amount)- assert txn.transaction_type == TransactionType.REFUND+ assert txn.kind == Transactions.REFUNDassert txn.is_successassert txn.payment == paymentassert 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.REFUNDassert not txn.is_successassert txn.payment == paymentassert payment.charge_status == ChargeStatus.CHARGED