Skip to content

Commit

Permalink
pay link fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RookieProgrammerSachin committed Jan 6, 2024
1 parent c1fd4ce commit d837e00
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default function Checkout() {
const phoneRef = useRef();
const [city, setCity] = useState("");
const [state, setState] = useState("");
const [isNotRedirected, setIsNotRedirected] = useState(false);
const [paymentLink, setPaymentLink] = useState("");
const router = useRouter();
const ctx = useContext(UserContext);
const closeModal = () => {
Expand Down Expand Up @@ -190,7 +192,14 @@ export default function Checkout() {
},
}
)
.then((response) => (window.location.href = response.data))
.then((response) => {
console.log(response);
setPaymentLink(response.data);
setTimeout(() => {
setIsNotRedirected(true);
}, 2000);
router.replace(response.data);
})
.catch((err) => {
console.log(err);
if (err.response.status === 400) {
Expand Down Expand Up @@ -490,6 +499,9 @@ export default function Checkout() {
className={`font-semibold rounded-[5px] text-white py-2 px-4 mr-2 mb-2 cursor-pointer font-algeria uppercase`}>
Proceed to Payment
</a>
{
isNotRedirected && <a href={paymentLink}>Click here if you are not redirected to payment page</a>
}
</div>
</form>
</div>
Expand Down

0 comments on commit d837e00

Please sign in to comment.