Skip to content

Commit

Permalink
Fixes: razorpay integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Jun 2, 2024
1 parent aebd17a commit bcbceee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ jobs:
run: npm ci
- name: Install Vercel CLI
run: npm install --global vercel@canary
- name: Get Current Deployment URL
run: |
DEPLOYMENT_URL=$(vercel ls --token=${{ secrets.VERCEL_TOKEN }} --json | jq -r '.[0].url')
echo "Deployment URL: $DEPLOYMENT_URL"
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand All @@ -41,4 +37,4 @@ jobs:
retention-days: 30
- name: Rollback Deployment on Test Failure
if: ${{ failure() }}
run: vercel rollback --url $DEPLOYMENT_URL --token=${{ secrets.VERCEL_TOKEN }}
run: vercel rollback --token=${{ secrets.VERCEL_TOKEN }}
51 changes: 21 additions & 30 deletions app/(pages)/patient/components/BookAppointment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,36 +196,27 @@ export default function BookAppointment({ name, email }: BookAppointmentProps) {
}

// razorpay payment processing
await processPayment(selectedHospital.appointment_charge, name, email)
.then(() => {
// booking appointment after payment
const bookAppointmentData = {
date: new Date(),
state: selectedState,
city: selectedCity,
hospital: selectedHospital,
disease: selectedDisease,
note: additionalNote,
};
processPayment(selectedHospital.appointment_charge, name, email);
toast.dismiss();

// booking appointment after payment
const bookAppointmentData = {
date: new Date(),
state: selectedState,
city: selectedCity,
hospital: selectedHospital,
disease: selectedDisease,
note: additionalNote,
};

return bookAppointment(bookAppointmentData);
})
.then((response) => {
if (response.error) {
console.error("Error booking apppointment:", response.error);
toast.error(response.error);
} else {
clearSelected();
toast.success(response.msg);
}
})
.catch((error) => {
console.error("Error booking apppointment:", error);
toast.error("Error booking appointment");
})
.finally(() => {
toast.dismiss();
});
const response = await bookAppointment(bookAppointmentData);
if (response.error) {
console.error("Error booking apppointment:", response.error);
toast.error(response.error);
return;
}
clearSelected();
toast.success(response.msg);
}

function clearSelected() {
Expand Down Expand Up @@ -462,7 +453,7 @@ async function processPayment(amount: string, name: string, email: string) {
headers: { "Content-Type": "application/json" },
});
const res = await result.json();
if (res.isOk) toast.success(res.message);
if (res.isOk) return true;
else {
toast.error(res.message);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/patient/pendingAppointmentsReq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default async function pendingAppointmentsRequest(hospital_id: string) {
try {
const res = await fetch(`${serverUrl}/api/patient/appointment/pending`, {
method: "POST",
body: JSON.stringify(hospital_id),
body: JSON.stringify({ hospital_id }),
headers,
});

Expand Down

0 comments on commit bcbceee

Please sign in to comment.