Skip to content
Open
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
12 changes: 9 additions & 3 deletions dashboard/src/components/billing/BuyCreditsRazorpay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</template>
<script setup>
import { Button, ErrorMessage, FeatherIcon, createResource } from 'frappe-ui';
import { ref, onMounted, onBeforeUnmount, inject } from 'vue';
import { ref, onMounted, inject } from 'vue';
import { toast } from 'vue-sonner';
import { DashboardError } from '../../utils/error';
import { loadRazorpayScript } from '../../utils/razorpay';
Expand Down Expand Up @@ -117,13 +117,20 @@ const handlePaymentFailed = createResource({
},
});

function getRazorpayContact() {
return team.doc?.phone_number || undefined;
}

function processOrder(data) {
const options = {
key: data.key_id,
order_id: data.order_id,
name: 'Frappe Cloud',
image: 'https://frappe.io/files/cloud.png',
prefill: { email: team.doc?.user },
prefill: {
email: team.doc?.user,
...(getRazorpayContact() && { contact: getRazorpayContact() }),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contact: team.doc?.phone_number will suffice, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of undefined, the contact param should not be passed.

Copy link
Copy Markdown
Member

@ssiyad ssiyad Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If team.doc?.phone_number is undefined, this works as expected. If it is any other falsy value, contact: team.doc?.phone_number || undefined should work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be undefined or empty, that's why I added the spread operator to include contact param if it has defined value and not pass otherwise. let me know if it can be improved. i will include the changes and push it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssiyad let me know if this comment can be resolved or do you have more feedback on this part?

},
handler: handlePaymentSuccess,
theme: { color: '#171717' },
...(paypalEnabled
Expand All @@ -150,7 +157,6 @@ function processOrder(data) {
}
: {}),
};

const rzp = new Razorpay(options);

// Opens the payment checkout frame
Expand Down
1 change: 1 addition & 0 deletions press/press/doctype/team/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Team(Document):
"hybrid_servers_enabled",
"relaxed_permissions",
"upi_autopay_enabled",
"phone_number",
)

def get_doc(self, doc):
Expand Down
Loading