asp.net - Paypal adaptive payment return url is calling twice -
i have implemented paypal adaptive payment method , using web flow. after making payment, when explicitly clicks on return button, return url calls twice if wait auto redirect calls once only.
i not able understand why return url calling twice.
please advice.
i using below code.
public static actionoutput maketransactionusingpaypal(paymentdetails payment, shopcart shop_cart) { receiverlist receiverlist = new receiverlist(); receiverlist.receiver = new list<receiver>(); string action_type = "pay_primary"; decimal amnt_to_admin = ((shop_cart.totalamounttobepaid * 10) / 100); /*total amount admin account */ receiver rec1 = new receiver(shop_cart.totalamounttobepaid); rec1.email = config.adminpaypalbusinessaccount; rec1.primary = true; /*amount after deducting admin commision seller */ receiver rec2 = new receiver(math.round((shop_cart.totalamounttobepaid - amnt_to_admin), 2, midpointrounding.toeven)); rec2.email = payment.paypalemail; // "anuj_merchant@xicom.biz"; receiverlist.receiver.add(rec1); receiverlist.receiver.add(rec2); payrequest req = new payrequest(new requestenvelope("en_us"), action_type, config.paypalcancelurl, "usd", receiverlist, config.paypalreturnurl); // set. fire request adaptivepaymentsservice service = new adaptivepaymentsservice(); payresponse resp = null; //transactiondetail details = new transactiondetail(); resp = service.pay(req); string paykey = resp.paykey; string paymentstatus = resp.paymentexecstatus; responseenvelope responseenvelope = resp.responseenvelope; payerrorlist errorlist = resp.payerrorlist; list<errordata> errordata = resp.error; if (errordata.count > 0) { return new actionoutput { status = actionstatus.error, message = errordata[0].message }; } fundingplan defaultfundingplan = resp.defaultfundingplan; warningdatalist warningdatalist = resp.warningdatalist; string redirecturl = null; if (!(resp.responseenvelope.ack == ackcode.failure) && !(resp.responseenvelope.ack == ackcode.failurewithwarning)) { redirecturl = configurationmanager.appsettings["paypal_redirect_url"] + "_ap-payment&paykey=" + resp.paykey; } return new actionoutput { status = actionstatus.successfull, message = "redirecting paypal...", results = new list<string> { redirecturl, resp.paykey } }; }
@jitendra, had same issue , found out paypal uses server side script redirects user return url after while , when explicitly click on return button, paypal server script again hits return url on own 2 responses/hits on our return url.
we can on checking/maintaining no of responses after payments made on paypal.
we can maintain using cookies on client end or on server using sessions or else similar.
hope helps well.
Comments
Post a Comment