Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions kompassi/payments/models/checkout_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
logger = logging.getLogger(__name__)


CHECKOUT_API_BASE_URL = "https://api.checkout.fi"
CHECKOUT_PAYMENT_WALL_ORIGIN = "pay.checkout.fi"
CHECKOUT_API_BASE_URL = "https://services.paytrail.com"
CHECKOUT_PAYMENT_WALL_ORIGIN = "payment.paytrail.com"
CHECKOUT_STATUSES = [
("new", _("New")),
("ok", _("OK")),
Expand Down Expand Up @@ -236,15 +236,20 @@ def perform_create_payment_request(self, request: HttpRequest):
if not settings.DEBUG and self.meta.checkout_merchant == META_DEFAULTS["checkout_merchant"]:
raise ValueError(f"Event {self.event} has testing merchant in production, please change this in admin")

language = "FI" if get_language() == "fi" else "EN"
lang = get_language()
if lang == "fi":
language = "FI"
elif lang == "sv":
language = "SV"
else:
language = "EN"

body = {
"stamp": str(self.stamp),
"reference": self.reference,
"amount": self.price_cents,
"currency": "EUR",
"language": language,
"items": self.items,
"customer": self.customer,
"redirectUrls": {
"success": request.build_absolute_uri(reverse("payments_checkout_success_view")),
Expand All @@ -263,7 +268,7 @@ def perform_create_payment_request(self, request: HttpRequest):

headers = self.meta.get_checkout_params()
headers["signature"] = calculate_hmac(self.meta.checkout_password, headers, body)
headers["content-type"] = "application/json"
headers["content-type"] = "application/json; charset=utf-8"

url = f"{CHECKOUT_API_BASE_URL}/payments"

Expand Down
3 changes: 2 additions & 1 deletion kompassi/payments/models/payments_organization_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ def get_checkout_params(self, method="POST", t=None):
"checkout-algorithm": "sha256",
"checkout-method": method,
"checkout-nonce": str(uuid4()),
"checkout-timestamp": t.isoformat(),
"checkout-timestamp": t.isoformat(timespec="milliseconds").replace("+00:00", "Z"),
"platform-name": "kompassi",
}
Loading