klarna-xmlrpc 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +13 -0
  3. data/Gemfile +14 -0
  4. data/Guardfile +16 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.textile +139 -0
  7. data/Rakefile +22 -0
  8. data/TODO +30 -0
  9. data/examples/Gemfile +8 -0
  10. data/examples/config/initializer.rb +15 -0
  11. data/examples/console.rb +71 -0
  12. data/examples/public/images/klarna.png +0 -0
  13. data/examples/public/images/ruby.png +0 -0
  14. data/examples/views/_address.haml +22 -0
  15. data/examples/views/_articles.haml +21 -0
  16. data/examples/views/checkout_page_example.haml +2 -0
  17. data/examples/views/essential/add_transaction/_form.haml +32 -0
  18. data/examples/views/essential/add_transaction/result.haml +7 -0
  19. data/examples/views/essential/calculate_monthly_cost/_form.haml +16 -0
  20. data/examples/views/essential/calculate_monthly_cost/result.haml +7 -0
  21. data/examples/views/essential/get_addresses/_form.haml +9 -0
  22. data/examples/views/essential/get_addresses/result.haml +8 -0
  23. data/examples/views/index.haml +296 -0
  24. data/examples/views/layout.haml +48 -0
  25. data/examples/views/payment_terms_example.haml +102 -0
  26. data/examples/views/product_page_example.haml +2 -0
  27. data/examples/views/reservation/activate_reservation/_form.haml +54 -0
  28. data/examples/views/reservation/activate_reservation/result.haml +7 -0
  29. data/examples/views/reservation/cancel_reservation/_form.haml +8 -0
  30. data/examples/views/reservation/cancel_reservation/result.haml +7 -0
  31. data/examples/views/reservation/change_reservation/_form.haml +10 -0
  32. data/examples/views/reservation/change_reservation/result.haml +7 -0
  33. data/examples/views/reservation/reserve_amount/_form.haml +58 -0
  34. data/examples/views/reservation/reserve_amount/result.haml +7 -0
  35. data/examples/views/reservation/reserve_ocr_numbers/_form.haml +8 -0
  36. data/examples/views/reservation/reserve_ocr_numbers/result.haml +7 -0
  37. data/examples/views/reservation/split_reservation/_form.haml +14 -0
  38. data/examples/views/reservation/split_reservation/result.haml +7 -0
  39. data/examples/views/special/get_pclasses/_form.haml +8 -0
  40. data/examples/views/special/get_pclasses/result.haml +7 -0
  41. data/examples/views/special/invoice_address/_form.haml +8 -0
  42. data/examples/views/special/invoice_address/result.haml +7 -0
  43. data/examples/views/special/invoice_amount/_form.haml +8 -0
  44. data/examples/views/special/invoice_amount/result.haml +7 -0
  45. data/examples/views/special/is_invoice_paid/_form.haml +8 -0
  46. data/examples/views/special/is_invoice_paid/result.haml +7 -0
  47. data/examples/views/special/update_charge_amount/_form.haml +15 -0
  48. data/examples/views/special/update_charge_amount/result.haml +7 -0
  49. data/examples/views/special/update_goods_quantity/_form.haml +17 -0
  50. data/examples/views/special/update_goods_quantity/result.haml +7 -0
  51. data/examples/views/special/update_order_number/_form.haml +10 -0
  52. data/examples/views/special/update_order_number/result.haml +7 -0
  53. data/examples/views/useful/activate_invoice/_form.haml +9 -0
  54. data/examples/views/useful/activate_invoice/result.haml +7 -0
  55. data/examples/views/useful/credit_invoice/_form.haml +11 -0
  56. data/examples/views/useful/credit_invoice/result.haml +7 -0
  57. data/examples/views/useful/delete_invoice/_form.haml +9 -0
  58. data/examples/views/useful/delete_invoice/result.haml +7 -0
  59. data/examples/views/useful/email_invoice/_form.haml +9 -0
  60. data/examples/views/useful/email_invoice/result.haml +7 -0
  61. data/examples/views/useful/has_account/_form.haml +9 -0
  62. data/examples/views/useful/has_account/result.haml +7 -0
  63. data/examples/views/useful/return_amount/_form.haml +15 -0
  64. data/examples/views/useful/return_amount/result.haml +7 -0
  65. data/examples/views/useful/send_invoice/_form.haml +9 -0
  66. data/examples/views/useful/send_invoice/result.haml +7 -0
  67. data/examples/web.rb +349 -0
  68. data/klarna.gemspec +34 -0
  69. data/lib/klarna.rb +171 -0
  70. data/lib/klarna/api.rb +187 -0
  71. data/lib/klarna/api/client.rb +126 -0
  72. data/lib/klarna/api/constants.rb +647 -0
  73. data/lib/klarna/api/errors.rb +154 -0
  74. data/lib/klarna/api/methods.rb +16 -0
  75. data/lib/klarna/api/methods/cost_calculations.rb +134 -0
  76. data/lib/klarna/api/methods/invoicing.rb +304 -0
  77. data/lib/klarna/api/methods/reservation.rb +188 -0
  78. data/lib/klarna/api/methods/standard.rb +126 -0
  79. data/lib/klarna/version.rb +5 -0
  80. data/test/fixtures/api/companies.yml +97 -0
  81. data/test/fixtures/api/pclasses.yml +37 -0
  82. data/test/fixtures/api/persons.yml +144 -0
  83. data/test/fixtures/api/stores.yml +6 -0
  84. data/test/fixtures/klarna.yml +10 -0
  85. data/test/klarna/api/client_test.rb +288 -0
  86. data/test/klarna/api/errors_test.rb +34 -0
  87. data/test/klarna/api/methods/cost_calculations_test.rb +78 -0
  88. data/test/klarna/api/methods/invoicing_test.rb +409 -0
  89. data/test/klarna/api/methods/reservation_test.rb +66 -0
  90. data/test/klarna/api/methods/standard_test.rb +244 -0
  91. data/test/klarna/api_test.rb +184 -0
  92. data/test/klarna_test.rb +204 -0
  93. data/test/support/assertions_helper.rb +40 -0
  94. data/test/test_helper.rb +55 -0
  95. metadata +335 -0
