Skip to Content
Menu
This question has been flagged

Version: Odoo 16 running on SH


Is there a way to dynamically add the sales order payment link to an email template for sending to customers? I know that we can get the payment link manually from the sales order via Action >> Generate Payment Link >> Copy, but I'm hoping there's a way to add this to an email template so my sales reps don't have to copy and paste this value every time. I've gotten close to figuring this out, but am hung up on the access_token parameter in the URL. Here's my code so far:

https://mydomain\.odoo\.com/payment/pay\?reference=\{\{object\.name\}\}\&amount=\{\{object\.amount_total\}\}\&access_token=\{\{object\.access_token\}\}\&sale_order_id=\{\{object.id}}&provider_id=14">Payment Link

The access_token being returned from object.access_token is different than the access token parameter found in the link when I copy it from the Generate Payment Link popup. It seems like this used to be available in earlier versions of Odoo, so I'm hoping it is possible v16.


Thanks!

Avatar
Discard
Author

Unfortunately, no.

Best Answer

Hello, @Great Fermentations,


Hope you are doing well,

Please find code in comment. 

Hope this answer helps you.

Thanks & Regards,
Email: odoo@aktivsoftware.com     

Skype: kalpeshmaheshwari

Avatar
Discard

Please find code here :-
For add the payment link into email you need to write the code like below:

<t t-set="base_url" t-value="object.get_base_url()"/>
<a t-attf-href="#{base_url}/payment/pay?reference=#{object.name}&amp;amount=#{object.amount_total}&amp;access_token=#{object.access_token}"> Payment Link </a>

Author

@Jainesh - Thanks, but that's already what I've tried more or less. The problem is object.access_token. That value is different from the access token in the payment link (sales order >> action >> generate payment link)

The access token generated by that action seems to be in the account_move model and not sale_order, thus object.access_token won't work.

Hello, @Great Fermentations,

Hope you are doing well,

When the "Generate Payment Link" button is clicked, a popup (payment_link_wizard) appears.
This popup generates an access token based on sale order data, not the account move.
We are using object.access_token because the wizard uses sale order data, not account move data.

The provided link in the question is missing some parameters between the objects.
Due to these missing parameters, accessing the specific link is not possible

I suggest use the given link to access a specific URL.

Author

I may be wrong about the model, but the access_token value is still different. When I call the object.access_token variable from a sales order email template, it pulls in the value used for the Customer Preview page, not the Payment link page. Quick example here from my environment below. Notice the different values for access_token:

Payment Link: https://<website url>/payment/pay?reference=S00054&amount=94.05&access_token=921190550da5307816d20b643188f8dea5bd0206002acafd1c71abd50c5ffb5a&sale_order_id=54

Customer Preview Link: https://<website url>/my/orders/54?access_token=e7cda3ad-1f32-477e-9bd6-73aa52d530da

My whole reason for going at it this way was to control which payment method is available to the customer. I run two websites with two different payment providers. The default customer preview page shows all the payment providers available, and not the ones associated with a given website. The payment link page gives me the ability to define exactly which one I want to show.

Best Answer

Hi, great fermentations. Did code provided by Jainesh work? 

Avatar
Discard
Related Posts Replies Views Activity
2
Mar 25
2731
1
Mar 25
1254
1
May 24
1692
1
Dec 23
1739
2
Mar 24
2561