Sha256: 74602ceaccdb8f6953f95b9030680475bbfc2916c0abd95a12a87df42a804660

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SolidusBolt::Transactions::RefundService, :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) { transaction['transaction']['amount']['amount'] }
  let(:currency) { 'USD' }
  let(:payment_method) { create(:bolt_payment_method) }

  describe '#call', vcr: true do
    before do
      SolidusBolt::Transactions::CaptureService.call(
        transaction_reference: reference, amount: amount, currency: currency, payment_method: payment_method
      )
    end

    it 'makes the API call' do
      response = api.call

      expect(response['credit']['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/refund_service_spec.rb
solidus_bolt-0.7.1 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.7.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.6.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.5.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.4.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.3.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.2.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.1.0 spec/services/solidus_bolt/transactions/refund_service_spec.rb
solidus_bolt-0.0.1 spec/services/solidus_bolt/transactions/refund_service_spec.rb