Paypal Form Payment correct workflow - asp.net

I need to integrate payments with PayPal and I'm using the form integration
<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="return" value="http://example.com/Thankyou.html">
<input type="hidden" name="notify_url" value="http://example.com/IPN">
<input type="image" name="submit" border="0" src="/img/logos_icons/paypal-btn.png" alt="PayPal - The safer, easier way to pay online">
</form>
After this point I'm a little bit confused: when the user click on the buy button is redirected on the PayPal website and when the transaction is completed is redirected on the "retun" link (a thank you page). At the same time PayPal send a notification (IPN) to the "notify_url".
is this the correct workflow?
if yes, in the notify method I should book the purchased products but how can I understand which is the original transaction linked to the current notification ?

You have the flow correct, although depending upon the nature of the transaction or user experience you are trying to provide you may have the fulfillment activity "book the purchased products") possible in two places: handled by the page the user the returns to (if they do return promptly and you want to fulfill the order immediately, e.g. so that they can navigate to a subscribed page) and via IPN to catch the cases where the user pays but does not return immediately to your site.
Generally you send a unique identifier of your choice to PayPal in the invoice field of the button; that identifier is linked to whatever context you need (purchase details/shopping cart, user account, whatever) on your side.

Related

Send amp-form data to mailchimp with Nextjs

I have a a standard amp form, with an email input, and a sumbit input, and a mailchimp endpoint.
<form
method="post"
action-xhr={`https://${DATACENTER}.api.mailchimp.com/3.0/lists/${LIST_ID}/members`}
target="_top"
>
<fieldset>
<input
type="email"
name="email"
placeholder="Enter your email"
required
className="email-input"
/>
<input
type="submit"
value="Sign Up"
className="sign-input"
/>
</fieldset>
</form>
now the problem is, i need to configure headers,to provide an Authorization API key, and to setup cors.
AMP requires to use xhr to send data. and i have no idea on how to do that inside nextjs, or a serverless function for that matter.
Maybe try this solution - https://www.miguoliang.com/how-to-build-a-mailchimp-embed-form-in-amp-pages.html
You'll have to make an API using mailchimp's python library and provide the credentials and use that API to post data from the form.

How to pass custom amount with Bitpay hosted checkout form?

I am looking to integrate BitPay for processing bitcoin payments on one of my sites.
Their hosted checkout form (similar to PayPal checkout form) is easy to integrate however I don't know how I can pass order amount with the form so that the same checkout button can be used for different orders (payments).
Here's their page regarding hosted checkout: https://bitpay.com/help-hosted-checkout
Bitpay has clearly stated that we can pass different order amount but they have not provided any field for this on the above mentioned page. I have contacted them and they will reply in 3 days but since I need to integrate this at the earliest, I hope somebody here can help me fast.
Thanks.
I was also looking for help with a bitpay button for a project and found this question (and another one like it), so coming back to answer in case it can help others in the future: If you got your bitpay button code from the payment button option on bitpay, your code might look something like this:
<form action="https://test.bitpay.com/checkout" method="post">
<input type="hidden" name="action" value="checkout" />
<input type="hidden" name="posData" value="" />
<input type="hidden" name="price" value="<?php echo $price_var;?>" />
<input type="hidden" name="data" value="...(your data value)..." />
<input name="checkout" type="submit" value="Checkout" class="form-button-submit button"/>
</form>
Having the line of code with 'name="price"' allows you to set a global variable (potentially your shopping cart total) as an order amount. Hope this helps!

PayPal IPN not calling notify_url

