Class: Paynl::Api::StartTransaction
- Defined in:
- lib/paynl/api/transaction/start_transaction.rb
Instance Method Summary collapse
- #addProduct(id, description, price, quantity, vatPercentage) ⇒ Object
- #doRequest ⇒ Object
- #getData ⇒ Object
-
#setAmount(amount) ⇒ Object
Set amount (in cents) of the transaction.
- #setCurrency(currency) ⇒ Object
- #setDescription(description) ⇒ Object
- #setDomainId(domainId) ⇒ Object
- #setEnduser(enduser) ⇒ Object
-
#setExchangeUrl(exchangeUrl) ⇒ Object
Set the communication url, the pay.nl server will call this url when the status of the transaction changes.
- #setExtra1(extra1) ⇒ Object
- #setExtra2(extra2) ⇒ Object
- #setExtra3(extra3) ⇒ Object
-
#setFinishUrl(finishUrl) ⇒ Object
Set the url where the user will be redirected to after payment.
- #setInfo(info) ⇒ Object
- #setIpAddress(ipAddress) ⇒ Object
- #setObject(object) ⇒ Object
- #setPaymentOptionId(paymentOptionId) ⇒ Object
- #setPaymentOptionSubId(paymentOptionSubId) ⇒ Object
- #setPromotorId(promotorId) ⇒ Object
- #setTestMode(testMode = false) ⇒ Object
- #setTool(tool) ⇒ Object
- #setTransferData(transferData) ⇒ Object
Methods inherited from Api
#isApiTokenRequired, #isServiceIdRequired, #processResult
Instance Method Details
#addProduct(id, description, price, quantity, vatPercentage) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 47 def addProduct(id, description, price, quantity, vatPercentage) unless price.is_a? Numeric raise('Price has to be numerical') end unless quantity.is_a? Numeric raise('Quantity has to be numerical') end if (@products.nil?) @products = Hash.new end # copying code from PHP version... this has no use. quantity = quantity * 1 # Description can only be 45 chars long description = description[0,45]; product = Hash.new product.store('productId', id) product.store('description', description) product.store('price', price) product.store('quantity', quantity) product.store('vatCode', vatPercentage) @products.store(@products.length + 1,product); end |
#doRequest ⇒ Object
239 240 241 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 239 def doRequest() return super('transaction/start', 5) end |
#getData ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 140 def getData() Paynl::Helper::requireServiceId @@data['serviceId'] = Paynl::Config::getServiceId Paynl::Helper::requireApiToken @@data['token'] = Paynl::Config::getApiToken if @testMode.equal? true @@data['testMode'] = 1 else @@data['testMode'] = 0 end if @amount.nil? raise('Amount has to be set and in cents') else @@data['amount'] = @amount.round(0); end unless @paymentOptionId.nil? @@data['paymentOptionId'] = @paymentOptionId end if @finishUrl.nil? raise('finishUrl is not set, which is required') else @@data['finishUrl'] = @finishUrl end # Crappy PHP associative array's are fcking my codestyle unless @@data['transaction'].is_a? Hash @@data['transaction'] = Hash.new end unless @@data['saleData'].is_a? Hash @@data['saleData'] = Hash.new end unless @@data['statsData'].is_a? Hash @@data['statsData'] = Hash.new end unless @exchangeUrl.nil? @@data['transaction'].store('orderExchangeUrl',@exchangeUrl) end unless @description.nil? @@data['transaction'].store('description', @description) end unless @currency.nil? @@data['transaction'].store('currency', @currency) end if @ipaddress.nil? #TODO: This is pure Ruby, no rails crap, so I can't abuse rails to get the IP raise("IP addresses are required for payments") else @@data['ipAddress'] = @ipaddress end unless @products.nil? @@data['saleData'].store('orderData',@products) end unless @enduser.nil? @@data['enduser'] = @enduser end unless @extra1.nil? @@data['statsData'].store('extra1',@extra1) end unless @extra2.nil? @@data['statsData'].store('extra2',@extra2) end unless @extra3.nil? @@data['statsData'].store('extra3',@extra3) end unless @promotorId.nil? @@data['statsData'].store('promotorId',@promotorId) end unless @info.nil? @@data['statsData'].store('info',@info) end unless @tool.nil? @@data['statsData'].store('tool',@tool) end unless @object.nil? @@data['statsData'].store('object',@object) end unless @domainId.nil? @@data['statsData'].store('domainId',@domainId) end unless @transferData.nil? @@data['statsData'].store('transferData',@transferData) end return super end |
#setAmount(amount) ⇒ Object
Set amount (in cents) of the transaction
84 85 86 87 88 89 90 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 84 def setAmount(amount) unless amount.is_a? Numeric raise('The amount has to be numeric (and in cents)') end @amount = amount end |
#setCurrency(currency) ⇒ Object
31 32 33 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 31 def setCurrency(currency) @currency = currency end |
#setDescription(description) ⇒ Object
136 137 138 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 136 def setDescription(description) @description = description end |
#setDomainId(domainId) ⇒ Object
132 133 134 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 132 def setDomainId(domainId) @domainId = domainId end |
#setEnduser(enduser) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 76 def setEnduser(enduser) unless enduser.is_a? Hash raise('Please supply Hash with correct data') end @enduser = enduser end |
#setExchangeUrl(exchangeUrl) ⇒ Object
Set the communication url, the pay.nl server will call this url when the status of the transaction changes
114 115 116 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 114 def setExchangeUrl(exchangeUrl) @exchangeUrl = exchangeUrl end |
#setExtra1(extra1) ⇒ Object
122 123 124 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 122 def setExtra1(extra1) @extra1 = extra1 end |
#setExtra2(extra2) ⇒ Object
125 126 127 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 125 def setExtra2(extra2) @extra2 = extra2 end |
#setExtra3(extra3) ⇒ Object
128 129 130 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 128 def setExtra3(extra3) @extra3 = extra3 end |
#setFinishUrl(finishUrl) ⇒ Object
Set the url where the user will be redirected to after payment.
109 110 111 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 109 def setFinishUrl(finishUrl) @finishUrl = finishUrl end |
#setInfo(info) ⇒ Object
34 35 36 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 34 def setInfo(info) @info = info end |
#setIpAddress(ipAddress) ⇒ Object
25 26 27 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 25 def setIpAddress(ipAddress) @ipaddress = ipAddress; end |
#setObject(object) ⇒ Object
40 41 42 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 40 def setObject(object) @object = object end |
#setPaymentOptionId(paymentOptionId) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 92 def setPaymentOptionId(paymentOptionId) unless paymentOptionId.is_a? Numeric raise('The paymentOptionId has to be numeric') end @paymentOptionId = paymentOptionId; end |
#setPaymentOptionSubId(paymentOptionSubId) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 100 def setPaymentOptionSubId(paymentOptionSubId) unless paymentOptionSubId.is_a? Numeric raise('The paymentOptionSubId has to be numberic') end @paymentOptionSubId = paymentOptionSubId end |
#setPromotorId(promotorId) ⇒ Object
28 29 30 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 28 def setPromotorId(promotorId) @promotorId = promotorId end |
#setTestMode(testMode = false) ⇒ Object
118 119 120 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 118 def setTestMode(testMode = false) @testMode = testMode end |
#setTool(tool) ⇒ Object
37 38 39 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 37 def setTool(tool) @tool = tool; end |
#setTransferData(transferData) ⇒ Object
43 44 45 |
# File 'lib/paynl/api/transaction/start_transaction.rb', line 43 def setTransferData(transferData) @transferData = transferData end |