I need to get Transaction data(date, valued) and user adata.Can I use this gem with some modifications as in this question?
Also, from documentation:
For example, if you plan to query PayPal using getBasicPersonalData and getAdvancedPersonalData, you might generate a merchant model like:
rails generate paypal_permissions merchant email:string first_name:string last_name:string full_name:string country:string payer_id:string street1:string street2:string city:string state:string postal_code_string phone:string birth_date:string
bundle exec
rake db:migrate
I should use Payment Data Transfer (PDT) or TRANSACTION_DETAILS? It is place,where I will write data, but how I can get data from PayPal ?
Can anyone give me example of code ?
Step 1: Create a plan using the PayPal API. Step 2: Update the last product in the database paypal_plan_name with the returned plan.id . Step 3: Add routes for PayPal subscription. Step 4: Handle create and execution in the PayPal service.
A pre-authorisation hold is the term commonly used by banks in situations where a customer purchases services or goods using a credit/debit card, or a digital wallet (e.g. PayPal) and an amount is held by the customer's bank on behalf of the merchant as a 'pre-authorised hold'.
Have a PayPal account in good standing. Pay for the eligible item from your PayPal account. Attempt to contact the seller to resolve your issue directly before filing a claim through the Resolution Center. Respond to PayPal's request for documentation and other information within the time requested.
Paypal Adaptive seems to be the way to go on this, here are some documentation I found, hope it helps.
As usual the PayPal documentation is quite messy and disorganised and thus I thought I’d document how I managed to get PayPal Adaptive working on a marketplace style website.
Please use this post as a guide as to how the paypal API connects with your rails app. As Jamesw in the comments below points out, I have not created an adequate way of recording all details of each transaction; something that is no doubt required by law. So perhaps take a look at his comment after reading this. Hopefully you can work out a way to do this
After some searching I found that the best gem to use right now is paypal_adaptive. ActiveMerchant currently does not support PayPal Adaptive (there is a gem that add’s it in but it does not seem to be maintained.)
# Gemfile
gem 'paypal_adaptive'
PayPal Adaptive is relatively simple, yet the messy documentation can make it appear daunting. Put simply, this is how I did it:
Go here to create a sandbox account (you will need it). Once logged in go to “Create a preconfigured account”. Create two accounts – one buyer and one seller. If you are using chained or parallel payments (payments that are split amongst more than one person) then create some more accounts.
Click on Api Credentials in the left hand side panel.
Now fill out your paypal_adaptive.yml using those credentials (also use the application_id I provide below – this is the testing application_id provided by www.x.com
development:
environment: "sandbox"
username: "platts_xxxxxxxx_biz_api1.gmail.com"
password: "xxxxxxxxxxxx"
signature: "xxxxxxx"
application_id: "APP-80W284485P519543T"
test:
environment: "sandbox"
username: "platts_xxxxxxxx_biz_api1.gmail.com"
password: "xxxxxxxx"
signature: "xxxxxxxx"
application_id: "APP-80W284485P519543T"
production:
environment: "production"
username: "my_production_username"
password: "my_production_password"
signature: "my_production_signature"
application_id: "my_production_app_id"
Here you only really need the amount of money to be paid and a list of the emails you want that money to go to. So write your logic to work that out and then make a call to PayPal to setup the purchase.
pay_request = PaypalAdaptive::Request.new
data = {
"returnUrl" => return_url,
"requestEnvelope" => {"errorLanguage" => "en_US"},
"currencyCode" => "USD",
"receiverList" =>
{ "receiver" => [
{"email" => "[email protected]", "amount"=> amount}
]},
"cancelUrl" => cancel_url,
"actionType" => "PAY",
"ipnNotificationUrl" => ipn_url
}
#To do chained payments, just add a primary boolean flag:{“receiver”=> [{"email"=>"PRIMARY", "amount"=>"100.00", "primary" => true}, {"email"=>"OTHER", "amount"=>"75.00", "primary" => false}]}
pay_response = pay_request.pay(data)
if pay_response.success?
# Send user to paypal
redirect_to pay_response.approve_paypal_payment_url
else
puts pay_response.errors.first['message']
redirect_to "/", notice: "Something went wrong. Please contact support."
end
I route my IPN call from PayPal to this method:
def ipn_notification
ipn = PaypalAdaptive::IpnNotification.new
ipn.send_back(request.raw_post)
if ipn.verified?
logger.info "IT WORKED"
else
logger.info "IT DIDNT WORK"
end
render nothing: true
end
Unfortunately if you are on localhost, PayPal can’t send you the IPN, and hence there is a problem with testing this whole process. Ryan Bates’ solution is to use curl to mimic an IPN request. However as you can see in the code above, we make another request to PayPal confirming that the IPN is real. So even with curl sending a fake IPN, we run into problems. I’m going to go hunt for solutions now, but please comment if you have any ideas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With