简体   繁体   中英

paypal/rest-api-sdk-php PHP simple example

I try to integrate paypal in my webapp.

I want to use paypal/rest-api-sdk-php for PHP

I checked tons of examples, but all of them look so complex, i need just simplest integration.

I want a user to enter an amount in a form and click "pay". after this i will build/get redirect url, redirect user to paypal , paypal redirects me back and i validate if payment was success. If possible, i would not use IPN, but just some way to validate after redirect back.

Is there some simple example that does this workflow with modern PHP sdk?

Thanks

Why you are using hard word like "rest" or "rest-api" even you have to redirect user on PayPal site. Api are useful in case you want to do transaction without redirecting user on PayPal site.

One simple HTML form is provided by PayPal to achieve your requirement.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="seller@designerfotos.com">
<input type="hidden" name="item_name" value="hat">
<input type="hidden" name="item_number" value="123">
<input type="hidden" name="amount" value="15.00">
<input type="hidden" name="return" value="http://yourdomain.com/return">
<input type="hidden" name="first_name" value="John">
<input type="hidden" name="last_name" value="Doe">
<input type="hidden" name="address1" value="9 Elm Street">
<input type="hidden" name="address2" value="Apt 5">
<input type="hidden" name="city" value="Berwyn">
<input type="hidden" name="state" value="PA">
<input type="hidden" name="zip" value="19312">
<input type="hidden" name="night_phone_a" value="610">
<input type="hidden" name="night_phone_b" value="555">
<input type="hidden" name="night_phone_c" value="1234">
<input type="hidden" name="email" value="jdoe@zyzzyu.com">
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
</form>

Add your PayPal account email in the field of "business". Set amount entered by user in the field "amount" and set return url in the field "return".

If you need more help the check url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM