-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from activemerchant/bitpay/allow-for-api-v2-t…
…okens Bitpay/allow for api v2 tokens
- Loading branch information
Showing
9 changed files
with
128 additions
and
19 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
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
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
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
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 |
---|---|---|
|
@@ -4,7 +4,10 @@ class BitPayHelperTest < Test::Unit::TestCase | |
include OffsitePayments::Integrations | ||
|
||
def setup | ||
@helper = BitPay::Helper.new(1234, '[email protected]', :amount => 500, :currency => 'USD') | ||
@token_v1 = 'g82hEYhfRkhIlX5HJEqO8w5giRVeyGwsJ1wDPRvx8' | ||
@token_v2 = '5v2K2rwuWQbnKexiQF9Eu6xdCVg7HFtkFNXarGEq9vLR' | ||
@invoice_id = '98kui1gJ7FocK41gUaBZxG' | ||
@helper = BitPay::Helper.new(1234, @token_v1, :amount => 500, :currency => 'USD') | ||
end | ||
|
||
def test_basic_helper_fields | ||
|
@@ -45,9 +48,41 @@ def test_setting_invalid_address_field | |
assert_equal fields, @helper.fields | ||
end | ||
|
||
def test_form_fields_uses_invoice_id | ||
Net::HTTP.any_instance.expects(:request).returns(stub(:body => '{"id": "98kui1gJ7FocK41gUaBZxG"}')) | ||
def test_calls_the_v1_api_url_when_the_token_is_v1 | ||
stub_request(:post, BitPay::API_V1_URL).with( | ||
body: { | ||
orderID: '1234', | ||
price: '500', | ||
currency: 'USD', | ||
posData: { orderId: 1234 }.to_json, | ||
fullNotifications: "true", | ||
transactionSpeed: 'high', | ||
}.to_json | ||
).to_return( | ||
status: 200, | ||
body: { id: @invoice_id }.to_json | ||
) | ||
|
||
assert_equal '98kui1gJ7FocK41gUaBZxG', @helper.form_fields['id'] | ||
assert_equal @invoice_id, @helper.form_fields['id'] | ||
end | ||
|
||
def test_calls_the_v2_api_url_when_the_token_is_v2 | ||
stub_request(:post, BitPay::API_V2_URL).with( | ||
body: { | ||
orderID: '1234', | ||
price: '500', | ||
currency: 'USD', | ||
posData: { orderId: 1234 }.to_json, | ||
fullNotifications: "true", | ||
transactionSpeed: 'high', | ||
}.to_json | ||
).to_return( | ||
status: 200, | ||
body: { id: @invoice_id }.to_json | ||
) | ||
|
||
helper = BitPay::Helper.new(1234, @token_v2, :amount => 500, :currency => 'USD') | ||
|
||
assert_equal @invoice_id, helper.form_fields['id'] | ||
end | ||
end |
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
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
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
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