Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am Facing the error "Phonepe is not defined" and PhonePe.init is not a function. #7

Open
SaurabhSangewar03 opened this issue Nov 23, 2023 · 0 comments

Comments

@SaurabhSangewar03
Copy link

const handlePayment = () => {
// Replace 'your-api-key' with your actual PhonePe API key
const apiKey = "0bc9343c-7350-4439-a640-ff51f5b7f88b";

const transactionId = transactionUniqueId;

console.log(window.PhonePe.init);
// Ensure the PhonePe script is loaded
if (window.PhonePe) {
// Initialize PhonePe SDK
window.PhonePe.init({
clientId: apiKey,
orderId: transactionId,
amount: 100, // Replace with your actual amount
returnUrl: window.location.href,
paymentModes: ["UPI", "DEBIT_CARD", "CREDIT_CARD", "WALLET"],
intent: "ORDER",
});

  // Generate the PhonePe payment button
  window.PhonePe.setButton({
    id: "phonepe-checkout-button",
    preAuth: false,
  });

  // Open the PhonePe checkout when the button is clicked
  window.PhonePe.open();
} else {
  console.error(
    "PhonePe SDK is not available. Make sure the script is loaded."
  );
}

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant