Issues in migrating to Live mode PhonePe payment gateway

812 Views Asked by At

I have implemented and integrated phonepe payment gateway in UAT test mode via firebase cloud function but having trouble while migrating to Live mode. Here is the code -

exports.Transaction = onCall({maxInstances:10},async(request)=>{
  const amount = parseFloat(request.data.amount) * 100;
const eventPayload = {
    merchantId: "PGTESTPAYUAT",
    merchantTransactionId: "MT7850590068188108",
    merchantUserId: "MUID123",
    amount: amount,
    redirectUrl: "https://ball24.in",
    redirectMode: "POST",
    callbackUrl: "https://ball24.in",
    mobileNumber: "9999999999",
    paymentInstrument: {
        type: "PAY_PAGE",
    },
};


const encodedPayload = Buffer.from(JSON.stringify(eventPayload)).toString("base64");
const saltKey = "099eb0cd-02cf-4e2a-8aca-3e6c6aff0399";
const saltIndex = 1;
const string = encodedPayload + "/pg/v1/pay" + saltKey;
const sha256 = crypto.createHash("sha256").update(string).digest("hex");
const finalXHeader = sha256 + "###" + saltIndex;

const headers = {
    "Content-Type": "application/json",
    "X-VERIFY": finalXHeader,
};

const phonePayUrl = "https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay";
const response = await fetch(phonePayUrl, {
    method: "POST",
    body: JSON.stringify({ request: encodedPayload }),
    headers: headers,
});

const data = await response.json();
// const paymentUrl = data.data.instrumentResponse.redirectInfo.url;

return data;
})

Now as soon as i change my credentials to Live ones, and replace host url with production url - https://api.phonepe.com/apis/hermes .I am getting a error - RESOURCES NOT FOUND. What should i supposed to do.Can't find anything on internet.Phonepe support also ignoring mails. Please someone help

The code for UAT sandbox works fine .But not able to migrate to Live mode.Please help

2

There are 2 best solutions below

0
Avinash Immaneni On

So I have the same issue as well , so the way I resolved it is by using the python SDK instead of the SDK Less approach . Works like a charm .

1
Priyanka Joshi On