diff --git a/dashboard/src/components/BuyPrepaidCreditsRazorpay.vue b/dashboard/src/components/BuyPrepaidCreditsRazorpay.vue index 646fff92198..ef9d8f0a08e 100644 --- a/dashboard/src/components/BuyPrepaidCreditsRazorpay.vue +++ b/dashboard/src/components/BuyPrepaidCreditsRazorpay.vue @@ -103,12 +103,35 @@ export default { }, }; }, + countriesWithIsd() { + return { + url: 'press.api.account.get_countries_with_isd_codes', + auto: true, + }; + }, }, methods: { buyCreditsWithRazorpay() { this.$resources.createRazorpayOrder.submit(); }, + getTeamCallingCode() { + const countries = this.$resources.countriesWithIsd?.data || []; + const teamCountry = this.$team.doc.country; + if (!teamCountry || countries.length === 0) { + return null; + } + const match = countries.find((country) => country.name === teamCountry); + if (!match?.isd) { + return null; + } + const isd = String(match.isd).trim(); + if (!isd) { + return null; + } + return isd.startsWith('+') ? isd : `+${isd}`; + }, processOrder(data) { + const callingCode = this.getTeamCallingCode(); const options = { key: data.key_id, order_id: data.order_id, @@ -116,6 +139,7 @@ export default { image: '/assets/press/images/frappe-cloud-logo.png', prefill: { email: this.$team.doc.user, + ...(callingCode ? { contact: callingCode } : {}), }, handler: this.handlePaymentSuccess, theme: { color: '#171717' }, diff --git a/press/api/account.py b/press/api/account.py index d78ec4b53d2..260690a1eb9 100644 --- a/press/api/account.py +++ b/press/api/account.py @@ -453,6 +453,7 @@ def validate_request_key(key, timezone=None): return None +@frappe.whitelist() def get_countries_with_isd_codes(): """Get list of countries with their ISD codes from Frappe's country_info.""" import phonenumbers