Home > Enterprise >  I could't receive posted data from callbackurl
I could't receive posted data from callbackurl

Time:01-12

I have been installing 3ds payment system and I use Iyzipay nodejs client.

My api : nodejs express

My ui : reactjs

My issue is to not recieve data from callback. I want to tell whole phases. I start a 3ds payment and ı put html content that comes from iyzipay into my iframe react compenent and user makes sms confirmation in this iframe and after that, iframe post a data to my callback

    callbackUrl : "http://localhost:5000/shop/ordersteps/confirmcheckout",

But ı can't get data that posted to my callbackurl by iyzipay. When ı log my req.body, it shows an empty object.

This is my api code

router.post("/startcheckout", getAccessToRoute, collectAndCompileData, startCheckout  );   
router.post("/confirmcheckout", confirmCheckout)
    
        const startCheckout = errorWrapper(async (req, res, next) => {

      const user = req.user.userinfo;
      const sameAddres = req.body.sameAddres;
      const getData = req.collectAndCompileData;
      const buyer = getData.buyer;
      const shippingAddress = getData.shippingAddress;
      const billingAddress = getData.billingAddress;
      const basketItems = getData.basketItems;
      const totalPrice = getData.totalPrice;
      const paidPrice = getData.paidPrice
      const {expireMonth, expireYear, cvc } = req.body;
      const getCardNumber = req.body.cardNumber;
      const cardNumber = getCardNumber.replace(/\s /g,"")
      const cardHolderName = billingAddress.contactName || shippingAddress.contactName;
      const is_valid = luhn.validate(cardNumber);
      if (!is_valid) {
        return next(new CustomError("Geçersiz kart numarası.", 400));
      }
    
      const paymentRequest = {
        locale: Iyzipay.LOCALE.TR,
        conversationId: user.id,
        price: totalPrice,
        paidPrice: paidPrice,
        currency: Iyzipay.CURRENCY.TRY,
        installment: "1",
        basketId: user.id,
        callbackUrl : "http://localhost:5000/shop/ordersteps/confirmcheckout",
        paymentCard: {
          cardHolderName: cardHolderName,
          cardNumber: cardNumber,
          expireMonth: expireMonth,
          expireYear: expireYear,
          cvc: cvc,
          registerCard: "0",
        },
        buyer: buyer,
        shippingAddress: shippingAddress,
        billingAddress: billingAddress,
        basketItems: basketItems,
      };
    
      const getResult = await start3DPayment(paymentRequest);
    
      const threeDSHtmlContent = Base64.decode(getResult.threeDSHtmlContent);
    
    
      
      return res.status(200).json({ success: true, data: threeDSHtmlContent });
    });
    
    const confirmCheckout = errorWrapper(async (req, res, next) => {
      console.log(req)
    });

this is my iframe code

   function CheckoutModal(props) {
    
  return (
    <Container visibility={props.visibility} onClick={() => {props.setVisibility(false); props.setLoading(false)}}>
      <Wrapper >
      <Iframe srcDoc={props.htmlData}></Iframe>
      </Wrapper>
    </Container>
  );
}

CodePudding user response:

I fixed issue, I monitored my network > docs in devtools and after realizing that request content type was application/x-www-form-urlencoded, ı added this code lines to my server.js

app.use(express.urlencoded({
    extended: true
}))

that's all :))))

“To follow the path, look to the master, follow the master, walk with the master, see through the master, become the master.” – Zen Proverb

  •  Tags:  
  • Related