class Transbank::Onepay::TransactionCreateRequest

Create a payload to create [Transaction] on Transbank

Constants

SIGNATURE_PARAMS

Attributes

app_scheme[RW]
callback_url[RW]
channel[RW]
commerce_logo_url[RW]
external_unique_number[RW]
generate_ott_qr_code[R]
issued_at[RW]
items[RW]
items_quantity[RW]
signature[RW]
total[RW]
width_height[RW]

Public Class Methods

new(opts = {}) click to toggle source

@param opts [Hash] options hash with params needed to initialize this @param external_unique_number [String] Unique identifier (per Merchant) of the [Transaction] that @param total [Numeric] the total amount to pay for the items @param items_quantity [Numeric] the quantity of items on the shopping cart @param items [Array<Item] the items on the shopping cart @param issued_at [Numeric] timestamp at the moment the transaction is created @param callback_url [String] used when the channel is mobile, to be able to finish the [Transaction] @param channel [String] The channel the operation is made on. Valid values are on the [Channel] class @param app_scheme [String] identificator for the Merchant's app @param signature [String, nil] a hashstring created for verification purposes @param commerce_logo_url [String] The URL pointing to the Merchant's logo @param width_height [Numeric] qr width and height used by the frontend JS SDK.

# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 30
def initialize(opts = {})
  self.external_unique_number = opts.fetch(:external_unique_number)
  self.total = opts.fetch(:total)
  self.items_quantity = opts.fetch(:items_quantity)
  self.items = opts.fetch(:items)
  self.issued_at = opts.fetch(:issued_at)
  self.callback_url = opts.fetch(:callback_url)
  channel = opts.fetch(:channel, Channel::WEB)
  self.channel = channel
  self.app_scheme = opts.fetch(:app_scheme, '')
  self.signature = nil
  self.commerce_logo_url = opts.fetch(:commerce_logo_url)
  self.width_height = opts.fetch(:width_height)
  # This is never anything but true, but it is required by the server
  @generate_ott_qr_code = true
end

Public Instance Methods

callback_url=(callback_url) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 69
def callback_url=(callback_url)
  raise Errors::TransactionCreateError, 'Callback url cannot be null.' if callback_url.nil?
  @callback_url = callback_url
end
channel=(channel) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 74
def channel=(channel)
  raise Errors::TransactionCreateError, 'Channel cannot be null.' if channel.nil?
  @channel = channel
end
external_unique_number=(external_unique_number) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 47
def external_unique_number=(external_unique_number)
  raise Errors::TransactionCreateError, 'External Unique Number cannot be null.' if external_unique_number.nil?
  @external_unique_number = external_unique_number
end
items=(items) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 64
def items=(items)
  raise Errors::TransactionCreateError, 'Items must not be empty.' if items.empty?
  @items = items
end
items_quantity=(items_quantity) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 58
def items_quantity=(items_quantity)
  raise Errors::TransactionCreateError, 'Items quantity cannot be null.' if items_quantity.nil?
  raise Errors::TransactionCreateError, 'Items quantity cannot be less than zero.' if items_quantity < 0
  @items_quantity = items_quantity
end
sign(secret) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 79
def sign(secret)
  @signature = signature_for(to_data, secret)
  self
end
total=(total) click to toggle source
# File lib/transbank/sdk/onepay/requests/transaction_create_request.rb, line 52
def total=(total)
  raise Errors::TransactionCreateError, 'Total cannot be null.' if total.nil?
  raise Errors::TransactionCreateError, 'Total cannot be less than zero.' if total < 0
  @total = total
end