diff --git a/CHANGELOG.md b/CHANGELOG.md index 7920974..647266f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ -## [Unreleased] +## [0.1.1] - 2023-06-19 -## [0.1.0] - 2023-06-15 +- Fix typo in a `README.md` file +- add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method +- Use named parameter of `destionation` for "MonopayRuby::Invoices::SimpleInvoice::create" method -- Initial release +## [0.1.0] - 2023-06-18 + +- Initial public release diff --git a/Gemfile.lock b/Gemfile.lock index e92dcb3..c95ea4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - monopay-ruby (0.1.0) + monopay-ruby (0.1.1) base64 (~> 0.1.1) json (~> 2.5) money (~> 6.13) diff --git a/lib/monopay-ruby/invoices/simple_invoice.rb b/lib/monopay-ruby/invoices/simple_invoice.rb index eef4157..c8fa0c6 100644 --- a/lib/monopay-ruby/invoices/simple_invoice.rb +++ b/lib/monopay-ruby/invoices/simple_invoice.rb @@ -4,11 +4,11 @@ module MonopayRuby module Invoices class SimpleInvoice < MonopayRuby::Base - attr_reader :invoice_id, :page_url, :error_messages, :amount, :destination, :redirect_url, :webhook_url + attr_reader :invoice_id, :page_url, :error_messages, :amount, :destination, :reference, :redirect_url, :webhook_url API_CREATE_INVOICE_URL = "#{API_URL}/merchant/invoice/create".freeze - CURRENCY = "UAH".freeze + DEFAULT_CURRENCY = "UAH".freeze PAGE_URL_KEY = "pageUrl".freeze INVOICE_ID_KEY = "invoiceId".freeze @@ -28,11 +28,13 @@ def initialize(redirect_url = nil, webhook_url = nil) # # @param [BigDecimal,Integer] amount in UAH (cents) to request payment # @param [String] destination - additional info about payment + # @param [String] reference - bill number or other reference # @return [Boolean] true if invoice was created successfully, false otherwise - def create(amount, destination = nil) + def create(amount, destination: nil, reference: nil) begin @amount = convert_to_cents(amount) @destination = destination + @reference = reference response = RestClient.post(API_CREATE_INVOICE_URL, request_body, headers) response_body = JSON.parse(response.body) @@ -64,6 +66,7 @@ def request_body redirectUrl: redirect_url, webHookUrl: webhook_url, merchantPaymInfo: { + reference: reference, destination: destination } }.to_json @@ -71,7 +74,7 @@ def request_body def convert_to_cents(amount) if amount.is_a?(BigDecimal) - Money.from_amount(amount, CURRENCY).cents + Money.from_amount(amount, DEFAULT_CURRENCY).cents else amount end diff --git a/lib/monopay-ruby/version.rb b/lib/monopay-ruby/version.rb index 5aee55f..c8194d3 100644 --- a/lib/monopay-ruby/version.rb +++ b/lib/monopay-ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module MonopayRuby - VERSION = "0.1.0" + VERSION = "0.1.1" end