Giter VIP home page Giter VIP logo

paypal-express's Introduction

paypal-express

Handle PayPal Express Checkout. Both Instance Payment and Recurring Payment are supported. Express Checkout for Digital Goods is also supported.

<img src=“https://secure.travis-ci.org/nov/paypal-express.png” />

Installation

gem install paypal-express

Usage

See Wiki on Github github.com/nov/paypal-express/wiki

Play with Sample Rails App github.com/nov/paypal-express-sample paypal-express-sample.heroku.com

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2011 nov matake. See LICENSE for details.

paypal-express's People

Contributors

aeden avatar beefsack avatar chewi avatar davidjrice avatar evilmarty avatar hanzawa avatar henrik avatar martinciu avatar matheusbras avatar maximgladkov avatar mstruve avatar nbibler avatar nov avatar olegkrachun avatar pda avatar rromanchuk avatar soulim avatar stuart avatar tei avatar thurtt avatar warlley avatar wear avatar zunger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-express's Issues

Questions

Hi, I've been trying to set up paypal-express into my app but I have a couple of questions:

  • What's the URL to submit the form and redirects to PayPal? I'm looking to have a simple form but I can't get how it triggers paypal redirection. I want to do f.submit and it goes to paypal. How? please advise.

I have a working version with rails 3.2.12 I can submit if you want to upgrade the repo.

Adding a response field

When dealing with multiple currencies, Paypal sends back an extra response field containing the exchange rate used in the transaction (which the gem is logging as ignored) called PAYMENTINFO_0_EXCHANGERATE

I was wondering how I'd go about retrieving that and including it in the payment_info object?

Many thanks

Production setup?

Hi, can you provide some production setup instructions? BTW, I was able to get the PayPal sandbox working. However, when I t checkout in the production setup, it immediately redirects to the to the root URL. Also, I have checked all the logs and the only thing that I can see is 'Completed 302'. At this point, I'm guessing that the production credentials haven't been properly enabled by PayPal.

-Conrad

Paypal Api Version

Hello,

I am wondering is there a reason why the gem is using such an old version of the Paypal Api (88.0). I believe the latest Version on Paypal is 119.

I ask as our support contact at Paypal has informed us we should be using a more updated version.

Thanks

Instant Payment not Redirecting

I dont know if Im wrong, but isnt this gem supposed to redirect you to paypal for processing the payment on the instant payment?

I have copied all your code from wiki and happens that it seems to work but do not redirect anything to paypal.

Thanks in advance

Getting 'payment_request' var to receive info about payment

First of all, I want to thank you for a wonderful library. It is just what I was looking for. Pure way to execute simple paypal payment :)

I'm facing the problem how to get 'payment_request' var in "successful_payment" action,

def successful_payment
        response = request.checkout!(
              params[:token],
              params[:PayerID],
              payment_request
            )
        end
        response.payment_info
        #error: payment_request is not defined
end

How can I move payment_request, which is in my Instant payment request action(if I understand this correctly) to this one? Thank you so much. Any thoughts would be great!

Ability to send shipping address details to PayPal

Hi there,

