lib/tikkie/api/requests/payment_requests.rb in tikkie-api-0.1.1 vs lib/tikkie/api/requests/payment_requests.rb in tikkie-api-0.2.0
- old
+ new
@@ -31,23 +31,24 @@
Tikkie::Api::Responses::PaymentRequest.new(response)
end
def create(platform_token, user_token, bank_account_token, options = {})
params = {
- amountInCents: to_cents(options.fetch(:amount)),
currency: options.fetch(:currency),
- description: options.fetch(:description),
- externalId: options[:external_id]
+ description: options.fetch(:description)
}
+ params[:amountInCents] = to_cents(options[:amount]) if options.key?(:amount)
+ params[:externalId] = options[:external_id] if options.key?(:external_id)
+
response = @request.post("/tikkie/platforms/#{platform_token}/users/#{user_token}/bankaccounts/#{bank_account_token}/paymentrequests", params)
Tikkie::Api::Responses::PaymentRequestCreated.new(response)
end
private
def to_cents(amount)
- decimal = BigDecimal.new(amount.to_s)
+ decimal = BigDecimal(amount.to_s)
decimal *= 100 # to cents
decimal.to_i
end
end
end