Sha256: 9c7704ab99c94a341e3530cec4e0b7cb359af0d6fbf271400d1a00c3b6118922

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require_relative '../../spec_helper'

describe MangoPay::PayIn::Card::Web, type: :feature do
  include_context 'payins'

  def check_type_and_status(payin)
    expect(payin['Type']).to eq('PAYIN')
    expect(payin['Nature']).to eq('REGULAR')
    expect(payin['PaymentType']).to eq('CARD')
    expect(payin['ExecutionType']).to eq('WEB')

    # not SUCCEEDED yet: waiting for processing
    expect(payin['Status']).to eq('CREATED')
    expect(payin['ResultCode']).to be_nil
    expect(payin['ResultMessage']).to be_nil
    expect(payin['ExecutionDate']).to be_nil
  end
  
  describe 'CREATE' do
    it 'creates a card web payin' do
      created = new_payin_card_web
      expect(created['Id']).not_to be_nil
      check_type_and_status(created)
    end
  end

  describe 'FETCH' do
    it 'fetches a payin' do
      created = new_payin_card_web
      fetched = MangoPay::PayIn.fetch(created['Id'])
      expect(fetched['Id']).to eq(created['Id'])
      expect(fetched['CreationDate']).to eq(created['CreationDate'])
      expect(fetched['CreditedFunds']).to eq(created['CreditedFunds'])
      expect(fetched['CreditedWalletId']).to eq(created['CreditedWalletId'])
      check_type_and_status(created)
      check_type_and_status(fetched)
    end
  end

  describe 'REFUND' do
    it 'refunds a payin' do
      payin = new_payin_card_web
      expect {
        MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']})
      }.to raise_error { |err|
        err.should be_a MangoPay::ResponseError
        err.type.should eq 'other'
        err.message.should eq "Impossible to refund the transaction, can't have negative amount."
      }
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-3.0.4 spec/lib/mangopay/payin_card_web_spec.rb
mangopay-3.0.3 spec/lib/mangopay/payin_card_web_spec.rb
mangopay-3.0.2 spec/lib/mangopay/payin_card_web_spec.rb