Skip to content

Commit

Permalink
cover offlinepayment
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-bites committed Jul 18, 2023
1 parent 6b1e42a commit dc825c8
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions spec/integration/OfflinePaymentTest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
require_relative 'helper'

class OfflinePaymentTest < Test::Unit::TestCase
include ApiClientHelper

def create_recipient
uuid = SecureRandom.uuid.to_s
recipient = @client.recipient.create(
type: 'individual',
firstName: 'Tom',
lastName: 'Jones',
email: "test.batch#{uuid}@example.com",
address: {
street1: '123 Wolfstrasse',
city: 'Berlin',
country: 'DE',
postalCode: '123123'
}
)
@client.recipient_account.create(recipient.id, type: 'bank-transfer', currency: 'EUR', country: 'DE', iban: 'DE89 3704 0044 0532 0130 00')
recipient
end

def test_create
recipient = create_recipient
offline_payment = @client.offline_payment.create(
recipient.id,
{
amount: '10.00',
currency: 'EUR'
}
)

assert_not_nil(offline_payment)
assert_not_nil(offline_payment.id)
assert_equal('10.00', offline_payment.amount)
assert_equal('EUR', offline_payment.currency)
end

def test_update
recipient = create_recipient
offline_payment = @client.offline_payment.create(
recipient.id,
{
amount: '10.00',
currency: 'EUR',
category: 'services'
}
)

assert_not_nil(offline_payment)

response = @client.offline_payment.update(
recipient.id,
offline_payment.id,
{
category: 'royalties'
}
)

assert_true(response)
end

def test_delete
recipient = create_recipient
offline_payment = @client.offline_payment.create(
recipient.id,
{
amount: '10.00',
currency: 'EUR',
category: 'services'
}
)

assert_not_nil(offline_payment)

response = @client.offline_payment.delete(recipient.id, offline_payment.id)

assert_true(response)
end

def test_search
recipient = create_recipient
offline_payment = @client.offline_payment.create(
recipient.id,
{
amount: '10.00',
currency: 'EUR',
category: 'services'
}
)

assert_not_nil(offline_payment)

offline_payments = @client.offline_payment.search(
recipient.id
)

assert_true(offline_payments.count > 0)
end
end

0 comments on commit dc825c8

Please sign in to comment.