[IMP] payment(_*): make express checkout work again
Following 7e012dd, the express checkout flow stopped working.
This commit makes the express checkout flow works again.
task-3526289
closes odoo/odoo#139854
closes odoo/odoo#140085
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
committed by
Antoine Vandevenne (anv)
parent
47b20dc6ad
commit
a3c6afb2a9
@@ -59,7 +59,7 @@ publicWidget.registry.PaymentExpressCheckoutForm = publicWidget.Widget.extend({
|
||||
_prepareTransactionRouteParams(providerId) {
|
||||
return {
|
||||
'provider_id': parseInt(providerId),
|
||||
'payment_method_id': 1, // TODO VCR
|
||||
'payment_method_id': parseInt(this.paymentContext['paymentMethodUnknownId']),
|
||||
'token_id': null,
|
||||
'flow': 'direct',
|
||||
'tokenization_requested': false,
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
<odoo>
|
||||
|
||||
<template id="payment.express_checkout" name="Payment Express Checkout">
|
||||
<!-- Variables description:
|
||||
- providers: The payment providers compatible with the current transaction.
|
||||
<!-- Parameters description:
|
||||
- reference_prefix: The custom prefix to compute the full transaction reference.
|
||||
- amount: The amount to pay.
|
||||
- minor_amount: The amount to pay in the minor units of its currency.
|
||||
- currency: The currency of the transaction, as a `res.currency` record.
|
||||
- currency: The currency of the payment, as a `res.currency` record.
|
||||
- providers_sudo: The compatible providers, as a sudoed `payment.provider` recordset.
|
||||
- merchant_name: The merchant name.
|
||||
- payment_method_unknown_id: The ID of the "Unknown" payment method record, to use as
|
||||
the generic express checkout method.
|
||||
- payment_access_token: The access token used to authenticate the partner. Since this
|
||||
template is loaded in the shopping cart, this parameter is
|
||||
called `payment_access_token` to prevent mixing up with the
|
||||
@@ -20,6 +22,10 @@
|
||||
Optional.
|
||||
- express_checkout_route: The route where the billing and shipping information are sent.
|
||||
- landing_route: The route the user is redirected to after the transaction.
|
||||
- payment_access_token: The access token used to authenticate the partner. Since this
|
||||
template is loaded in the shopping cart, this parameter is
|
||||
called `payment_access_token` to prevent mixing up with the
|
||||
`access_token` used for abandoned carts.
|
||||
-->
|
||||
<form name="o_payment_express_checkout_form" class="container"
|
||||
t-att-data-reference-prefix="reference_prefix"
|
||||
@@ -29,6 +35,7 @@
|
||||
t-att-data-currency-name="currency.name.lower()"
|
||||
t-att-data-merchant-name="merchant_name"
|
||||
t-att-data-partner-id="partner_id"
|
||||
t-att-data-payment-method-unknown-id="payment_method_unknown_id"
|
||||
t-att-data-access-token="payment_access_token"
|
||||
t-att-data-shipping-info-required="shipping_info_required"
|
||||
t-att-data-transaction-route="transaction_route"
|
||||
@@ -36,15 +43,12 @@
|
||||
t-att-data-express-checkout-route="express_checkout_route"
|
||||
t-att-data-landing-route="landing_route"
|
||||
>
|
||||
<t t-foreach="providers_sudo" t-as="provider_sudo">
|
||||
<t t-set="express_checkout_form_xml_id"
|
||||
t-value="provider_sudo.express_checkout_form_view_id.xml_id"
|
||||
/>
|
||||
<t t-if="express_checkout_form_xml_id">
|
||||
<t t-call="{{express_checkout_form_xml_id}}">
|
||||
<t t-set="provider_sudo" t-value="provider_sudo"/>
|
||||
</t>
|
||||
</t>
|
||||
<t t-set="provider_sudo" t-value="providers_sudo[0]"/>
|
||||
<t t-set="express_checkout_form_xml_id"
|
||||
t-value="provider_sudo.express_checkout_form_view_id.xml_id"
|
||||
/>
|
||||
<t t-if="express_checkout_form_xml_id">
|
||||
<t t-call="{{express_checkout_form_xml_id}}"/>
|
||||
</t>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
@@ -26,6 +26,7 @@ PAYMENT_METHODS_MAPPING = {
|
||||
'becs_direct_debit': 'au_becs_debit',
|
||||
'afterpay': 'afterpay_clearpay',
|
||||
'clearpay': 'afterpay_clearpay',
|
||||
'unknown': 'card', # For express checkout.
|
||||
}
|
||||
|
||||
# Mapping of transaction states to Stripe objects ({Payment,Setup}Intent, Refund) statuses.
|
||||
|
||||
@@ -20,12 +20,12 @@ paymentExpressCheckoutForm.include({
|
||||
*/
|
||||
_getOrderDetails(deliveryAmount) {
|
||||
const pending = this.paymentContext['shippingInfoRequired'] && deliveryAmount === undefined;
|
||||
const amount = deliveryAmount ? this.paymentContext['minorAmount'] + deliveryAmount
|
||||
: this.paymentContext['minorAmount'];
|
||||
const amount = deliveryAmount ? parseInt(this.paymentContext['minorAmount'] + deliveryAmount)
|
||||
: parseInt(this.paymentContext['minorAmount']);
|
||||
const displayItems = [
|
||||
{
|
||||
label: _t("Your order"),
|
||||
amount: this.paymentContext['minorAmount'],
|
||||
amount: parseInt(this.paymentContext['minorAmount']),
|
||||
},
|
||||
];
|
||||
if (this.paymentContext['shippingInfoRequired'] && deliveryAmount !== undefined) {
|
||||
|
||||
@@ -1668,6 +1668,7 @@ class WebsiteSale(payment_portal.PaymentPortal):
|
||||
'transaction_route': f'/shop/payment/transaction/{order.id}',
|
||||
'express_checkout_route': self._express_checkout_route,
|
||||
'landing_route': '/shop/payment/validate',
|
||||
'payment_method_unknown_id': request.env.ref('payment.payment_method_unknown').id,
|
||||
})
|
||||
if request.website.is_public_user():
|
||||
payment_form_values['partner_id'] = -1
|
||||
|
||||
Reference in New Issue
Block a user