class Docdata::Order::CreateRequest
Public Instance Methods
build_request(builder)
click to toggle source
# File lib/docdata/order/request.rb, line 113 def build_request(builder) # Unique merchant reference to this order. builder.merchantOrderReference(order_reference) # Preferences to use for this payment. builder.paymentPreferences do |preferences| # The profile that is used to select the payment methods that can be used to pay this order. preferences.profile(profile) preferences.numberOfDaysToPay(14) end # Information concerning the shopper who placed the order. builder.shopper(id: shopper_id) do |shopper| # Shopper's full name. shopper.name do |name| # The first given name. name.first(shopper_first_name) # Any subsequent given name or names. May also be used as middle initial. name.middle(shopper_infix) if shopper_infix # The family or inherited name(s). name.last(shopper_last_name) end # Shopper's e-mail address. shopper.email(shopper_email) # Shopper's preferred language. Language code according to ISO 639. shopper.language(code: shopper_language) # Shopper's gender. shopper.gender(shopper_gender) # Ip address of the shopper. Will be used in the future for riskchecks. Can be ipv4 or ipv6. shopper.ipAddress(shopper_ip_address) if shopper_ip_address end # Total order gross amount. The amount in the minor unit for the given currency. # (E.g. for EUR in cents) builder.totalGrossAmount(amount, currency: currency) # Name and address to use for billing. builder.billTo do |bill| bill.name do |name| # The first given name. name.first(shopper_first_name) # Any subsequent given name or names. May also be used as middle initial. name.middle(shopper_infix) if shopper_infix # The family or inherited name(s). name.last(shopper_last_name) end # Address of the destination. bill.address do |address| # Address lines must be filled as specific as possible using the house number # and optionally the house number addition field. address.street(address_street) # The house number. address.houseNumber(address_house_number) address.postalCode(address_postal_code) address.city(address_city) # Country code according to ISO 3166. address.country(code: address_country) end end # The description of the order. builder.description(description) # The description that is used by payment providers on shopper statements. builder.receiptText(receipt_text) # The merchant_reference is used for recurring payments. if initial builder.paymentRequest do |payment_request| payment_request.initialPaymentReference do |payment_reference| payment_reference.merchantReference(merchant_reference) end end end end
Private Instance Methods
address_city()
click to toggle source
# File lib/docdata/order/request.rb, line 248 def address_city options.fetch(:address).fetch(:city) end
address_country()
click to toggle source
# File lib/docdata/order/request.rb, line 252 def address_country options.fetch(:address).fetch(:country) end
address_house_number()
click to toggle source
# File lib/docdata/order/request.rb, line 240 def address_house_number options.fetch(:address).fetch(:house_number) end
address_postal_code()
click to toggle source
# File lib/docdata/order/request.rb, line 244 def address_postal_code options.fetch(:address).fetch(:postal_code) end
address_street()
click to toggle source
# File lib/docdata/order/request.rb, line 236 def address_street options.fetch(:address).fetch(:street) end
amount()
click to toggle source
# File lib/docdata/order/request.rb, line 192 def amount Amount.new(options.fetch(:amount)).to_cents end
currency()
click to toggle source
# File lib/docdata/order/request.rb, line 256 def currency options[:currency] || "EUR" end
description()
click to toggle source
# File lib/docdata/order/request.rb, line 260 def description options.fetch(:description) end
initial()
click to toggle source
# File lib/docdata/order/request.rb, line 268 def initial options[:initial] end
merchant_reference()
click to toggle source
# File lib/docdata/order/request.rb, line 272 def merchant_reference initial[:merchant_reference] end
order_reference()
click to toggle source
# File lib/docdata/order/request.rb, line 196 def order_reference options.fetch(:order_reference) end
profile()
click to toggle source
# File lib/docdata/order/request.rb, line 200 def profile options.fetch(:profile) end
receipt_text()
click to toggle source
# File lib/docdata/order/request.rb, line 264 def receipt_text options.fetch(:description)[0, 49] end
shopper_email()
click to toggle source
# File lib/docdata/order/request.rb, line 220 def shopper_email options.fetch(:shopper).fetch(:email) end
shopper_first_name()
click to toggle source
# File lib/docdata/order/request.rb, line 208 def shopper_first_name options.fetch(:shopper).fetch(:first_name) end
shopper_gender()
click to toggle source
# File lib/docdata/order/request.rb, line 228 def shopper_gender options.fetch(:shopper).fetch(:gender) end
shopper_id()
click to toggle source
# File lib/docdata/order/request.rb, line 204 def shopper_id options.fetch(:shopper)[:id] || SecureRandom.hex end
shopper_infix()
click to toggle source
# File lib/docdata/order/request.rb, line 212 def shopper_infix options.fetch(:shopper)[:infix] end
shopper_ip_address()
click to toggle source
# File lib/docdata/order/request.rb, line 232 def shopper_ip_address options.fetch(:shopper)[:ip_address] end
shopper_language()
click to toggle source
# File lib/docdata/order/request.rb, line 224 def shopper_language options.fetch(:shopper).fetch(:language) end
shopper_last_name()
click to toggle source
# File lib/docdata/order/request.rb, line 216 def shopper_last_name options.fetch(:shopper).fetch(:last_name) end