Compare commits

...

2 Commits

Author SHA1 Message Date
Martin Gross
765dfb13ac isort 2025-05-22 17:03:18 +02:00
Martin Gross
cd05d2a45c Stripe: Update to 12.x 2025-05-22 16:56:56 +02:00
6 changed files with 1780 additions and 1144 deletions

View File

@@ -93,7 +93,7 @@ dependencies = [
"requests==2.31.*",
"sentry-sdk==2.27.*",
"sepaxml==2.6.*",
"stripe==7.9.*",
"stripe==12.1.*",
"text-unidecode==1.*",
"tlds>=2020041600",
"tqdm==4.*",

View File

@@ -19,12 +19,12 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
import stripe
from django.core.management.base import BaseCommand
from django_scopes import scopes_disabled
from pretix.base.models import Event
from pretix.base.settings import GlobalSettingsObject
from pretix.plugins.stripe.utils import get_stripe_client
class Command(BaseCommand):
@@ -34,7 +34,10 @@ class Command(BaseCommand):
def handle(self, *args, **options):
cache = {}
gs = GlobalSettingsObject()
api_key = gs.settings.payment_stripe_connect_secret_key or gs.settings.payment_stripe_connect_test_secret_key
api_key = (
gs.settings.payment_stripe_connect_secret_key
or gs.settings.payment_stripe_connect_test_secret_key
)
if not api_key:
self.stderr.write(self.style.ERROR("Stripe Connect is not set up!"))
return
@@ -46,11 +49,13 @@ class Command(BaseCommand):
e.settings.payment_stripe_merchant_country = cache[uid]
else:
try:
account = stripe.Account.retrieve(
stripe_client = get_stripe_client(api_key)
account = stripe_client.accounts.retrieve(
uid,
api_key=api_key
)
except Exception as e:
print(e)
else:
e.settings.payment_stripe_merchant_country = cache[uid] = account.get('country')
e.settings.payment_stripe_merchant_country = cache[uid] = (
account.get("country")
)

File diff suppressed because it is too large Load Diff

View File

@@ -29,6 +29,7 @@ from pretix.base.services.tasks import EventTask
from pretix.celery_app import app
from pretix.multidomain.urlreverse import get_event_domain
from pretix.plugins.stripe.models import RegisteredApplePayDomain
from pretix.plugins.stripe.utils import get_stripe_client
logger = logging.getLogger(__name__)
@@ -51,6 +52,7 @@ def get_stripe_account_key(prov):
@app.task(base=EventTask, max_retries=5, default_retry_delay=1)
def stripe_verify_domain(event, domain):
from pretix.plugins.stripe.payment import StripeCC
prov = StripeCC(event)
account = get_stripe_account_key(prov)
@@ -59,29 +61,22 @@ def stripe_verify_domain(event, domain):
# we're building our api_kwargs here by hand.
# Only if no live connect secret key is set, we'll fall back to the testmode keys.
# But this should never happen except in scenarios where pretix runs in devmode.
if prov.settings.connect_client_id and prov.settings.connect_user_id:
api_kwargs = {
'api_key': prov.settings.connect_secret_key or prov.settings.connect_test_secret_key,
'stripe_account': prov.settings.connect_user_id
}
else:
api_kwargs = {
'api_key': prov.settings.secret_key,
}
stripe_client = get_stripe_client(
prov.settings.connect_secret_key or prov.settings.connect_test_secret_key
)
if RegisteredApplePayDomain.objects.filter(account=account, domain=domain).exists():
return
try:
resp = stripe.ApplePayDomain.create(
domain_name=domain,
**api_kwargs
resp = stripe_client.apple_pay_domains.create(
params={
"domain_name": domain,
},
options=prov.api_options,
)
except stripe.error.StripeError:
logger.exception('Could not verify domain with Stripe')
logger.exception("Could not verify domain with Stripe")
else:
if resp.livemode:
RegisteredApplePayDomain.objects.create(
domain=domain,
account=account
)
RegisteredApplePayDomain.objects.create(domain=domain, account=account)

View File

@@ -19,3 +19,18 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
import stripe
from stripe import StripeClient
from pretix import __version__
def get_stripe_client(api_key):
stripe.set_app_info(
"pretix",
partner_id="pp_partner_FSaz4PpKIur7Ox",
version=__version__,
url="https://pretix.eu",
)
stripe.enable_telemetry = False
return StripeClient(api_key)

File diff suppressed because it is too large Load Diff