Skip to content

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

Drop paymentAuthorize mutation

Marcin Gębalafa722b4fcab0
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.py
index 0231583bde..35aa426fd7 100644
--- a/saleor/graphql/payment/mutations.py
+++ b/saleor/graphql/payment/mutations.py
@@ -86,36 +86,6 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):
return CheckoutPaymentCreate(payment=payment, errors=errors)
-class PaymentAuthorize(BaseMutation):
- payment = graphene.Field(Payment, description='Updated payment')
-
- class Arguments:
- payment_id = graphene.ID(required=True, description='Payment ID')
- payment_token = graphene.String(
- required=True,
- description='One-time-use reference to payment information')
-
- class Meta:
- description = 'Authorize the payment'
-
- @classmethod
- @permission_required('order.manage_orders')
- def mutate(cls, root, info, payment_id, payment_token):
- errors = []
- payment = cls.get_node_or_error(
- info, payment_id, errors, 'payment_id', only_type=Payment)
-
- if not payment:
- return PaymentAuthorize(errors=errors)
-
- try:
- gateway_authorize(payment, payment_token)
- except PaymentError as exc:
- msg = str(exc)
- cls.add_error(field=None, message=msg, errors=errors)
- return PaymentAuthorize(payment=payment, errors=errors)
-
-
class PaymentCapture(BaseMutation):
payment = graphene.Field(Payment, description='Updated payment')
diff --git a/saleor/graphql/payment/schema.py b/saleor/graphql/payment/schema.py
index 2447e14ade..754aeced61 100644
--- a/saleor/graphql/payment/schema.py
+++ b/saleor/graphql/payment/schema.py
@@ -3,8 +3,7 @@ from graphql_jwt.decorators import permission_required
from ..core.fields import PrefetchingConnectionField
from .enums import PaymentGatewayEnum
-from .mutations import (
- PaymentAuthorize, PaymentCapture, PaymentRefund, PaymentVoid)
+from .mutations import PaymentCapture, PaymentRefund, PaymentVoid
from .resolvers import resolve_payment_client_token, resolve_payments
from .types import Payment
@@ -28,7 +27,6 @@ class PaymentQueries(graphene.ObjectType):
class PaymentMutations(graphene.ObjectType):
- payment_authorize = PaymentAuthorize.Field()
payment_capture = PaymentCapture.Field()
payment_refund = PaymentRefund.Field()
payment_void = PaymentVoid.Field()
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 277cbbafa3..812f7ea393 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -409,6 +409,8 @@ type ChoiceValue {
}
type Collection implements Node {
+ publicationDate: Date
+ isPublished: Boolean!
seoTitle: String
seoDescription: String
id: ID!
@@ -416,9 +418,7 @@ type Collection implements Node {
slug: String!
products(before: String, after: String, first: Int, last: Int): ProductCountableConnection
backgroundImage(size: Int): Image
- isPublished: Boolean!
description: String!
- publicationDate: Date
publishedDate: Date @deprecated(reason: "publishedDate is deprecated, use publicationDate instead")
}
@@ -876,7 +876,6 @@ type Mutations {
productVariantUpdate(id: ID!, input: ProductVariantInput!): ProductVariantUpdate
variantImageAssign(imageId: ID!, variantId: ID!): VariantImageAssign
variantImageUnassign(imageId: ID!, variantId: ID!): VariantImageUnassign
- paymentAuthorize(paymentId: ID!, paymentToken: String!): PaymentAuthorize
paymentCapture(amount: Decimal, paymentId: ID!): PaymentCapture
paymentRefund(amount: Decimal, paymentId: ID!): PaymentRefund
paymentVoid(paymentId: ID!): PaymentVoid
@@ -1172,14 +1171,14 @@ type OrderVoid {
type Page implements Node {
id: ID!
+ publicationDate: Date
+ isPublished: Boolean!
seoTitle: String
seoDescription: String
slug: String!
title: String!
content: String!
created: DateTime!
- isPublished: Boolean!
- publicationDate: Date
availableOn: Date @deprecated(reason: "availableOn is deprecated, use publicationDate instead")
isVisible: Boolean @deprecated(reason: "isVisible is deprecated, use isPublished instead")
}
@@ -1258,11 +1257,6 @@ type Payment implements Node {
creditCard: CreditCard
}
-type PaymentAuthorize {
- errors: [Error!]
- payment: Payment
-}
-
type PaymentCapture {
errors: [Error!]
payment: Payment
@@ -1321,6 +1315,8 @@ enum PermissionEnum {
}
type Product implements Node {
+ publicationDate: Date
+ isPublished: Boolean!
seoTitle: String
seoDescription: String
id: ID!
@@ -1329,8 +1325,6 @@ type Product implements Node {
description: String!
category: Category!
price: Money
- publicationDate: Date
- isPublished: Boolean!
attributes: [SelectedAttribute!]!
updatedAt: DateTime
chargeTaxes: Boolean!
diff --git a/tests/api/test_payment.py b/tests/api/test_payment.py
index f9457c5e3d..650069563e 100644
--- a/tests/api/test_payment.py
+++ b/tests/api/test_payment.py
@@ -115,73 +115,6 @@ def test_checkout_add_payment(
assert payment.charge_status == ChargeStatus.NOT_CHARGED
-AUTHORIZE_QUERY = """
- mutation PaymentAuthorize($paymentId: ID!, $paymentToken: String!) {
- paymentAuthorize(paymentId: $paymentId, paymentToken: $paymentToken) {
- payment {
- id,
- chargeStatus
- }
- errors {
- field
- message
- }
- }
- }
-"""
-
-
-def test_payment_authorize_success(
- staff_api_client, permission_manage_orders, payment_dummy):
- payment = payment_dummy
- assert payment.charge_status == ChargeStatus.NOT_CHARGED
-
- payment_id = graphene.Node.to_global_id(
- 'Payment', payment.pk)
- variables = {
- 'paymentId': payment_id,
- 'paymentToken': 'Fake'}
- response = staff_api_client.post_graphql(
- AUTHORIZE_QUERY, variables, permissions=[permission_manage_orders])
- content = get_graphql_content(response)
- data = content['data']['paymentAuthorize']
- assert not data['errors']
- payment.refresh_from_db()
- assert payment.charge_status == ChargeStatus.NOT_CHARGED
- assert payment.transactions.count() == 1
- txn = payment.transactions.first()
- assert txn.kind == TransactionKind.AUTH
-
-
-def test_payment_authorize_gateway_error(
- staff_api_client, permission_manage_orders, payment_dummy,
- monkeypatch):
- payment = payment_dummy
- assert payment.charge_status == ChargeStatus.NOT_CHARGED
-
- payment_id = graphene.Node.to_global_id(
- 'Payment', payment.pk)
- variables = {
- 'paymentId': payment_id,
- 'paymentToken': 'Fake'}
- monkeypatch.setattr(
- 'saleor.payment.gateways.dummy.dummy_success', lambda: False)
- response = staff_api_client.post_graphql(
- AUTHORIZE_QUERY, variables, permissions=[permission_manage_orders])
- content = get_graphql_content(response)
- data = content['data']['paymentAuthorize']
- assert data['errors']
- assert data['errors'][0]['field'] is None
- assert data['errors'][0]['message']
-
- payment.refresh_from_db()
- assert payment.charge_status == ChargeStatus.NOT_CHARGED
- assert payment.transactions.count() == 1
- txn = payment.transactions.first()
- assert txn.kind == TransactionKind.AUTH
- assert not txn.is_success
-
-
CAPTURE_QUERY = """
mutation PaymentCapture($paymentId: ID!, $amount: Decimal!) {
paymentCapture(paymentId: $paymentId, amount: $amount) {