@@ -0,0 +1,2 @@
1
+ %h1 Product Page (Example)
2
+ %p Example of a valid product page for a Klarna-connected store.
@@ -0,0 +1,54 @@
1
+ %h3 Activate Reservation
2
+ %p
3
+
4
+ %form{:action => '/reservation/activate_reservation', :name => 'active_reservation'}
5
+ %p
6
+ = field "Reservation ID:", :reservation_id, :text, :size => 10
7
+ %p
8
+ = field "SSN:", :pno, :text, :size => 10
9
+
10
+ = partial :articles
11
+
12
+ %p
13
+ = currency_selector "Currency:"
14
+ %p
15
+ = field "Reference", :reference, :text, :size => 10
16
+ %p
17
+ = field "Reference ID", :reference_id, :text, :size => 10
18
+ %p
19
+ = field "Order ID #1:", :order_id_1, :text, :size => 10
20
+ %p
21
+ = field "Order ID #2", :order_id_2, :text, :size => 10
22
+
23
+ %table
24
+ %tbody
25
+ %tr
26
+ %td
27
+ %h3 Delivery address:
28
+ = partial :address, :prefix => 'delivery_'
29
+
30
+ %td
31
+ %h3 Invoice address:
32
+ = partial :address, :prefix => 'invoice_'
33
+
34
+ %p
35
+ = field "E-mail:", :email, :text, :size => 20
36
+ *
37
+ %p
38
+ = field "Phone:", :phone, :text, :size => 10
39
+ *
40
+ %p
41
+ = field "Mobile:", :mobile, :text, :size => 10
42
+ *
43
+ %p
44
+ = shipment_type_selector "Shipment type:"
45
+ %p
46
+ = country_selector "Country:"
47
+ %p
48
+ = language_selector "Language:"
49
+ %p
50
+ = ssn_encoding_selector "SSN Encoding:"
51
+ %p
52
+ = field "Yearly salary:", :yearly_salary, :text, :size => 20, :value => 0
53
+ %p
54
+ = submit_button "Activate"
@@ -0,0 +1,7 @@
1
+ %h2 Activate Reservation
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Cancel Reservation
2
+ %p Enter reservation number of reservation to cancel.
3
+
4
+ %form{:action => '/reservation/cancel_reservation'}
5
+ %p
6
+ = field "Reservation ID:", :reservation_id, :text, :size => 6
7
+ %p
8
+ = submit_button "Cancel it"
@@ -0,0 +1,7 @@
1
+ %h2 Cancel Reservation
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,10 @@
1
+ %h3 Change Reservation
2
+ %p Enter reservation number and new amount.
3
+
4
+ %form{:action => '/reservation/change_reservation'}
5
+ %p
6
+ = field "Reservation ID:", :reservation_id, :text, :size => 6
7
+ %p
8
+ = field "New amount:", :new_amount, :text, :size => 6
9
+ %p
10
+ = submit_button "Update"
@@ -0,0 +1,7 @@
1
+ %h2 Change Reservation
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,58 @@
1
+ %h3 Reserve Amount (Create Reservation)
2
+ %p
3
+
4
+ %form{:action => '/reservation/reserve_amount', :name => 'reserve_amount'}
5
+ %p
6
+ = field "SSN:", :pno, :text, :size => 10
7
+ *
8
+ %p
9
+ = field "Amount:", :amount, :text, :size => 10
10
+ *
11
+
12
+ = partial :articles
13
+
14
+ %p
15
+ = currency_selector "Currency:"
16
+ %p
17
+ = field "Reference", :reference, :text, :size => 10
18
+ %p
19
+ = field "Reference ID", :reference_id, :text, :size => 10
20
+ %p
21
+ = field "Order ID #1:", :order_id_1, :text, :size => 10
22
+ %p
23
+ = field "Order ID #2", :order_id_2, :text, :size => 10
24
+
25
+ %table
26
+ %tbody
27
+ %tr
28
+ %td
29
+ %h3 Delivery address:
30
+ = partial :address, :prefix => 'delivery_'
31
+
32
+ %td
33
+ %h3 Invoice address:
34
+ = partial :address, :prefix => 'invoice_'
35
+
36
+ %p
37
+ = field "E-mail:", :email, :text, :size => 20
38
+ *
39
+ %p
40
+ = field "Phone:", :phone, :text, :size => 10
41
+ *
42
+ %p
43
+ = field "Mobile:", :mobile, :text, :size => 10
44
+ *
45
+ %p
46
+ = field "Annual salary:", :annual_salary, :text, :size => 20, :value => 0
47
+
48
+ %p
49
+ = shipment_type_selector "Shipment type:"
50
+ %p
51
+ = country_selector "Country:"
52
+ %p
53
+ = language_selector "Language:"
54
+ %p
55
+ = ssn_encoding_selector "SSN Encoding:"
56
+
57
+ %p
58
+ = submit_button "Reserve"
@@ -0,0 +1,7 @@
1
+ %h2 Reserve Amount
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Reserve OCR Numbers
2
+ %p Enter the number of ocrnumbers that you want to reserve. (Swedish only)
3
+
4
+ %form{:action => '/reservation/reserve_ocr_numbers'}
5
+ %p
6
+ = field "Number of OCRs:", :ocr_count, :text, :size => "2"
7
+ %p
8
+ = submit_button "Reserve"
@@ -0,0 +1,7 @@
1
+ %h2 Reserve OCR Numbers
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,14 @@
1
+ %h3 Split Reservation
2
+ %p Enter reservation number and new amount.
3
+
4
+ %form{:action => '/reservation/split_reservation'}
5
+ %p
6
+ = field "Reservation ID:", :reservation_id, :text, :size => 6
7
+ %p
8
+ = field "Split amount:", :split_amount, :text, :size => 6
9
+ %p
10
+ = field "Order ID #1:", :order_id_1, :text, :size => 6
11
+ %p
12
+ = field "Order ID #2:", :order_id_2, :text, :size => 6
13
+ %p
14
+ = submit_button "Split"
@@ -0,0 +1,7 @@
1
+ %h2 Split Reservation
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Get P-Classes
2
+ %p Chose the currency you want to retreive the pclasses for
3
+
4
+ %form{:action => '/special/get_pclasses'}
5
+ %p
6
+ = currency_selector("Currency:")
7
+ %p
8
+ = submit_button "Get"
@@ -0,0 +1,7 @@
1
+ %h2 Get P-Classes
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Invoice Address
2
+ %p Enter the invoice number of an invoice you would like see the address of.
3
+
4
+ %form{:action => '/special/invoice_addresses'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %p
8
+ = submit_button "Get"
@@ -0,0 +1,7 @@
1
+ %h2 Invoice Address
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Invoice Amount
2
+ %p Enter the invoice number of an invoice you would like see the amount of.
3
+
4
+ %form{:action => '/special/invoice_amount'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %p
8
+ = submit_button "Get"
@@ -0,0 +1,7 @@
1
+ %h2 Invoice Amount
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,8 @@
1
+ %h3 Is Invoice Paid?
2
+ %p Enter the invoice number that you want to check.
3
+
4
+ %form{:action => '/special/is_invoice_paid'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %p
8
+ = submit_button "Check"
@@ -0,0 +1,7 @@
1
+ %h2 Is Invoice Paid?
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,15 @@
1
+ %h3 Update Charge Amount
2
+ %p Enter invoice number of a passive invoice on which you would like to update the charge amount.
3
+
4
+ %form{:action => '/special/update_charge_amount'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %p
8
+ %input{:name => :charge_type, :type => :radio, :value => '0', :checked => true}
9
+ %label{:for => :charge_type}= "Shipment"
10
+ %input{:name => :charge_type, :type => :radio, :value => '1'}
11
+ %label{:for => :charge_type}= "Handling"
12
+ %p
13
+ = field "New amount:", :new_amount, :text, :size => 6
14
+ %p
15
+ = submit_button "Update"
@@ -0,0 +1,7 @@
1
+ %h2 Update Charge Amount
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,17 @@
1
+ %h3 Update Goods Quantity
2
+ %p Enter invoice number of a passive invoice on which you would like to update the quantity of a goods.
3
+
4
+ %form{:action => '/special/update_goods_quantity'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %table
8
+ %thead
9
+ %tr
10
+ %th Quantity
11
+ %th Art.no.
12
+ %tbody
13
+ %tr
14
+ %td= field "", :quantity, :text, :value => "3", :size => 2
15
+ %td= field "", :article_no, :text, :value => "ABC-123", :size => 10
16
+ %p
17
+ = submit_button "Update"
@@ -0,0 +1,7 @@
1
+ %h2 Update Goods Quantity
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,10 @@
1
+ %h3 Update Order Number
2
+ %p Enter invoice number of a passive invoice on which you would like to update the order number.
3
+
4
+ %form{:action => '/special/update_order_number'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ %p
8
+ = field "New order number:", :new_order_id, :text, :size => 10
9
+ %p
10
+ = submit_button "Update"
@@ -0,0 +1,7 @@
1
+ %h2 Update Order Number
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,9 @@
1
+ %h3 Activate Invoice
2
+ %p Enter invoice number of an passive invoice you would like to activate. Options: Fully, or partly.
3
+
4
+ %form{:action => '/invoicing/activate_invoice'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ *
8
+ %p
9
+ = submit_button "Activate"
@@ -0,0 +1,7 @@
1
+ %h2 Activate Invoice
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,11 @@
1
+ %h3 Credit Invoice
2
+ %p Enter invoice number of an active invoice you would like to return. Options: Fully, or partly.
3
+
4
+ %form{:action => '/invoicing/activate_invoice'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ *
8
+ %p
9
+ = field "Credit ID:", :credit_id, :text, :size => 10
10
+ %p
11
+ = submit_button "Credit"
@@ -0,0 +1,7 @@
1
+ %h2 Credit Invoice
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,9 @@
1
+ %h3 Delete Invoice
2
+ %p Enter invoice number of an passive invoice you would like to delete.
3
+
4
+ %form{:action => '/invoicing/delete_invoice'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ *
8
+ %p
9
+ = submit_button "Delete"
@@ -0,0 +1,7 @@
1
+ %h2 Delete Invoice
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root
@@ -0,0 +1,9 @@
1
+ %h3 E-mail Invoice
2
+ %p Enter invoice number of an active invoice you would like to email.
3
+
4
+ %form{:action => '/invoicing/email_invoice'}
5
+ %p
6
+ = field "Invoice ID:", :invoice_no, :text, :size => 10
7
+ *
8
+ %p
9
+ = submit_button "Send"
@@ -0,0 +1,7 @@
1
+ %h2 E-mail Invoice
2
+
3
+ %h3 Result:
4
+ %p
5
+ = @result.inspect
6
+
7
+ = link_to "Back", :root