-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc825c8
commit eb9db11
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require_relative 'helper' | ||
|
||
class PaymentTest < Test::Unit::TestCase | ||
include ApiClientHelper | ||
|
||
def 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 batch | ||
@_batch ||= @client.batch.create(sourceCurrency: 'USD', description: 'Integration Test Create') | ||
end | ||
def test_crud | ||
payment = @client.payment.create( | ||
batch.id, | ||
sourceAmount: '10.00', | ||
sourceCurrency: 'USD', | ||
recipient: { id: recipient.id } | ||
) | ||
|
||
assert_not_nil(payment) | ||
assert_not_nil(payment.id) | ||
assert_equal('10.00', payment.sourceAmount) | ||
assert_equal('USD', payment.sourceCurrency) | ||
|
||
payment = @client.payment.find(batch.id, payment.id) | ||
assert_not_nil(payment) | ||
|
||
update_response = @client.payment.update( | ||
batch.id, | ||
payment.id, | ||
sourceAmount: '20.00', | ||
sourceCurrency: 'USD' | ||
) | ||
|
||
assert_not_nil(update_response) | ||
|
||
response = @client.payment.delete(batch.id, payment.id) | ||
assert_true(response) | ||
end | ||
|
||
def test_search | ||
@client.payment.create( | ||
batch.id, | ||
sourceAmount: '10.00', | ||
sourceCurrency: 'USD', | ||
recipient: { id: recipient.id } | ||
) | ||
|
||
result =@client.payment.search(batch.id) | ||
assert_not_nil(result) | ||
assert_true(result.count > 0) | ||
end | ||
end |