Sha256: 5f42385f2aafba15efbacec7a223bde6890c26847135b48899ec63cbfd8f0f78

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Cardflex::ThreeStepGateway do
  it 'should fail step 1 in testing env (missing amount)' do
    res = Cardflex::Configuration.gateway.three_step.get_form_url({
      :sale => { :redirect_url => 'http://example.com' }
    })

    expect(res.success?).to eq false
  end

  it 'should pass step 1 in testing env' do
    res = Cardflex::Configuration.gateway.three_step.get_form_url({
      :sale => { :redirect_url => 'http://example.com', :amount => 1.5 }
    })

    expect(res.success?).to eq true
    expect(res.three_step.form_url).to match "secure.cardflexonline.com"
  end

  it 'should complete a transaction in testing env' do
    res = Cardflex::Configuration.gateway.three_step.get_form_url({
      :sale => { :redirect_url => 'http://example.com', :amount => 1.5 }
    })

    form_url = res.three_step.form_url
    token_id = SpecHelper.step_two(form_url)

    complete_result = Cardflex::Configuration.gateway.three_step.complete(token_id)

    expect(complete_result.success?).to be true
    expect(complete_result.transaction.transaction_id).to_not be nil
  end

  it 'should decline a transaction in testing env' do
    res = Cardflex::Configuration.gateway.three_step.get_form_url({
      :sale => { :redirect_url => 'http://example.com', :amount => 0.5 }
    })

    form_url = res.three_step.form_url
    token_id = SpecHelper.step_two(form_url)

    res = Cardflex::Configuration.gateway.three_step.complete(token_id)
    expect(res.success?).to be false
    expect(res.result_code.to_i).to eq 200
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cardflex-ruby-0.1.2 spec/integration/cardflex/three_step_gateway_spec.rb
cardflex-ruby-0.1.1 spec/integration/cardflex/three_step_gateway_spec.rb
cardflex-ruby-0.0.1 spec/integration/cardflex/three_step_gateway_spec.rb