Sha256: ad4a4dfcfe906576fb4cd0fe7ad5400414e109b3c7b6aa25eb700ffdbc050652

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SolidusBolt::Transactions::CaptureService, :vcr, :bolt_configuration do
  subject(:api) do
    described_class.new(
      transaction_reference: reference, amount: amount, currency: currency, payment_method: payment_method
    )
  end

  let(:transaction) do
    SolidusBolt::Transactions::AuthorizeService.call(
      order: order, credit_card: credit_card_payload, create_bolt_account: false, payment_method: payment_method
    )
  end
  let(:credit_card_payload) do
    tokenize_credit_card(credit_card_number: '4111111111111004', cvv: '111').merge(
      expiration: (Time.current + 1.year).strftime('%Y-%m'),
      token_type: 'bolt'
    )
  end
  let(:order) { create(:order_with_line_items) }
  let(:reference) { transaction['transaction']['reference'] }
  let(:amount) { 10 }
  let(:currency) { 'USD' }
  let(:payment_method) { create(:bolt_payment_method) }

  describe '#call', vcr: true do
    it 'makes the API call' do
      response = api.call

      expect(response['reference']).to eq(reference)
      expect(response['capture']['status']).to eq 'succeeded'
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.7.1 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.7.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.6.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.5.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.4.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.3.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.2.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.1.0 spec/services/solidus_bolt/transactions/capture_service_spec.rb
solidus_bolt-0.0.1 spec/services/solidus_bolt/transactions/capture_service_spec.rb