So I have this form in my Wordpress site and I've configured it to use the PayPal sandbox:
<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="daniel-facilitator#domain.com">
<input type="hidden" name="item_name" value="Test - 11/11/2017">
<input type="hidden" name="item_number" value="13877">
<input type="hidden" name="notify_url" value="http://b1248fa5.ngrok.io/wp-admin/admin-ajax.php?action=eab_paypal_ipn&blog_id=1&booking_id=1">
<input type="hidden" name="amount" value="5">
<input type="hidden" name="return" value="http://b1248fa5.ngrok.io/events/2017/11/test/">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="quantity" value="1" max="1">
<p>Haz click aquĆ­ para pagar tu entrada</p><input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
</form>
It is generated by the Event + plugin. I has been working fine all year round until now.
This is what is happening:
I submit the form.
I get to my sandbox account's login page. I login.
My sandbox account's dashboard opens up.
Nothing happens... I'm waiting for PayPal to call my notify_url handler, but it doesn't!
If I use the PayPal IPN simulator with the same notify_url, then it is a whole other story. I get a message saying:
IPN was not sent, and the handshake was not verified. Please review your information.
However, in this case, my notify_url does get called.
What could be going on here? Why PayPal is not calling my notify_url when I submit my form?
The IPN will not be triggered until a transaction is completed. It sounds like you're not fully completing the transaction before expecting to see it hit..??
If you are completing the transaction and you aren't getting what you expect then you need to check the IPN History in the PayPal account to see if it's showing that IPNs are being sent and what the response is on them. Based on what you see there you'll go one direction or another.
If it looks like it's sending things fine, then you'll need to check the web server logs to see what's happening when your IPN URL gets hit. There must be an error happening.
For more details take a look at my article on how to test PayPal IPN.

Paypal Donation Button in asp.net page

I've created a paypal donation button from paypal business account with all default setting. I copy paste the html into my asp.net page, and it looks fine. The problem is when I click on the button simply nothing happen. Is this because I'm still on localhost? Will it be work and go to paypal page when I upload the website?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="buttonId">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Your asp.net page probably already has a form tag on it and you may have placed the PayPal code inside that form, which won't work. Instead of using the form with the hidden fields that PayPal generated for you, you could just use a link with url parameters. Here's an example (make sure you replace YOUR_BUTTON_ID_HERE with your id):
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YOUR_BUTTON_ID_HERE">
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" alt="PayPal - The safer, easier way to pay online!" />
</a>
Good afternoon. In your original example, no hosted button ID was provided:
<input type="hidden" name="hosted_button_id" value="buttonId">
PayPal buttons are hosted on your PayPal account, so in order for the checkout to appear, an ID must be present.
In order to locate the hosted button ID, log in to your PayPal account and go to Tools > PayPal Buttons. Click on the carat next to the button you are trying to add, and the button ID will display. Just substitute that value for "buttonId", and it should be working.

Detecting which option was selected by the buyer in PayPal IPN Listener

I'm testing my IPN handler with micro-payments using Live PayPal and I want to know how to detect what option was selected when the user clicked my PayPal "Buy Now" button. I've checked many places and found conflicting documentation and guidance.
Based on another StackOverflow thread, I added the last 4 hidden elements below to the SELECT drop-down OPTION(s) on the ASP.NET page with my Buy Now button:
<input type="hidden" runat="server" name="hosted_button_id" value="WYUM54ACPKUH6" id="hosted_button_id"/>
<input type="hidden" name="on0" value="SubType"/>SubType
<select name="os0">
<option value="S10">Standard (10 users) $0.04 USD</option>
<option value="ENT">Enterprise (unlimited) $0.05 USD</option>
</select>
<input type="hidden" name="option_select0" value="S10"/>
<input type="hidden" name="option_select1" value="ENT"/>
<input type="hidden" name="option_amount0" value="0.04" />
<input type="hidden" name="option_amount1" value="0.05" />
These are not being POSTed back. In a specific test case, I bought the "Standard" option for $0.04 and dumped out the Form variables posted back to my site from PayPal and here are the only things even close to what I am looking for:
option_name1 = SubType
option_selection1 = S10
payment_gross = 0.04
The threads I read and the doc I read emphasized the naming convention of the OPTION elements and the name and value of the corresponding hidden elements as being as shown above. YET - my testing indicates different things being posted back regarding the choice that was made by the user (i.e. me).
One specific thing is why the suffix is 1 when it seems like it should be 0 (since that first choice and it should be relative to 0). Is there anybody who can clarify what to expect?

Resources