Skip to content

Commit

Permalink
style: ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Oct 2, 2024
1 parent fe53c4e commit cecf0be
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class BraintreeSettings(Document):
supported_currencies = [
supported_currencies = (
"AED",
"AMD",
"AOA",
Expand Down Expand Up @@ -150,7 +150,7 @@ class BraintreeSettings(Document):
"ZAR",
"ZMK",
"ZWD",
]
)

def validate(self):
if not self.flags.ignore_mandatory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def set_status(event):

def set_mandate_status(event):
mandates = []
if isinstance(event["links"], (list,)):
if isinstance(event["links"], list):
for link in event["links"]:
mandates.append(link["mandate"])
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class GoCardlessSettings(Document):
supported_currencies = ["EUR", "DKK", "GBP", "SEK", "AUD", "NZD", "CAD", "USD"]
supported_currencies = ("EUR", "DKK", "GBP", "SEK", "AUD", "NZD", "CAD", "USD")

def validate(self):
self.initialize_client()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class MpesaSettings(Document):
supported_currencies = ["KES"]
supported_currencies = ("KES",)

def validate_transaction_currency(self, currency):
if currency not in self.supported_currencies:
Expand Down Expand Up @@ -51,7 +51,7 @@ def request_for_payment(self, **kwargs):
args = frappe._dict(kwargs)
request_amounts = self.split_request_amount_according_to_transaction_limit(args)

for i, amount in enumerate(request_amounts):
for _i, amount in enumerate(request_amounts):
args.request_amount = amount
if frappe.flags.in_test:
from payments.payment_gateways.doctype.mpesa_settings.test_mpesa_settings import (
Expand Down Expand Up @@ -197,7 +197,7 @@ def verify_transaction(**kwargs):
)

total_paid = amount + sum(completed_payments)
mpesa_receipts = ", ".join(mpesa_receipts + [mpesa_receipt])
mpesa_receipts = ", ".join([*mpesa_receipts, mpesa_receipt])

if total_paid >= pr.grand_total:
pr.run_method("on_payment_authorized", "Completed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def on_payment_authorized(payment_status):


class PayPalSettings(Document):
supported_currencies = [
supported_currencies = (
"AUD",
"BRL",
"CAD",
Expand All @@ -105,7 +105,7 @@ class PayPalSettings(Document):
"THB",
"TRY",
"USD",
]
)

def __setup__(self):
self.use_sandbox = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class PaytmSettings(Document):
supported_currencies = ["INR"]
supported_currencies = ("INR",)

def validate(self):
create_payment_gateway("Paytm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def on_payment_authorized(payment_status):


class RazorpaySettings(Document):
supported_currencies = ["INR"]
supported_currencies = ("INR",)

def init_client(self):
if self.api_key:
Expand Down Expand Up @@ -251,8 +251,8 @@ def create_request(self, data):

def authorize_payment(self):
"""
An authorization is performed when users payment details are successfully authenticated by the bank.
The money is deducted from the customers account, but will not be transferred to the merchants account
An authorization is performed when user's payment details are successfully authenticated by the bank.
The money is deducted from the customer's account, but will not be transferred to the merchant's account
until it is explicitly captured by merchant.
"""
data = json.loads(self.integration_request.data)
Expand Down Expand Up @@ -341,7 +341,7 @@ def cancel_subscription(self, subscription_id):
settings = self.get_settings({})

try:
resp = make_post_request(
make_post_request(
f"https://api.razorpay.com/v1/subscriptions/{subscription_id}/cancel",
auth=(settings.api_key, settings.api_secret),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2017, Frappe Technologies and contributors
# License: MIT. See LICENSE

from types import MappingProxyType
from urllib.parse import urlencode

import frappe
Expand All @@ -11,9 +12,27 @@

from payments.utils import create_payment_gateway

currency_wise_minimum_charge_amount = {
"JPY": 50,
"MXN": 10,
"DKK": 2.50,
"HKD": 4.00,
"NOK": 3.00,
"SEK": 3.00,
"USD": 0.50,
"AUD": 0.50,
"BRL": 0.50,
"CAD": 0.50,
"CHF": 0.50,
"EUR": 0.50,
"GBP": 0.30,
"NZD": 0.50,
"SGD": 0.50,
}


class StripeSettings(Document):
supported_currencies = [
supported_currencies = (
"AED",
"ALL",
"ANG",
Expand Down Expand Up @@ -128,25 +147,9 @@ class StripeSettings(Document):
"XPF",
"YER",
"ZAR",
]

currency_wise_minimum_charge_amount = {
"JPY": 50,
"MXN": 10,
"DKK": 2.50,
"HKD": 4.00,
"NOK": 3.00,
"SEK": 3.00,
"USD": 0.50,
"AUD": 0.50,
"BRL": 0.50,
"CAD": 0.50,
"CHF": 0.50,
"EUR": 0.50,
"GBP": 0.30,
"NZD": 0.50,
"SGD": 0.50,
}
)

currency_wise_minimum_charge_amount = MappingProxyType(currency_wise_minimum_charge_amount)

def on_update(self):
create_payment_gateway(
Expand Down Expand Up @@ -225,7 +228,7 @@ def create_charge_on_stripe(self):
receipt_email=self.data.payer_email,
)

if charge.captured == True:
if charge.captured is True:
self.integration_request.db_set("status", "Completed", update_modified=False)
self.flags.status_changed_to = "Completed"

Expand Down
1 change: 0 additions & 1 deletion payments/templates/pages/payment_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


def get_context(context):
token = frappe.local.form_dict.token
doc = frappe.get_doc(frappe.local.form_dict.doctype, frappe.local.form_dict.docname)

context.payment_message = ""
Expand Down

0 comments on commit cecf0be

Please sign in to comment.