0

I am trying to do the following: When the user selects some items and click "Pay Now" button on our website, I mark the selected items status as "on hold" so no one else can select these items. If I receive "complete" from ipn I will mark the items as "purchased" and do other database change. If I receive "canceled" from ipn I will mark the "on hold" items back to "available".

It works fine when the user did make the payment (complete). However, if the user exit the payment flow (for example just close the browser tab) I didn't receive any messages. I am not sure why this is happening. Or the ipn just wouldn't give a message if the transaction is not complete?

Here is the code of the paypal button:

                            <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
                                <input type="hidden" name="cmd" value="_cart">
                                <input type="hidden" name="upload" value="1">
                                <input type="hidden" name="business" value="********-facilitator@gmail.com">
                                <input type="hidden" name="env" value="www.sandbox">
                                <input type="hidden" name="address_override" value="1">
                                <c:set var="index" value="${1}"/>
                                <c:forEach items="${items}" var="item">
                                   <input type="hidden" name="item_name_${index}" value="${item.title}">
                                   <input type="hidden" name="amount_${index}" value="${item.askPrice}">
                                   <input type="hidden" name="tax_${index}" value="$<fmt:formatNumber type="number" maxFractionDigits="2" value="${item.askPrice * taxRate}" />">
                                   <c:if test="${index == 1}">
                                       <input type="hidden" name="shipping_${index}" value="$<fmt:formatNumber type="number" maxFractionDigits="2" value="${shipmentFee}" />">
                                   </c:if>
                                   <c:set var="index" value="${index + 1}"/>
                                </c:forEach>
                                <c:remove var="index"/>
                                <!-- Fill full name in the first_name field -->
                                <input type="hidden" name="first_name" value="${info.recipient}">
                                <input type="hidden" name="notify_url" value="<c:url value="https://********.localtunnel.me/payment/paypal/ipn"></c:url>">
                                <input type="hidden" name="address1" value="${info.addressLine1}">
                                <input type="hidden" name="address2" value="${info.addressLine2}">
                                <input type="hidden" name="city" value="${info.city}">
                                <input type="hidden" name="state" value="${info.state}">
                                <input type="hidden" name="zip" value="${info.zip}">
                                <input type="hidden" name="country" value="US">
                                <input type="hidden" name="email" value="${info.email}">
                                <input type="hidden" name="custom" value="${flowId}">
                                <input type="image" name="submit" border="0"
                                    src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="Check out with PayPal">
                            </form>
darklord
  • 5,077
  • 12
  • 40
  • 65
  • Well you can't get a message unless he does something that will cause Paypal to send one. I suggest you put a timeout on the item hold. – user207421 Jun 14 '15 at 23:34
  • @EJP While do you know if there is a way to set the expire time on paypal button? If one user enter the payment flow but doesn't commit the payment for three days, I cannot make the items on hold for three days. On the other hand, if I just mark the items as available after say 20 minutes, it could lead to two users pay for the same item. – darklord Jun 14 '15 at 23:43
  • 1
    A PayPal login session will expire, but a website payments standard button as you show above does not. I recommend you turn the problem around: don't mark your inventory & then take payment; take an authorization (not sale!) from PayPal; then mark your inventory once the user has authorized payment, and then capture the funds. – geewiz Jun 15 '15 at 01:00
  • Yeah that's a useful recommendation – darklord Jun 15 '15 at 17:27

0 Answers0