forked from nov/paypal-express
-
Notifications
You must be signed in to change notification settings - Fork 0
Instant Payment
aileron edited this page Aug 20, 2012
·
7 revisions
Call SetExpressCheckout
using this code and let user redirect to the given redirect URI.
request = Paypal::Express::Request.new(
:username => SET_YOUR_OWN,
:password => SET_YOUR_OWN,
:signature => SET_YOUR_OWN
)
payment_request = Paypal::Payment::Request.new(
:currency_code => :JPY, # if nil, PayPal use USD as default
:amount => SET_YOUR_OWN,
:description => SET_YOUR_OWN
)
response = request.setup(
payment_request,
YOUR_SUCCESS_CALBACK_URL,
YOUR_CANCEL_CALBACK_URL
)
response.redirect_uri
Assume the end-user approved the payment request on PayPal.com and redirect back to your site.
In the redirect back request, you get token
and PayerID
in query string.
Call GetExpressCheckoutDetails
using this code and ask the user for final approval.
response = request.details(token)
# inspect these attributes for more details
response.payer
response.amount
response.ship_to
response.payment_responses
Call DoExpressCheckoutPayment
using this code.
response = request.checkout!(
token,
payer_id,
payment_request
)
# inspect this attribute for more details
response.payment_info