Skip to content
Draft
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
24 changes: 24 additions & 0 deletions dashboard/src/components/BuyPrepaidCreditsRazorpay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,43 @@ 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,
name: 'Frappe Cloud',
image: '/assets/press/images/frappe-cloud-logo.png',
prefill: {
email: this.$team.doc.user,
...(callingCode ? { contact: callingCode } : {}),
},
handler: this.handlePaymentSuccess,
theme: { color: '#171717' },
Expand Down
1 change: 1 addition & 0 deletions press/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down