Compare commits
2 Commits
master
...
bug-fix-bt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcfeb8edb5 | ||
|
|
e6bc86bd4b |
@ -1,3 +1,4 @@
|
||||
@invoices
|
||||
Feature: creating an invoice
|
||||
The user won't get any money
|
||||
If they can't
|
||||
@ -10,17 +11,18 @@ Feature: creating an invoice
|
||||
When the user creates an invoice for <price> <currency>
|
||||
Then they should recieve an invoice in response for <price> <currency>
|
||||
Examples:
|
||||
| price | currency |
|
||||
| "5.23" | "USD" |
|
||||
| price | currency |
|
||||
| "5.23" | "USD" |
|
||||
| "10.21" | "EUR" |
|
||||
| "0.225" | "BTC" |
|
||||
|
||||
Scenario Outline: The invoice contains illegal characters
|
||||
When the user creates an invoice for <price> <currency>
|
||||
Then they will receive a BitPay::ArgumentError matching <message>
|
||||
Examples:
|
||||
| price | currency | message |
|
||||
| "5,023" | "USD" | "Price must be formatted as a float" |
|
||||
| "3.21" | "EaUR" | "Currency is invalid." |
|
||||
| "5,023" | "USD" | "Price must be formatted as a float" |
|
||||
| "3.21" | "EaUR" | "Currency is invalid." |
|
||||
| "" | "USD" | "Price must be formatted as a float" |
|
||||
| "Ten" | "USD" | "Price must be formatted as a float" |
|
||||
| "10" | "" | "Currency is invalid." |
|
||||
| "10" | "" | "Currency is invalid." |
|
||||
|
||||
@ -61,7 +61,10 @@ module BitPay
|
||||
# Defaults to pos facade, also works with merchant facade
|
||||
#
|
||||
def create_invoice(price:, currency:, facade: 'pos', params:{})
|
||||
raise BitPay::ArgumentError, "Illegal Argument: Price must be formatted as a float" unless ( price.is_a?(Numeric) || /^[[:digit:]]+(\.[[:digit:]]{2})?$/.match(price) )
|
||||
raise BitPay::ArgumentError, "Illegal Argument: Price must be formatted as a float" unless
|
||||
price.is_a?(Numeric) ||
|
||||
/^[[:digit:]]+(\.[[:digit:]]{2})?$/.match(price) ||
|
||||
currency == 'BTC' && /^[[:digit:]]+(\.[[:digit:]]{1,6})?$/.match(price)
|
||||
raise BitPay::ArgumentError, "Illegal Argument: Currency is invalid." unless /^[[:upper:]]{3}$/.match(currency)
|
||||
params.merge!({price: price, currency: currency})
|
||||
response = send_request("POST", "invoices", facade: facade, params: params)
|
||||
|
||||
@ -3,5 +3,5 @@
|
||||
# or https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
|
||||
|
||||
module BitPay
|
||||
VERSION = '2.3.1'
|
||||
VERSION = '2.3.2'
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user