using paypal button - can my webpage tell if paypal transaction was successful or not?

前端 未结 2 1392
情深已故
情深已故 2021-01-22 11:12

I am using joomla and have brought a component which allows users to post listings on my site. The plugin uses a credit system to pay for the listing but the credit system is qu

相关标签:
2条回答
  • 2021-01-22 11:31

    Good news - the answer to your questions is essentially yes. Your end goal is definitely doable, but in order to really solve your problem in its entirety, we may need a little bit more information.

    How you go about it can vary from case to case, however, and unfortunately it's been a while since I configured these buttons, so bear with me ;-)

    once the user clicks on the buy it now button is it possible to redirect them back the the add listing form they were just filling out?

    Yes, this is a very standard functionality that PayPal has built into their buttons and their process. What you are looking for here is what PayPal calls "Return URLs" or "Auto Return". Here's the page with more of the documentation I quoted below so you can decide whether the Return URL or the Auto Return or the Payment Data Transfer option is best suited for you.

    Returning buyers to your website after they check out

    The basic checkout experience leaves buyers on the PayPal website after they check out. Use one of the following techniques to enhance the checkout experience so that buyers return to your website, instead.

    Return URL: Allow buyers return to a page on your website if they click a return link or button on the PayPal payment confirmation page.

    To learn more, see item #5 under Step 3: Adding advanced features to your Buy Now button or HTML variables for displaying PayPal checkout pages.

    Auto Return: Have PayPal return customers automatically to a page on your website.

    Important: PayPal recommends that you turn Payment Data Transfer on when you turn Auto Return on. With Auto Return on, PayPal redirects buyers to your website from an alternative PayPal payment confirmation page, which does not allow them to print PayPal receipts. Payment Data Transfer provides the transaction information that you need to allow buyers to print receipts from your website.

    To learn more, see Auto Return.

    Payment Data Transfer: PayPal includes information about the completed transaction when you use a return URL or Auto Return to send customers back to your website. Use the information that Payment Data Transfer provides to display a "thank you, print your receipt" page on your website. To learn more, see the Payment Data Transfer.


    Question Can I disable the submit button on the form until the payment has been confirmed?

    Certainly. To disable the submit button on the form until the payment has been confirmed, simply do one of two things until you can detect that the payment has been confirmed:

    1. Add the 'disabled' attribute to the Submit button. This will grey out and disable the Submit button, rendering it unusable. However, since the button would still be visible and all, a web-savvy end user might just go into the HTML and remove the disabled attribute and be on his merry way.

    <button type="submit" disabled>Submit Listing</button>

    1. Hide the Submit button. In this case, the web-savvy end user could technically still go into the HTML and remove the styling so that the button is visible, but without seeing it...well, you know, 'out of sight, out of mind'

    <button type="submit" style="display:none">Submit Listing</button>


    Question Does the PayPal 'Buy Now' button return any information confirming the process was successful?

    Again, there's a few ways of attacking this.

    Method 1 The simplest way might be to use the PayPal Return URLs and some GET parameters to tell you whether or not things were completed or cancelled. There is something like a Return URL for Cancellations and a Return URL for Completions. From that same page that I linked, PayPal documents the creation of a button with respect to this feature:

    Take buyers to a specific webpage (URL) after checkout cancellation (optional)?

    Select the checkbox and enter a URL in the text box if you have a special page on your website where you want buyers to return to if they cancel their checkouts before completing their transactions.

    Take buyers to a specific webpage (URL) after successful checkout (optional)?

    Select the checkbox and enter a URL in the text box if you have a special page on your website where you want buyers to return to after they complete checkout successfully.

    Method 2 The more advanced way (which is also more foolproof, given that in the first Method a hacker could try and guess your Successful Return URL) is using PayPal's Instant Payment Notification feature. With this feature, PayPal sends a POST request to a private (behind the scenes) URL which allows you to capture the data it sends you pertaining to the payment completion.

    So your backend receives the information on the completion of the payment, and there are countless ways (AJAX requests, require the user refresh the browser or send the user an email telling them to come back and finish it, etc) that you can go about updating the frontend for the user so that they can use the now visible/enabled Submit button.

    For details and documentation on PayPal's notify_url through their IPN system.

    Best of luck!

    0 讨论(0)
  • 2021-01-22 11:43

    I think you will find PayPal supply merchant scripts which will do something like that. Instant Payment Notification under PayPal settings - only available in a business account.

    The php scripts you can download can be customised to do pretty much whatever you want once they return from payment. On a successful purchase you can echo the submit button so that it is physically not present unless they are returning after payment echo '<input type="submit" name="submit">';

    Under "Tools and Settings" "Process My Orders"

    You then need to make adjustments in the PayPal merchant interface to return the user to your IPN script.

    0 讨论(0)
提交回复
热议问题