mirror of
https://github.com/pretix/pretix.git
synced 2025-12-21 16:42:26 +00:00
Compare commits
2 Commits
widget-dia
...
stripe_12x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
765dfb13ac | ||
|
|
cd05d2a45c |
@@ -93,7 +93,7 @@ dependencies = [
|
|||||||
"requests==2.31.*",
|
"requests==2.31.*",
|
||||||
"sentry-sdk==2.27.*",
|
"sentry-sdk==2.27.*",
|
||||||
"sepaxml==2.6.*",
|
"sepaxml==2.6.*",
|
||||||
"stripe==7.9.*",
|
"stripe==12.1.*",
|
||||||
"text-unidecode==1.*",
|
"text-unidecode==1.*",
|
||||||
"tlds>=2020041600",
|
"tlds>=2020041600",
|
||||||
"tqdm==4.*",
|
"tqdm==4.*",
|
||||||
|
|||||||
@@ -19,12 +19,12 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# 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/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import stripe
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
|
||||||
from pretix.base.models import Event
|
from pretix.base.models import Event
|
||||||
from pretix.base.settings import GlobalSettingsObject
|
from pretix.base.settings import GlobalSettingsObject
|
||||||
|
from pretix.plugins.stripe.utils import get_stripe_client
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -34,7 +34,10 @@ class Command(BaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
cache = {}
|
cache = {}
|
||||||
gs = GlobalSettingsObject()
|
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:
|
if not api_key:
|
||||||
self.stderr.write(self.style.ERROR("Stripe Connect is not set up!"))
|
self.stderr.write(self.style.ERROR("Stripe Connect is not set up!"))
|
||||||
return
|
return
|
||||||
@@ -46,11 +49,13 @@ class Command(BaseCommand):
|
|||||||
e.settings.payment_stripe_merchant_country = cache[uid]
|
e.settings.payment_stripe_merchant_country = cache[uid]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
account = stripe.Account.retrieve(
|
stripe_client = get_stripe_client(api_key)
|
||||||
|
account = stripe_client.accounts.retrieve(
|
||||||
uid,
|
uid,
|
||||||
api_key=api_key
|
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
else:
|
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
@@ -29,6 +29,7 @@ from pretix.base.services.tasks import EventTask
|
|||||||
from pretix.celery_app import app
|
from pretix.celery_app import app
|
||||||
from pretix.multidomain.urlreverse import get_event_domain
|
from pretix.multidomain.urlreverse import get_event_domain
|
||||||
from pretix.plugins.stripe.models import RegisteredApplePayDomain
|
from pretix.plugins.stripe.models import RegisteredApplePayDomain
|
||||||
|
from pretix.plugins.stripe.utils import get_stripe_client
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
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)
|
@app.task(base=EventTask, max_retries=5, default_retry_delay=1)
|
||||||
def stripe_verify_domain(event, domain):
|
def stripe_verify_domain(event, domain):
|
||||||
from pretix.plugins.stripe.payment import StripeCC
|
from pretix.plugins.stripe.payment import StripeCC
|
||||||
|
|
||||||
prov = StripeCC(event)
|
prov = StripeCC(event)
|
||||||
account = get_stripe_account_key(prov)
|
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.
|
# 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.
|
# 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.
|
# 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:
|
stripe_client = get_stripe_client(
|
||||||
api_kwargs = {
|
prov.settings.connect_secret_key or prov.settings.connect_test_secret_key
|
||||||
'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,
|
|
||||||
}
|
|
||||||
|
|
||||||
if RegisteredApplePayDomain.objects.filter(account=account, domain=domain).exists():
|
if RegisteredApplePayDomain.objects.filter(account=account, domain=domain).exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = stripe.ApplePayDomain.create(
|
resp = stripe_client.apple_pay_domains.create(
|
||||||
domain_name=domain,
|
params={
|
||||||
**api_kwargs
|
"domain_name": domain,
|
||||||
|
},
|
||||||
|
options=prov.api_options,
|
||||||
)
|
)
|
||||||
except stripe.error.StripeError:
|
except stripe.error.StripeError:
|
||||||
logger.exception('Could not verify domain with Stripe')
|
logger.exception("Could not verify domain with Stripe")
|
||||||
else:
|
else:
|
||||||
if resp.livemode:
|
if resp.livemode:
|
||||||
RegisteredApplePayDomain.objects.create(
|
RegisteredApplePayDomain.objects.create(domain=domain, account=account)
|
||||||
domain=domain,
|
|
||||||
account=account
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -19,3 +19,18 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# 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/>.
|
# <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
Reference in New Issue
Block a user