As far as I see (https://github.com/nov/paypal-express/blob/97971f05605b0bf56ba60219017bdaeaabe23d0d/lib/paypal/payment/request.rb) there is no way atm to send shipping address details to PayPal on request with paypal-express gem, right?
From PayPal documentation it is possible:

&PAYMENTREQUEST_0_SHIPTONAME=...
&PAYMENTREQUEST_0_SHIPTOSTREET=...
&PAYMENTREQUEST_0_SHIPTOCITY=...
&PAYMENTREQUEST_0_SHIPTOSTATE=CA
&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=US
&PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME=United%20States
&PAYMENTREQUEST_0_SHIPTOZIP=94666
&PAYMENTREQUEST_0_ADDRESSID=...
&PAYMENTREQUEST_0_ADDRESSSTATUS=Confirmed

Allow

Would be nice to have
response = paypal_request.setup(payment_request, :pay_on_paypal => true)

Add "activation" in the param of recurring payment init, so it will charge 1 immediately upon complete.

Related to issue #51.

I think current recurring payment won't charge immediately (for the first month) upon complete. And I found add a "activation" param to make it happen (am I wrong?). Since it's quite normal to charge immediately for recurring payments, maybe can add this option in the wiki docs?

Paypal::Payment::Recurring.new(
      start_date: SET_YOUR_OWN,
      description: SET_YOUR_OWN,
      activation: {
        initial_amount: SET_YOUR_OWN
      },
      billing: {
        period: :SET_YOUR_OWN,
        frequency: SET_YOUR_OWN,
        amount: SET_YOUR_OWN
      }
    )

Error when trying to change from sandbox mode.

I am trying to set up a paypal express chechout. When I switch from sandbox to production I get a paypal security error.

 PayPal API Error: 'Security error' # [#"10002", :SHORTMESSAGE=>"Security error", :LONGMESSAGE=>"Security header is not valid", :SEVERITYCODE=>"Error"}, @error_code="10002", @severity_code="Error", @long_message="Security header is not valid", @short_message="Security error">]

Everything works well in sandbox mode, I have also contacted paypal and they have assured me my keys are not sandbox/test keys. When looking for this error on stack overflow most people say check keys. which I have done, I have also issued new ones just to be sure. The other suggestion is that I am posting to the wrong url but that is something handled by the gem so I don't think of as an issue.

Has anyone else had these problems?
have any suggestions

How to print full messages in exceptions

I tried searching for some method, in exception object, but I did not find it:

e.methods.grep /message/

I just get message method. But that message says:

PayPal API Error: 'Transaction refused because of an invalid argument. See additional error messages for details.'

Paypal::Exception::APIError: PayPal API Error: 'Transaction refused because of an invalid argument. See additional error messages for details.'

Getting this error:

Paypal::Exception::APIError in PaymentsController#create

PayPal API Error: 'Transaction refused because of an invalid argument. See additional error messages for details.', 'Transaction refused because of an invalid argument. See additional error messages for details.'

with the following code:

    request = Paypal::Express::Request.new(
      :username   => Settings.paypal.username,
      :password   => Settings.paypal.password,
      :signature  => Settings.paypal.signature
    )
    payment_request = Paypal::Payment::Request.new(
      :currency_code => :CAD,
      :amount        => 5.00,
      :description   => 'Fluffy bear'
    )
    response = request.setup(
      payment_request,
      '/success',
      '/cancel'
    )
    redirect_to response.redirect_uri

Not requiring a PayPal account

I need to add SOLUTIONTYPE=Sole to the request, so that users can just use a credit card, and not be PayPal members, to pay. Has anyone addressed that requirement -- adding additional arguments to a Request?

Add Changelog

Hey, since it's quite a critical gem for everyone using it it would be nice if following changes from version to version would be a little easier. Adding a Changelog could help a lot with that.
What do you say @nov?

Recurring payments (undefined method `closed?' for #<Hash:>)

When running the example code (see https://github.com/nov/paypal-express/wiki/Recurring-Payment)
I suddenly getting errors (since 30 augustus 2012) when making a call to

payment_request = Paypal::Payment::Request.new(
:currency_code => :EUR,
:billing_type => :RecurringPayments,
:billing_agreement_description => "My billing agreement"
)

/home/gummybears/bundler/common/ruby/1.9.1/gems/rest-client-1.6.7/lib/restclient/payload.rb:109:in close': undefined methodclosed?' for #Hash:0xa172b7c (NoMethodError)
from /home/gummybears/bundler/common/ruby/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:66:in ensure in execute' from /home/gummybears/bundler/common/ruby/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:66:inexecute'
from /home/gummybears/bundler/common/ruby/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in execute' from /home/gummybears/bundler/common/ruby/1.9.1/gems/restclient_with_cert-0.0.8/lib/restclient_with_cert.rb:17:inpost'
from /home/gummybears/bundler/common/ruby/1.9.1/gems/paypal-express-0.5.0/lib/paypal/nvp/request.rb:43:in post' from /home/gummybears/bundler/common/ruby/1.9.1/gems/paypal-express-0.5.0/lib/paypal/nvp/request.rb:36:inblock in request'
from /home/gummybears/bundler/common/ruby/1.9.1/gems/paypal-express-0.5.0/lib/paypal/nvp/request.rb:47:in handle_response' from /home/gummybears/bundler/common/ruby/1.9.1/gems/paypal-express-0.5.0/lib/paypal/nvp/request.rb:35:inrequest'
from /home/gummybears/bundler/common/ruby/1.9.1/gems/paypal-express-0.5.0/lib/paypal/express/request.rb:28:in setup' from recurring.rb:30:in

'

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

$ bundle list
Gems included by the bundle:

  • Ascii85 (1.0.1)
  • POpen4 (0.1.4)
  • Platform (0.4.0)
  • RedGreen (1.0)
  • actionmailer (3.2.8)
  • actionpack (3.2.8)
  • activemodel (3.2.8)
  • activerecord (3.2.8)
  • activerecord-import (0.2.10)
  • activeresource (3.2.8)
  • activesupport (3.2.8)
  • addressable (2.3.2)
  • arel (3.0.2)
  • attr_required (0.0.5)
  • autotest-standalone (4.5.9)
  • awesome_print (1.0.2)
  • bcrypt-ruby (3.0.1)
  • better-logging (0.0.2)
  • bootstrap-sass (2.0.4.2)
  • builder (3.0.0)
  • bullet (4.1.6)
  • bundler (1.1.4)
  • capybara (1.1.2)
  • childprocess (0.3.5)
  • chromedriver-helper (0.0.5)
  • chronic (0.6.7)
  • coderay (1.0.7)
  • coffee-rails (3.2.2)
  • coffee-script (2.2.0)
  • coffee-script-source (1.3.3)
  • colored (1.2)
  • cucumber (1.2.0)
  • cucumber-rails (1.3.0)
  • daemons (1.1.9)
  • database_cleaner (0.8.0)
  • deadweight (0.2.1)
  • diff-lcs (1.1.3)
  • domain_name (0.5.3)
  • email_spec (1.2.1)
  • erubis (2.7.0)
  • eventmachine (0.12.10)
  • execjs (1.4.0)
  • factory_girl (4.0.0)
  • factory_girl_rails (4.0.0)
  • fakeweb (1.3.0)
  • ffi (1.1.5)
  • foreigner (1.2.1)
  • gherkin (2.10.0)
  • hashery (2.0.1)
  • hike (1.2.1)
  • i18n (0.6.1)
  • immigrant (0.1.2)
  • jasmine (1.2.1)
  • jasmine-core (1.2.0)
  • journey (1.0.4)
  • jquery-rails (2.1.1)
  • jquery-ui-rails (2.0.0)
  • json (1.7.5)
  • kaminari (0.13.0 a8637f2)
  • launchy (2.1.2)
  • libnotify (0.7.3)
  • libv8 (3.3.10.4)
  • libwebsocket (0.1.5)
  • macaddr (1.6.1)
  • mail (2.4.4)
  • mechanize (2.5.1)
  • method_source (0.8)
  • mime-types (1.19)
  • multi_json (1.3.6)
  • mysql2 (0.3.11)
  • net-http-digest_auth (1.2.1)
  • net-http-persistent (2.7)
  • nokogiri (1.5.5)
  • notifier (0.2.1)
  • ntlm-http (0.1.1)
  • open4 (1.3.0)
  • parallel (0.5.18)
  • parallel_tests (0.8.9)
  • paypal-express (0.5.0)
  • pdf-reader (1.2.0)
  • polyglot (0.3.3)
  • prawn (0.12.0)
  • pry (0.9.10)
  • rack (1.4.1)
  • rack-cache (1.2)
  • rack-protection (1.2.0)
  • rack-ssl (1.3.2)
  • rack-test (0.6.1)
  • rails (3.2.8)
  • railties (3.2.8)
  • rake (0.9.2.2)
  • rb-fsevent (0.9.1)
  • rb-inotify (0.8.8)
  • rdoc (3.12)
  • redis (3.0.1)
  • redis-namespace (1.2.1)
  • redisk (0.2.2)
  • resque (1.22.0)
  • resque-status (0.3.3 f466dbc)
  • rest-client (1.6.7)
  • restclient_with_cert (0.0.8)
  • rspec (2.11.0)
  • rspec-core (2.11.1)
  • rspec-expectations (2.11.2)
  • rspec-mocks (2.11.2)
  • rspec-rails (2.11.0)
  • ruby-ole (1.2.11.4)
  • ruby-rc4 (0.1.5)
  • rubyzip (0.9.9)
  • sass (3.2.1)
  • sass-rails (3.2.5)
  • selenium-webdriver (2.25.0)
  • shoulda-matchers (1.3.0)
  • simplecov (0.6.4)
  • simplecov-html (0.5.3)
  • simplecov-rcov (0.2.3)
  • sinatra (1.3.3)
  • slop (3.3.3)
  • spreadsheet (0.7.3)
  • sprockets (2.1.3)
  • systemu (2.5.2)
  • test_notifier (1.0.0)
  • therubyracer (0.10.2)
  • thin (1.4.1)
  • thor (0.16.0)
  • tilt (1.3.3)
  • timecop (0.4.5)
  • treetop (1.4.10)
  • ttfunk (1.0.3)
  • tzinfo (0.3.33)
  • uglifier (1.2.7)
  • unf (0.0.5)
  • unf_ext (0.0.5)
  • uniform_notifier (1.0.2)
  • uuid (2.3.5)
  • vegas (0.1.11)
  • webrobots (0.0.13)
  • whenever (0.7.3)
  • xpath (0.1.4)
  • yui-compressor (0.9.6)

transaction_id of recurring payment

Get subscription details does not return list of transaction ids of each recurrent payment.
It is required for refund method.
Is it possible to refund recurring payment using this API?

Example not working

The site on Heroku with example of this gem is not working... seems like 5XX error.

Recurring payment does not accept currency code

Hi, I'm trying to perform a recurring payment but it doesn't accept a customizable currency code.

I'm creating a Paypal::Payment::Request using currency code defined as BRL (Brazillian currency code). It works well and I'm able to redirect the user to the authorization flow within paypal. But, when trying to subscribe I cannot define the currency code for the Paypal::Payment::Recurring and it gets the default currency code defined by paypal (USD). It generates an inconsistency because the currency codes don't match and paypal API throws "Invalid currency code".

Error number 11548 from https://developer.paypal.com/docs/classic/api/errorcodes/

API documentation that shows the expectation for CURRENCYCODE for recurring: https://developer.paypal.com/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/

Best,
Pedro.

Notify_url is not working for recurring payment

I have set the notify_url as below, but paypal doesn't send any notification on sandbox, I checked the paypal ipn history, its empty even I cancelled profile on paypal sandbox.

As for paypal checkout api, it should send the IPN notification but it doesn't.

  def client
     Paypal::Express::Request.new PAYPAL_CONFIG
  end

  def payment_request
    request_attributes = if self.recurring?
      {
        billing_type: :RecurringPayments,
        billing_agreement_description: DESCRIPTION[:recurring],
        notify_url: ipn_path
      }
  end 

  response = client.setup(
      payment_request,
      return_url,
      cancel_url,
      pay_on_paypal: true,
      no_shipping: true
    )
  def ipn_path
    Rails.application.routes.url_helpers.notification_url(secret: APP_CONFIG[:paypal_secret], host: APP_CONFIG[:domain])
  end

Paypal::Payment::Response::ShipTo doesn't have street2

I've made an order with a complete address, and got only this for details.ship_to:

@ship_to=
  #<Paypal::Payment::Response::ShipTo:0x00000005174378
    @owner=nil,
    @status=nil,
    @name="My Home",
    @zip="95131",
    @street="That street, 100",
    @city="San Jose",
    @state="CA",
    @country_code="US",
    @country_name="United States"
  >

There's no street2 field.
Also, there's no doc for the gem specifying what fields I can expect on response objects, or set in the request objects.

Coding against non-payments

I'm noticing that lately half the recurring payments I take in are not being paid. So, the workflow that is occurring is:

  1. User gets redirected to Paypal.
  2. Paypal creates the recurring profile.
  3. Paypal redirects the user back to my site.
  4. Payment is sometimes taken on the spot or taken anywhere from 30 seconds up to 24 hours.
  5. Meanwhile, user is able to use all of the services on my site without having paid.

I've checked and there's no way to code against the Paypal summary because of the delay in payment. What would happen is that all users would be denied services until a payment is verified. But, this could be very slow, especially in the case of waiting up to 24 hours for a payment to be processed. There also appears to be a payment/time stamp issue on payment collections depending on how close to midnight the payment is processed.

So, what I'm trying to find out is there anyone out there that has seen this type of issue and how are you coding against these non-payment scenarios? Are you creating an hourly recheck?

Any help would be appreciated. I love this gem and I'd like to not have to change it.

Getting 'PayPal API Error: 'Version error''

When trying to register transaction I get:

Paypal::Exception::APIError - PayPal API Error: 'Version error'

Full message says that version is not supported. I tried setting Paypal.api_version to latest and different values and it doesn't help.

This started happening suddenly yesterday. It was working fine few days ago.

full code of method

order = @order
    if(APP_CONFIG["paypal"]["sandbox"])
      Paypal.sandbox!
    end

    express_request = Paypal::Express::Request.new(
      :username   => APP_CONFIG["paypal"]["api_username"],
      :password   => APP_CONFIG["paypal"]["api_password"],
      :signature  => APP_CONFIG["paypal"]["api_signature"]
    )

    logger.info "==PPP Express::Request: #{express_request}"

    paypal_options = {
      no_shipping: true, # if you want to disable shipping information
      allow_note: false, # if you want to disable notes
      pay_on_paypal: true # if you don't plan on showing your own confirmation step
    }

    logger.info "==PPP paypal_options: #{paypal_options}"

    payment_request = Paypal::Payment::Request.new(
      :currency_code => "PLN",              # if nil, PayPal use USD as default
      :description   => order.pack.name,    # item description
      :quantity      => 1,                  # item quantity
      :amount        => order.total.round(2).to_f,
      :invoice_number => (order.id + 100000),
      :notify_url => APP_CONFIG["paypal"]["ipn_notify_url"]
    )

    response = express_request.setup(
      payment_request,
      "http://bookrage.org/paypal/success/#{order.return_token}",
      "http://bookrage.org/paypal/cancel/#{order.return_token}",
      paypal_options  # Optional
    )

    logger.info "==PPP response.redirect_uri: #{response.redirect_uri}"

    return response.redirect_uri

Still, example curl from paypal page works on sandbox event with my credentials

curl https://api-3t.sandbox.paypal.com/nvp \
>   -s \
>   --insecure \
>   -d USER=platfo_1255077030_biz_api1.gmail.com \
>   -d PWD=1255077037 \
>   -d SIGNATURE=Abg0gYcQyxQvnf2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf \
>   -d METHOD=SetExpressCheckout \
>   -d VERSION=78 \
>   -d PAYMENTREQUEST_0_PAYMENTACTION=SALE \
>   -d PAYMENTREQUEST_0_AMT=19 \
>   -d PAYMENTREQUEST_0_CURRENCYCODE=USD \
>   -d cancelUrl=http://www.example.com/cancel.html \
>   -d returnUrl=http://www.example.com/success.html
TOKEN=EC%2d6VH883273N101092R&TIMESTAMP=2016%2d07%2d14T21%3a04%3a57Z&CORRELATIONID=c34496e55ed38&ACK=Success&VERSION=78&BUILD=000000%

Checkout multiple items

Is there a way to checkout multiple items at once? I see that you can pass in a array of hashes into:

payment_request = Paypal::Payment::Request.new(
  :currency_code => :JPY, # if nil, PayPal use USD as default
  :amount        => SET_YOUR_OWN,
  :items => [{
    :name => SET_YOUR_OWN,
    :description => SET_YOUR_OWN,
    :amount => SET_YOUR_OWN,
    :category => :Digital
  }]
)

but the items key only seems to accept one hash, and no more. Is this intended behavior? Because that :items key is really misleading because it's plural and it's an array, making it look like I can add multiple items.

Error message when using the popup method

Hi there,

I've been struggling with the popup payment for a while now. I tried it like a month ago and got an error message so I thought let's try it later. I tried again now and still got the same error message :

We are unable to complete your request at this time. Please try again later. We apologize for the inconvenience.

The funny thing is the redirect method seems to be working fine.

Apparently someone else is having the same issue with the merchant-sdk-ruby gem, so I replied to his issue and I thought I might reference it here : https://github.com/paypal/merchant-sdk-ruby/issues/7

Any idea ?

Complete instance transaction

Hello,
My question: is when I am using Instant Payment I should execute "Complete the transaction" to finish the payment flow, but I don't understand what is "payment_request" variable and how it should looks.

response = request.checkout!(
token,
payer_id,
payment_request
)

inspect this attribute for more details

response.payment_info

Will appreciate if anybody could explain me what "payment_request" variable is.
Many thanks.

Feature Request: Refunds

r = Paypal::NVP::Request.new(:username   => PAYPAL[:username], :password   => PAYPAL[:password], :signature  => PAYPAL[:signature])

r.request('RefundTransaction', {'TRANSACTIONID' => '2VV74337KH776410C', 'REFUNDTYPE' => 'Full'})

{:REFUNDTRANSACTIONID=>"1E530441XU804092F", :FEEREFUNDAMT=>"1.16", :GROSSREFUNDAMT=>"40.00", :NETREFUNDAMT=>"38.84", :CURRENCYCODE=>"USD", :TOTALREFUNDEDAMOUNT=>"40.00", :TIMESTAMP=>"2011-05-18T21:43:15Z", :CORRELATIONID=>"d9cdfc1171d5c", :ACK=>"Success", :VERSION=>"69.0", :BUILD=>"1882144"} 

Would love to have something like this

req = Paypal::Express::Request.new(:username   => PAYPAL[:username], :password   => PAYPAL[:password], :signature  => PAYPAL[:signature])

refund = Paypal::Refund::Request.new(:transaction_id => '2VV74337KH776410C', :type => :full)
or 
refund = Paypal::Refund::Request.new(:transaction_id => '2VV74337KH776410C', :type => :partial, :amt => '10')
req.setup(refund).refund!

Phone Number Ignored

Phone numbers would be nice to have added:

Paypal::Express: Ignored Parameter (Paypal::Express::Response): PHONENUM=XXX-XXX-XXXX

Submit Cart items to Express Checkout

How can I submit the cart items so the customer can see them in the PayPal cart?

 payment_request = Paypal::Payment::Request.new(
         :currency_code => :EUR,
         :tax => 19.0,
         :shipping => 5.95,
         :amount => invoice_total,
         :items => ????,
         :allow_note =>  true,        
         :description =>  current_cart.cart_identifier,
         :country => "Germany",
         :notify_url => APP_CONFIG[:paypal_notify]
       )

       @response = request.setup(
           payment_request,
           APP_CONFIG[:paypal_success],
           APP_CONFIG[:paypal_cancel]
       )

Recurring payments

Hi,
I am using your gem to enable recurring payments. Looking at Ryan Bates screencast #289 using the paypal-recurring gem

  1. The customer selects a plan to subscribe
  2. A form is shown with the Paypal button
  3. Customer clicks on Paypal button and is redirected to Paypal to login and approve the subscription
  4. Customer approves the subscription and is redirected back to the sellers website
  5. Customer can now hit Subscribe which makes a call to Paypal (while staying on sellers website) to finalize the payment.

I use your sample code (thanks, which helps a lot) and implemented steps 1-4. But I still have to implement step 5
where the customer actually subscribes to the selected plan.
I looked at the source code of your gem, looked at the Paypal NVP API but I am unable to find the correct call to make.

Hope you can help
Thanks

Mapping of amounts different between request and recurring

paypal-express uses the same attribute for mapping amounts for the Payment::Request (SetExpressCheckout) and Payment::Recurring (CreateRecurringPaymentsProfile) but they are different:

I would recommend creating a new variable, Request#total_amount.

PayPal API Error: 'Security error'

Could you help me with this

PayPal API Error: 'Security error'

When calling

request.setup(
      payment_request(
        args[:amount],
        args[:description],
        args[:currency_code]
      ),
      args[:success_url],
      args[:cancel_url]
    )

This is request

Paypal::Express::Request.new(
      :username   => USERNAME,
      :password   => PASSWORD,
      :signature  => SIGNATURE
    )

I set these three constants with the strings I see in PayPal - API Explorer https://www.paypal-labs.com/apiexplorer/PayPalAPIs

This is args

{:amount=>#<BigDecimal:7fc128cd4bf0,'0.2E4',9(18)>, :description=>"my desc ", :currency_code=>:INR, :success_url=>"http://localhost:3333/payments/10/edit", :cancel_url=>"http://localhost:3333/services/1"}

Thanks in advance.

Security Error with recurring payments

I'm trying to setup a recurring payment, but I get an "Security Error" with long message "Security header is not valid"

I'm using the code from the wiki here: https://github.com/nov/paypal-express/wiki/Recurring-Payment

I've double checked the credentials (username, password, signature) but they seem fine.
Any ideas why this happens?

Here's the output from ex.response:

=> #<Paypal::Exception::APIError::Response:0x4f19f10 @raw={:TIMESTAMP=>"2014-01-18T09:13:58Z", :CORRELATIONID=>"dab969813aed6", :ACK=>"Failure", :VERSION=>"88.0", :BUILD=>"9285531", :L_ERRORCODE0=>"10002", :L_SHORTMESSAGE0=>"Security error", :L_LONGMESSAGE0=>"Security header is not valid", :L_SEVERITYCODE0=>"Error"}, @ack="Failure", @build="9285531", @colleration_id="dab969813aed6", @timestamp="2014-01-18T09:13:58Z", @Version="88.0", @order_time=nil, @pending_reason=nil, @payment_status=nil, @payment_type=nil, @reason_code=nil, @transaction_type=nil, @details=[#<Paypal::Exception::APIError::Response::Detail:0x4f1f328 @raw={:ERRORCODE=>"10002", :SHORTMESSAGE=>"Security error", :LONGMESSAGE=>"Security header is not valid", :SEVERITYCODE=>"Error"}, @error_code="10002", @severity_code="Error", @long_message="Security header is not valid", @short_message="Security error">]>

Paypal::Payment::Common::Amount should properly equate to Numerics

I just wanted to point out an unexpected result that I came across while upgrading:

In an upgrade from 0.2 to 0.4, one spec failure that occurred was that a Paypal::Payment::Request.new(amount: 12.34).amount.should == 12.34. While this is not exactly the spec, it's actual spec failed with the following error:

     Failure/Error: its(:amount) { should == 12.34 }
       expected: 12.34
            got: #<Paypal::Payment::Common::Amount:0x007fc5bc5a4a40 @total=12.34, @item=0, @fee=0, @handing=0, @insurance=0, @ship_disc=0, @shipping=0, @tax=0, @gross=0, @net=0> (using ==)

Anyway, it seems logical that an Amount should equate to a Numeric, when it's generated in this manor. I believe that this is especially true since Amount does not carry a currency type, so it's fairly safe to assume that creating an Amount with a Numeric should equate successfully when given the same Numeric.

Although, I could certainly see an argument against this, since Amount has been overloaded to carry fees, handling charges, shipping charges, and more... It just feels counter-intuitive to create a Request with an amount set as a numeric and receive back an instance of an object that cannot be equated to the same numeric from which it was generated.

Feel free to disregard and close out this ticket if you disagree. :)

ipn notify url for reference transactions

Hi,

I'm using paypal-express for paypal reference transactions.

All works as aspected but I can't find a way to specify the paypal ipn notify url.

Is it possible?

Thanks

Teo

Paypal::Exception::APIError (PayPal API Error)

site_url = Rails.application.config.site_url

request = Paypal::Express::Request.new(
:username => "username",
:password => "password",
:signature => "signature"
)

payment_request = Paypal::Payment::Request.new(
:currency_code => :USD,
:amount => params[:amount].to_i,
:description => "MPay2Park initial amount"
)

response = request.setup(
payment_request,
"http://#{site_url}/wallets/thank_you",
"http://#{site_url}/wallets/cancel"
)

I'm using Rails 3.1 rc4

Ability to supply custom "RAW" options

Hi, first of all thank you very much for creating and releasing this library.

I have been working to integrate the library into a project where we want to use PayPal. The project uses both PayPal instant payment and PayPal payment authorization and here comes the problem.

Currently, the paypal-express library doesn't support PayPal authorization, nor it provides authorization, void and capture methods. Moreover, integrating such feature at runtime or in a fork requires a lot of monkey patching because it's impossible to supply custom attributes on the fly to existing methods.

My proposal is to relax the method PayPal::Express::Request definitions in order to allow arbitrary parameters to be supplied at runtime.

Let me show you an example.

https://github.com/nov/paypal-express/blob/master/lib/paypal/express/request.rb#L42-52

Here's the current checkout! method.

def checkout!(token, payer_id, payment_requests)
  params = {
    :TOKEN => token,
    :PAYERID => payer_id
  }
  Array(payment_requests).each_with_index do |payment_request, index|
    params.merge! payment_request.to_params(index)
  end
  response = self.request :DoExpressCheckoutPayment, params
  Response.new response
end

In order to introduce the Authorization, I should be able to pass the PAYMENTREQUEST_0_PAYMENTACTION option and set it to Authorization or Order. But this is just an example, there is a number of additional fields I might want to supply to the :DoExpressCheckoutPayment call such as GIFTMESSAGE, BUTTONSOURCE, ...

PS. I know that PAYMENTREQUEST_0_PAYMENTACTION can be supplied using the Paypal::Payment::Request, but this is just an example.

My proposal is to change the method definition to something like

def checkout!(token, payer_id, payment_requests, options = {})
  params = {
    :TOKEN => token,
    :PAYERID => payer_id
  }

  merge_request_params(params, payment_requests)
  merge_optional_params(params, options)

  response = self.request :DoExpressCheckoutPayment, params
  Response.new response
end

private

def merge_request_params(params, payment_requests)
  Array(payment_requests).each_with_index do |payment_request, index|
    params.merge! payment_request.to_params(index)
  end
end

def merge_optional_params(params, options)
  options.each do |key, value|
    params.merge! key.upcase => value
  end
end


@request.checkout!(..., ..., [payment_request], :GIFTMESSAGE => "My personal gift to you.")

You already provide the options argument in some methods, however the options are filtered and custom values not mapped internally into the method are discarded. An other solution can be to pass an additional attribute so that options (currently reserved for ruby-oriented options) are not mixed with custom options.

The options value can be filtered or validated even further, but I believe that leaving the responsibility to the programmer can be a reasonable solution.

What do you think?

Paypal::Express::Request#subscription warnings: Ignored Parameter (Paypal::Express::Response)

To get details for recurring billing profiles, I'm making calls like this:

Paypal::Express::Request.new(@credentials).subscription(profile_id).recurring

And I'm getting warnings like this:

Ignored Parameter (Paypal::Express::Response): TRIALBILLINGPERIOD=Month
Ignored Parameter (Paypal::Express::Response): TRIALBILLINGFREQUENCY=1
Ignored Parameter (Paypal::Express::Response): TRIALTOTALBILLINGCYCLES=6
Ignored Parameter (Paypal::Express::Response): TRIALCURRENCYCODE=USD
Ignored Parameter (Paypal::Express::Response): TRIALAMT=7.00
Ignored Parameter (Paypal::Express::Response): TRIALSHIPPINGAMT=0.00
Ignored Parameter (Paypal::Express::Response): TRIALTAXAMT=0.00

I'm guessing the response from PayPal contain parameters that
we're not expecting.. perhaps unknown parameters should be
ignored more silently? :)

I'm happy to make the changes necessary and submit a pull request,
but I'm not sure where to start looking.

Cheers!
Paul

Digital Goods section

Hi all,
anybody can clarify what is the meaning of username, password, signature ??? in
request = Paypal::Express::Request.new(
:username => SET_YOUR_OWN ,
:password => SET_YOUR_OWN,
:signature => SET_YOUR_OWN
)
and if I can use a Client ID and Secret in authentication process.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.