balanced / balanced-api

Balanced API specification.
221 stars 72 forks source link

API v1.1 Order debiting not failing when account uses the accounts that should fail #550

Closed bcatherall closed 10 years ago

bcatherall commented 10 years ago

It looks like something isn't working right with the v1.1 API when processing orders on the test site. I'm using the sample accounts that should go to a "failed" state for both the merchant and the customer, but when you credit or debit on an order it passes through as "successful".

This looks related to balanced/balanced-docs#283 and balanced/balanced-docs#275 and balanced/balanced-docs#405 but is when processing through an Order.

Here's a failing rspec test using the Balanced Rails gem:

    it "doesn't process the debit when the account is bad" do
      merchant = Balanced::Customer.new(
            name: 'Customer with Failing Account'
      ).save
      merchant_account = Balanced::BankAccount.new(
            name: "Failing Account",
            routing_number: '121000358',
            account_number: '9900000004',
            type: 'checking'
      ).save
      merchant_account.associate_to_customer(merchant)
      verification = merchant_account.verify
      verification.confirm(1, 1)

      customer = Balanced::Customer.new(
            name: 'Customer with Failing Account'
      ).save
      customer_account = Balanced::BankAccount.new(
            name: "Failing Account",
            routing_number: '121000358',
            account_number: '9900000005',
            type: 'checking'
      ).save
      customer_account.associate_to_customer(customer)
      verification = customer_account.verify
      verification.confirm(1, 1)

      order = BalancedOrder.new(merchant.href, 'Test Order for Failing Account')
      order.debit(customer_account.href, 10000)
      puts "ORDER: #{order.methods}"
      expect(order.amount_escrowed).to eq(0) 
    end
matthewfl commented 10 years ago

this should be fixed now