What is the easiest way to integrate PayPal into a registration system? - php

How do I integrate a one time fee into paypal?
The user clicks SignUp then is taken to a page to confirm t&c's and where they pay £50, they are then - if successful, taken to a page where they can enter details and create an account... but I only want this page to be visible to users coming from paypal.
I thought about using tokens, but I do not know how to use them.

You can use the paypal IPN which they are plenty of code samples and the paypal sandbox has some great tools to get you started.
The flow would work like this.
User selects that they want to sign up on your site and they fill out a form (contact info, accept terms and conditions, etc).
They then click purchase registrations, etc.
Your site posts all the details of the contact form along with the cost of registration to Paypal for the user to pay.
The user completes payment on the paypal site and is taken to a success page which informs them they will shortly receive an email regarding their registration.
Your back end...
1. After the user pays, paypal will post the details of the transaction to a URL you provide.
2. Your system completes a handshake over a connection to paypal.
3. Paypal sends the details of the transaction back to your server and you validate the total and any other necessary validations.
4. After validation, you system generates an email to the new user with their account details.
Let me know if that does not make sense or what additional elaborations are needed. Also if you let me know what language your coding in, I can pull up some sample code for you.
[EDIT]
Here is a URL to the paypal IPN --> https://www.paypal.com/ipn
--Dan
[edit]
Here is an example form. This form posts a single item for payment to paypal.
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="rm" value="2" id="PayPalRm" />
<input type="hidden" name="cmd" value="_xclick" id="PayPalCmd" />
<input type="hidden" name="business" value="seller#paypal.account" id="PayPalBusiness" />
<input type="hidden" name="return" value="http://localhost/inventories/success" id="PayPalReturn" />
<input type="hidden" name="cancel_return" value="http://localhost/inventories/cancel" id="PayPalCancelReturn" />
<input type="hidden" name="notify_url" value="http://localhost/Paypal_orders/process" id="PayPalNotifyUrl" />
<input type="hidden" name="item_name" value="product name" id="PayPalItemName" />
<input type="hidden" name="quantity" value="1" id="PayPalQuantity" />
<input type="hidden" name="no_shipping" value="2" id="PayPalNoShipping" />
<input type="hidden" name="shipping" value="2.5" id="PayPalShipping" />
<input type="hidden" name="shipping2" value="2.5" id="PayPalShipping2" />
<input type="hidden" name="no_note" value="1" id="PayPalNoNote" />
<input type="hidden" name="lc" value="US" id="PayPalLc" />
<input type="hidden" name="country" value="US" id="PayPalCountry" />
<input type="hidden" name="bn" value="PP-BuyNowBF" id="PayPalBn" />
<input type="hidden" name="amount" value="12" id="PayPalAmount" />
<div class="submit"><input type="submit" value="Click Here" /></div></form>

Related

paypal subscription error when doing the purchase on live site, but works on sandbox. "Action could not be completed"

