Sha256: 3ee3f1b46f6b01aba26d3aa9e2cdbc27778f69a2773eba612d350d267900b8cf

Contents?: true

Size: 1.94 KB

Versions: 18

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper.rb'

describe Paypal::Express::Response do
  before { fake_response 'SetExpressCheckout/success' }

  let(:return_url) { 'http://example.com/success' }
  let(:cancel_url) { 'http://example.com/cancel' }
  let :request do
    Paypal::Express::Request.new(
      :username => 'nov',
      :password => 'password',
      :signature => 'sig'
    )
  end
  let :payment_request do
    Paypal::Payment::Request.new( 
      :billing_type => :RecurringPayments,
      :billing_agreement_description => 'Recurring Payment Request'
    )
  end
  let(:response) { request.setup payment_request, return_url, cancel_url }

  describe '#redirect_uri' do
    subject { response.redirect_uri }
    it { should include 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' }
  end

  describe '#popup_uri' do
    subject { response.popup_uri }
    it { should include 'https://www.paypal.com/incontext?token=' }
  end

  context 'when pay_on_paypal option is given' do
    let(:response) { request.setup payment_request, return_url, cancel_url, :pay_on_paypal => true }

    subject { response }
    its(:pay_on_paypal) { should be_true }
    its(:query) { should include(:useraction => 'commit') }

    describe '#redirect_uri' do
      subject { response.redirect_uri }
      it { should include 'useraction=commit' }
    end

    describe '#popup_uri' do
      subject { response.popup_uri }
      it { should include 'useraction=commit' }
    end
  end

  context 'when sandbox mode' do
    before do
      Paypal.sandbox!
      fake_response 'SetExpressCheckout/success'
    end
    after { Paypal.sandbox = false }

    describe '#redirect_uri' do
      subject { response.redirect_uri }
      it { should include 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' }
    end

    describe '#popup_uri' do
      subject { response.popup_uri }
      it { should include 'https://www.sandbox.paypal.com/incontext?token=' }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
paypal-express-0.5.5 spec/paypal/express/response_spec.rb
paypal-express-0.5.4 spec/paypal/express/response_spec.rb
paypal-express-0.5.3 spec/paypal/express/response_spec.rb
paypal-express-0.5.2 spec/paypal/express/response_spec.rb
paypal-express-0.5.1 spec/paypal/express/response_spec.rb
paypal-express-0.5.0 spec/paypal/express/response_spec.rb
paypal-express-0.4.7 spec/paypal/express/response_spec.rb
paypal-express-0.5.0.alpha spec/paypal/express/response_spec.rb
paypal-express-0.4.6 spec/paypal/express/response_spec.rb
paypal-express-0.4.5 spec/paypal/express/response_spec.rb
paypal-express-0.4.4 spec/paypal/express/response_spec.rb
paypal-express-0.4.3 spec/paypal/express/response_spec.rb
paypal-express-0.4.2 spec/paypal/express/response_spec.rb
paypal-express-0.4.1 spec/paypal/express/response_spec.rb
paypal-express-0.4.0 spec/paypal/express/response_spec.rb
paypal-express-0.4.0.alpha spec/paypal/express/response_spec.rb
paypal-express-0.3.1 spec/paypal/express/response_spec.rb
paypal-express-0.3.0 spec/paypal/express/response_spec.rb