diff --git a/odex25_donation/applepay_fast_checkout/controllers/main.py b/odex25_donation/applepay_fast_checkout/controllers/main.py index 6e5dc3850..33d4f50d1 100644 --- a/odex25_donation/applepay_fast_checkout/controllers/main.py +++ b/odex25_donation/applepay_fast_checkout/controllers/main.py @@ -1,20 +1,24 @@ import json +import secrets +import requests from odoo.http import route, request, Controller - class ApplePayFastCheckout(Controller): @route('/applepay', type='http', auth='public', website=True, csrf=False) def apple_pay_iframe(self, **kwargs): + nonce = secrets.token_urlsafe(16) acquirer_id = request.env['payment.acquirer'].sudo().search([('provider', '=', 'applepay')], limit=1) if acquirer_id.state == 'test': url = "https://eu-test.oppwa.com/v1/paymentWidgets.js" else: - url = "https://oppwa.com/v1/paymentWidgets.js" + url = "https://eu-prod.oppwa.com/v1/paymentWidgets.js" - response = request.render("applepay_fast_checkout.apple_pay_iframe", {'hyperpay_src': url, 'merchant_id': acquirer_id.applepay_entity_id}) + integrity = requests.get(f'{url}/v1/fastcheckout/integrity').json().get('integrity', '') + + response = request.render("applepay_fast_checkout.apple_pay_iframe", {'hyperpay_src': url, 'merchant_id': acquirer_id.applepay_entity_id, 'nonce': nonce, 'integrity': integrity}) response.headers['Content-Security-Policy'] = "script-src blob: 'self' 'unsafe-inline' 'unsafe-eval' https://*; worker-src blob: 'self' 'unsafe-inline' 'unsafe-eval' https://*;connect-src 'self' https://* wss://*;frame-src 'self' blob: https://*;" return response diff --git a/odex25_donation/applepay_fast_checkout/views/applepay_iframe.xml b/odex25_donation/applepay_fast_checkout/views/applepay_iframe.xml index d508d8ca7..7f83bb306 100644 --- a/odex25_donation/applepay_fast_checkout/views/applepay_iframe.xml +++ b/odex25_donation/applepay_fast_checkout/views/applepay_iframe.xml @@ -4,12 +4,20 @@