Sha256: 6d889b56c35de9d4bdb5439337c754bcd7efb52d4cb28f54f010f4679e20265e

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require "test_helper"
require "uri"

class Pay::Lago::PaymentMethodTest < ActiveSupport::TestCase
  setup do
    @pay_customer = pay_customers(:lago)
  end

  test "Lago sync returns Pay::PaymentMethod" do
    lago_customer = OpenStruct.new(
      external_id: @pay_customer.processor_id,
      billing_configuration: OpenStruct.new(
        payment_provider: "stripe",
        provider_customer_id: "x"
      )
    )
    pay_payment_method = Pay::Lago::PaymentMethod.sync(lago_customer)
    assert pay_payment_method.is_a?(Pay::PaymentMethod)
    assert pay_payment_method.processor_id == "x"
    assert @pay_customer.default_payment_method == pay_payment_method
  end

  test "PaymentMethod does not push or pull if not default" do
    pay_payment_method = @pay_customer.add_payment_method(:stripe, "test_1234", default: false, sync: false).payment_processor
    assert pay_payment_method.push! == false
    assert pay_payment_method.pull! == false
  end

  test "PaymentMethod can be made default, updating Lago" do
    pay_payment_method = @pay_customer.add_payment_method(:stripe, "test_1234_a", sync: true)
    lago_customer = Pay::Lago.client.customers.get(@pay_customer.pay_external_id)
    assert lago_customer.billing_configuration.provider_customer_id == pay_payment_method.processor_id
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pay-lago-0.1.1 test/pay/lago/payment_method_test.rb