I have 2 purchase button for paypal.
Regular checkout (this works perfectly well in sandbox AND live site)
A recurring payment.
The recurring button works perfectly well in the sandbox. I can make the transaction, no problem. Everything is good.
If I switch over the live site, my #1 (regular checkout button still works with a real money exchange), but my recurring button doesn't.
It Does bring me to the paypal subscription payment page. I use a paypal account with real live credits in it (NOT the same account as the seller's account). And when I press login, I see:
Sorry — your last action could not be completed
If you were making a
purchase or sending money, we recommend that you check both your
PayPal account and your email for a transaction confirmation after 30
minutes.
If you came to this page from another website, please return to that
site (don't use your browser's Back button) and restart your activity.
If you came from PayPal's website, click the PayPal logo in the
upper-left corner to return to our home page and restart your
activity. You might have to log in again.
I tried the following:
Change browser, FF and Chrome
Clear all cache, cookies
I am not using frames as other people have suggested
Nothing works.
here is my code to submit to paypal, in case someone sees a mistake:
<form name="_xclick" action="https://www.paypal.com/ca/cgi-bin/webscr" id="myform" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="MY EMAIL HERE">
<input type="hidden" name="item_name" value="MY NAME Subscription">
<input type="hidden" name="add" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" id="currency" value="<?=$currency?>">
<input type="hidden" name="a3" id="hiddentotal2" value="<?=$total2?>">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="custom" id="custompaypal" value="<?=$custom?>">
<input type="hidden" name="notify_url" value="http://www.mysite..../notify_paypal.php">
<input type="hidden" name="return" value="http://www.mysite..../myorders.php">
<input class="submit-button2" type="submit" name="submit" value="PURCHASE SUB" />
</form>
What could be causing this and how can I fix this.

How to transform PayPal Classic Payment form into PayPal REST API PHP Application?

The following is the simplest PayPal interface form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="JohnDoe2#example.com" />
<input type="hidden" name="item_name" value="Purchase at the Virtual Store" />
<input type="hidden" name="item_number" value="Organic-001" />
<input type="hidden" name="amount" value="17.4" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="notify_url" value="http://www.example.com/paypalnotify.php" />
<input type="submit" name="submit" value="Pay now By PayPal" />
</form>
This form is specific to a PayPal premier business account and a given amount to pay, with following key parameters:
business=JohnDoe2#example.com.
amount=17.4EUR.
currency_code=EUR or USD.
notify_url as the callback for PayPal.com as it ends.
By clicking on the [submit] button, it perfoms this:
It redirects the customer to the paypal.com site.
The user will login into her/his PayPal account, and validate the payment.
The PayPal site will call the paypalnotify.php like a callback, passes information indicating if the payment has suceeded, cancelled, or not valid...
Now in the new interface using PalPal REST API, using PHP development kit, how one has to proceed to accomplish the payment ?
There are a few options. Start by looking at the code in these files:
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePayment.php
https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePaymentUsingPayPal.php
Obviously they don't have any interactive forms, but they show the general process. Dig in and work through creating your code. Then when you hit problems, open a new question with the specific issues. StackOverflow is not for "how do I" type questions. https://stackoverflow.com/help/on-topic

Paypal Subscription check with PHP for non hosted button

I am having a peculiar problem implementing recurring payment for a webapp that I am developing. I could not use a hosted paypal subscription button, because the payment sum would be variable. So, I used a non hosted solution something like this :
<form action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="business#email.com">
<input type="hidden" name="item_name" value="Some item"/>
<input type="hidden" name="return" value="return_url">
<input type="hidden" name="cancel_return" value="cancel_url">
<input type="hidden" name="notify_url" value="notification_url">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="a3" value="variable_amount">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
<input type="hidden" name="custom" value="planid1,planid2"/>
</form>
Now, I need to check every month using a cron that who has paid, and generate content according to that.
From the discussions all over the internet, it is clear that paypal doesn't send txn_id for the subscription. So, how am I supposed to check if user has paid in the next month or not?
One thing that comes to my mind is an IPN listener, but will that work with a non-hosted button? Totally confused with this. Could someone point me to the right direction?
IPN would be the way to go. With IPN, your system would be notified when the profile is created, when the profile bills the user again, when the profile is canceld, or when it fails to bill. You would also get the transaction id back in the IPN each thim the profile is charged.

PayPal _cart Upload to Sandbox never allows login

So I have been doing a lot of Googling on PayPal's _cart Upload ability and so far, this is what I have managed to put together. And this seems to be working just fine; I am taken to a PayPal page with the purchase info and it asks me to login. But when I login with a Sandbox buyer account, it simply shows that it's logging me in but it never logs me in nor does it allow me to complete the purchase. The merchant sandbox account is working fine as it displays the Example store name on the PayPal page.
<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="xxx#xxx.xxx">
<input type="hidden" name="item_number_1" value="3">
<input type="hidden" name="item_name_1" value="Foo">
<input type="hidden" name="amount_1" value="22.97">
<input type="hidden" name="shipping_1" value="0">
<input type="hidden" name="shipping2_1" value="0">
<input type="hidden" name="quantity_1" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="22.97">
<input type="hidden" name="notify_url" value="http://******/order.php">
<input type="hidden" name="no_shipping" value="2">
<input class="paypal_button" type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
Am I doing something wrong when I'm logging in to PayPal or is the _cart upload ability deprecated after PayPal moved to a new a developer site and API? Any and all help would be appreciated it, I have been banging my head against the wall for hours trying to figure out what I'm doing wrong.
I don't think it'd make a difference but I am using PHP to generate the checkout information.
Thank you very much for your help.
I just submitted a payment using your code and my own sandbox account. It worked fine for me.
PayPal's servers can sometimes be pretty finicky with cookies in browsers. Close your browser (all instances of it so it's completely closed) and then reopen it and try again. Make sure you're signed in at developer.paypal.com before you try it and you should be just fine.

Amazon Checkout Sandbox failing to Process Order

My goal is to integrate our website with Amazon Checkout. We have already interfaced with both google and paypal apis with minor issues. However, with Amazon we have tried their provided PHP code and tried using create a button. With the PHP code in the sandbox we can get to finalizing the order, but then it gives an error saying Payment Failed your debit card was not charged. In the seller central it gives no information at all that anything ever happen.
When trying to create a button with amazons tool, and changing the address to the sandbox address instead, it says you must send the payment to a verified e-mail address and account.
The account has a credit card on it, verified bank account, tax information completed and verified e-mail.
Has anyone else has similar issues with amazon? Is there an exciting non-amazon based project that has successfully interfaced with Amazon that can be used for a reference. Amazon's documentation is... lacking and all over the place.
<form action="https://authorize.payments-sandbox.amazon.com/pba/paypipeline" method="POST">
<input type="image" src="https://authorize.payments-sandbox.amazon.com/pba/images/payNowButton.png" border="0">
<input type="hidden" name="accessKey" value="MERCHANT_KEY_REMOVED">
<input type="hidden" name="amount" value="USD 1.1">
<input type="hidden" name="description" value="Test of the Vidya Amazon Payment Alpha">
<input type="hidden" name="recipientEmail" value="MERCHANT_EMAIL_REMOVED">
<input type="hidden" name="signatureMethod" value="HmacSHA256">
<input type="hidden" name="referenceId" value="2">
<input type="hidden" name="immediateReturn" value="0">
<input type="hidden" name="returnUrl" value="http://yourwebsite.com/return.html">
<input type="hidden" name="abandonUrl" value="http://yourwebsite.com/cancel.html">
<input type="hidden" name="processImmediate" value="1">
<input type="hidden" name="ipnUrl" value="REMOVED">
<input type="hidden" name="cobrandingStyle" value="logo">
<input type="hidden" name="collectShippingAddress" value="0">
<input type="hidden" name="fixedMarketplaceFee" value="0.01">
<input type="hidden" name="variableMarketplaceFee" value="4">
<input type="hidden" name="signatureVersion" value="2">
<input type="hidden" name="signature" value="REMOVED">
</form>
So here's the scoop. With immediate processing set to 1 you have to leave out the Fee fields, otherwise it will never be accepted.
These two need to be removed for it to work
<input type="hidden" name="fixedMarketplaceFee" value="0.01" />
<input type="hidden" name="variableMarketplaceFee" value="4" />
If you use AWS SimplyPay PHP files you have to remove the variables from all 3 files in order for them to work. Or set processImmediate = 0.

Categories