mangopay-v4 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +29 -29
  3. data/.rspec +3 -3
  4. data/.rubocop.yml +1 -1
  5. data/.travis.yml +21 -13
  6. data/Gemfile +2 -2
  7. data/LICENSE +20 -20
  8. data/README.md +379 -379
  9. data/bin/mangopay +9 -9
  10. data/lib/mangopay.rb +132 -132
  11. data/lib/mangopay/api/api.rb +8 -8
  12. data/lib/mangopay/api/api_methods.rb +160 -136
  13. data/lib/mangopay/api/auth_token_manager.rb +173 -173
  14. data/lib/mangopay/api/http_client.rb +324 -324
  15. data/lib/mangopay/api/service/bank_accounts.rb +145 -145
  16. data/lib/mangopay/api/service/banking_aliases.rb +83 -0
  17. data/lib/mangopay/api/service/cards.rb +151 -151
  18. data/lib/mangopay/api/service/client_wallets.rb +88 -88
  19. data/lib/mangopay/api/service/clients.rb +67 -67
  20. data/lib/mangopay/api/service/dispute_documents.rb +157 -157
  21. data/lib/mangopay/api/service/disputes.rb +186 -186
  22. data/lib/mangopay/api/service/e_money.rb +63 -41
  23. data/lib/mangopay/api/service/events.rb +46 -46
  24. data/lib/mangopay/api/service/hooks.rb +92 -92
  25. data/lib/mangopay/api/service/kyc_documents.rb +152 -152
  26. data/lib/mangopay/api/service/mandates.rb +141 -141
  27. data/lib/mangopay/api/service/oauth_tokens.rb +24 -24
  28. data/lib/mangopay/api/service/pay_ins.rb +369 -259
  29. data/lib/mangopay/api/service/pay_outs.rb +53 -53
  30. data/lib/mangopay/api/service/pre_authorizations.rb +126 -68
  31. data/lib/mangopay/api/service/refunds.rb +159 -61
  32. data/lib/mangopay/api/service/reports.rb +150 -150
  33. data/lib/mangopay/api/service/repudiations.rb +31 -31
  34. data/lib/mangopay/api/service/responses.rb +101 -101
  35. data/lib/mangopay/api/service/settlement_transfers.rb +54 -54
  36. data/lib/mangopay/api/service/transactions.rb +246 -182
  37. data/lib/mangopay/api/service/transfers.rb +53 -53
  38. data/lib/mangopay/api/service/ubo_declarations.rb +94 -69
  39. data/lib/mangopay/api/service/users.rb +162 -162
  40. data/lib/mangopay/api/service/wallets.rb +98 -98
  41. data/lib/mangopay/api/uri_provider.rb +32 -34
  42. data/lib/mangopay/common/json_tag_converter.rb +70 -67
  43. data/lib/mangopay/common/jsonifier.rb +266 -248
  44. data/lib/mangopay/common/log_provider.rb +33 -33
  45. data/lib/mangopay/common/rate_limit_interval.rb +16 -16
  46. data/lib/mangopay/common/read_only_fields.rb +26 -26
  47. data/lib/mangopay/common/response_error.rb +61 -61
  48. data/lib/mangopay/common/sort_direction.rb +14 -14
  49. data/lib/mangopay/common/sort_field.rb +12 -12
  50. data/lib/mangopay/common/template_url_options.rb +8 -8
  51. data/lib/mangopay/configuration.rb +38 -38
  52. data/lib/mangopay/environment.rb +65 -65
  53. data/lib/mangopay/model/address.rb +26 -26
  54. data/lib/mangopay/model/billing.rb +13 -0
  55. data/lib/mangopay/model/birthplace.rb +15 -0
  56. data/lib/mangopay/model/declared_ubo.rb +20 -20
  57. data/lib/mangopay/model/dispute_reason.rb +14 -14
  58. data/lib/mangopay/model/document_page_consult.rb +14 -14
  59. data/lib/mangopay/model/e_money.rb +17 -17
  60. data/lib/mangopay/model/entity/account/bank_account.rb +25 -25
  61. data/lib/mangopay/model/entity/account/ca_bank_account.rb +26 -26
  62. data/lib/mangopay/model/entity/account/debited_bank_account.rb +31 -0
  63. data/lib/mangopay/model/entity/account/gb_bank_account.rb +20 -20
  64. data/lib/mangopay/model/entity/account/iban_bank_account.rb +20 -20
  65. data/lib/mangopay/model/entity/account/other_bank_account.rb +23 -23
  66. data/lib/mangopay/model/entity/account/us_bank_account.rb +23 -23
  67. data/lib/mangopay/model/entity/banking_alias.rb +27 -0
  68. data/lib/mangopay/model/entity/card.rb +44 -44
  69. data/lib/mangopay/model/entity/card_registration.rb +42 -42
  70. data/lib/mangopay/model/entity/client.rb +65 -62
  71. data/lib/mangopay/model/entity/client_wallet.rb +22 -22
  72. data/lib/mangopay/model/entity/dispute.rb +49 -49
  73. data/lib/mangopay/model/entity/dispute_document.rb +28 -28
  74. data/lib/mangopay/model/entity/entity_base.rb +17 -17
  75. data/lib/mangopay/model/entity/hook.rb +25 -25
  76. data/lib/mangopay/model/entity/kyc_document.rb +27 -27
  77. data/lib/mangopay/model/entity/mandate.rb +50 -50
  78. data/lib/mangopay/model/entity/pay_in/apple_pay_direct_pay_in.rb +26 -0
  79. data/lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in.rb +24 -21
  80. data/lib/mangopay/model/entity/pay_in/bank_wire_external_instruction_pay_in.rb +19 -0
  81. data/lib/mangopay/model/entity/pay_in/card_direct_pay_in.rb +41 -32
  82. data/lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in.rb +15 -12
  83. data/lib/mangopay/model/entity/pay_in/card_web_pay_in.rb +36 -39
  84. data/lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in.rb +25 -22
  85. data/lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in.rb +37 -37
  86. data/lib/mangopay/model/entity/pay_in/google_pay_direct_pay_in.rb +28 -0
  87. data/lib/mangopay/model/entity/pay_in/pay_in.rb +18 -15
  88. data/lib/mangopay/model/entity/pay_in/paypal_web_pay_in.rb +15 -0
  89. data/lib/mangopay/model/entity/pay_out.rb +21 -21
  90. data/lib/mangopay/model/entity/pre_authorization.rb +74 -67
  91. data/lib/mangopay/model/entity/refund.rb +17 -17
  92. data/lib/mangopay/model/entity/report.rb +50 -50
  93. data/lib/mangopay/model/entity/repudiation.rb +17 -17
  94. data/lib/mangopay/model/entity/settlement_transfer.rb +16 -16
  95. data/lib/mangopay/model/entity/transaction.rb +51 -51
  96. data/lib/mangopay/model/entity/transfer.rb +12 -12
  97. data/lib/mangopay/model/entity/ubo.rb +30 -0
  98. data/lib/mangopay/model/entity/ubo_declaration.rb +29 -31
  99. data/lib/mangopay/model/entity/user/legal_user.rb +55 -52
  100. data/lib/mangopay/model/entity/user/natural_user.rb +49 -49
  101. data/lib/mangopay/model/entity/user/user.rb +17 -17
  102. data/lib/mangopay/model/entity/wallet.rb +27 -27
  103. data/lib/mangopay/model/enum/account_type.rb +23 -23
  104. data/lib/mangopay/model/enum/avs_result.rb +19 -0
  105. data/lib/mangopay/model/enum/banking_alias_type.rb +12 -0
  106. data/lib/mangopay/model/enum/business_type.rb +17 -0
  107. data/lib/mangopay/model/enum/card_status.rb +14 -14
  108. data/lib/mangopay/model/enum/card_type.rb +32 -32
  109. data/lib/mangopay/model/enum/card_validity.rb +18 -18
  110. data/lib/mangopay/model/enum/country_iso.rb +758 -758
  111. data/lib/mangopay/model/enum/culture_code.rb +43 -43
  112. data/lib/mangopay/model/enum/currency_iso.rb +551 -551
  113. data/lib/mangopay/model/enum/declared_ubo_refused_reason_type.rb +15 -15
  114. data/lib/mangopay/model/enum/declared_ubo_status.rb +17 -17
  115. data/lib/mangopay/model/enum/deposit_type.rb +14 -14
  116. data/lib/mangopay/model/enum/direct_debit_type.rb +12 -12
  117. data/lib/mangopay/model/enum/dispute_doc_refused_reason_type.rb +24 -24
  118. data/lib/mangopay/model/enum/dispute_document_type.rb +22 -22
  119. data/lib/mangopay/model/enum/dispute_reason_type.rb +32 -32
  120. data/lib/mangopay/model/enum/dispute_status.rb +20 -20
  121. data/lib/mangopay/model/enum/dispute_type.rb +14 -14
  122. data/lib/mangopay/model/enum/document_status.rb +20 -20
  123. data/lib/mangopay/model/enum/download_format.rb +10 -10
  124. data/lib/mangopay/model/enum/event_type.rb +76 -73
  125. data/lib/mangopay/model/enum/funds_type.rb +14 -14
  126. data/lib/mangopay/model/enum/hook_status.rb +12 -12
  127. data/lib/mangopay/model/enum/hook_validity.rb +14 -14
  128. data/lib/mangopay/model/enum/income_range.rb +20 -20
  129. data/lib/mangopay/model/enum/kyc_doc_refused_reason_type.rb +36 -36
  130. data/lib/mangopay/model/enum/kyc_document_type.rb +18 -18
  131. data/lib/mangopay/model/enum/kyc_level.rb +12 -12
  132. data/lib/mangopay/model/enum/legal_person_type.rb +14 -14
  133. data/lib/mangopay/model/enum/mandate_culture_code.rb +22 -22
  134. data/lib/mangopay/model/enum/mandate_execution_type.rb +10 -10
  135. data/lib/mangopay/model/enum/mandate_scheme.rb +12 -12
  136. data/lib/mangopay/model/enum/mandate_status.rb +23 -23
  137. data/lib/mangopay/model/enum/mandate_type.rb +10 -10
  138. data/lib/mangopay/model/enum/natural_user_capacity.rb +14 -14
  139. data/lib/mangopay/model/enum/pay_in_execution_type.rb +17 -17
  140. data/lib/mangopay/model/enum/pay_in_payment_type.rb +29 -20
  141. data/lib/mangopay/model/enum/pay_out_payment_type.rb +10 -10
  142. data/lib/mangopay/model/enum/payment_status.rb +20 -20
  143. data/lib/mangopay/model/enum/person_type.rb +14 -14
  144. data/lib/mangopay/model/enum/platform_type.rb +22 -22
  145. data/lib/mangopay/model/enum/pre_authorization_execution_type.rb +10 -10
  146. data/lib/mangopay/model/enum/pre_authorization_status.rb +17 -17
  147. data/lib/mangopay/model/enum/refund_reason_type.rb +20 -20
  148. data/lib/mangopay/model/enum/report_status.rb +16 -16
  149. data/lib/mangopay/model/enum/report_type.rb +12 -12
  150. data/lib/mangopay/model/enum/sector.rb +29 -0
  151. data/lib/mangopay/model/enum/secure_mode.rb +15 -15
  152. data/lib/mangopay/model/enum/transaction_nature.rb +16 -16
  153. data/lib/mangopay/model/enum/transaction_status.rb +14 -14
  154. data/lib/mangopay/model/enum/transaction_type.rb +14 -14
  155. data/lib/mangopay/model/enum/ubo_declaration_refused_reason_type.rb +18 -18
  156. data/lib/mangopay/model/enum/ubo_declaration_status.rb +20 -20
  157. data/lib/mangopay/model/event.rb +17 -17
  158. data/lib/mangopay/model/model.rb +214 -193
  159. data/lib/mangopay/model/money.rb +16 -16
  160. data/lib/mangopay/model/pay_in_web_extended_view.rb +30 -30
  161. data/lib/mangopay/model/platform_categorization.rb +15 -0
  162. data/lib/mangopay/model/refund_reason.rb +14 -14
  163. data/lib/mangopay/model/report_filter.rb +82 -82
  164. data/lib/mangopay/model/request/cancel_request.rb +15 -15
  165. data/lib/mangopay/model/request/complete_registration_request.rb +12 -12
  166. data/lib/mangopay/model/request/currency_request.rb +12 -12
  167. data/lib/mangopay/model/request/deactivation_request.rb +9 -9
  168. data/lib/mangopay/model/request/filter_request.rb +37 -37
  169. data/lib/mangopay/model/request/submit_document_request.rb +13 -13
  170. data/lib/mangopay/model/request/submit_ubo_declaration_request.rb +16 -13
  171. data/lib/mangopay/model/request/upload_file_request.rb +8 -8
  172. data/lib/mangopay/model/response_replica.rb +26 -26
  173. data/lib/mangopay/model/security_info.rb +13 -0
  174. data/lib/mangopay/util/custom_formatter.rb +11 -11
  175. data/lib/mangopay/util/custom_logger.rb +33 -33
  176. data/lib/mangopay/util/enum.rb +51 -51
  177. data/lib/mangopay/util/file_encoder.rb +15 -15
  178. data/lib/mangopay/util/non_instantiable.rb +5 -5
  179. data/lib/mangopay/util/storage_strategy.rb +9 -9
  180. data/lib/mangopay/util/void_logger.rb +5 -5
  181. data/mangopay-v4.gemspec +32 -0
  182. data/mangopay.gemspec +32 -32
  183. data/spec/context/address_context.rb +24 -24
  184. data/spec/context/bank_account_context.rb +137 -137
  185. data/spec/context/banking_alias_context.rb +17 -0
  186. data/spec/context/birthplace_context.rb +17 -0
  187. data/spec/context/card_context.rb +45 -45
  188. data/spec/context/client_context.rb +43 -44
  189. data/spec/context/dispute_context.rb +36 -36
  190. data/spec/context/dispute_document_context.rb +19 -19
  191. data/spec/context/hook_context.rb +15 -15
  192. data/spec/context/kyc_document_context.rb +22 -22
  193. data/spec/context/mandate_context.rb +26 -26
  194. data/spec/context/pay_in_context.rb +319 -224
  195. data/spec/context/pay_out_context.rb +39 -38
  196. data/spec/context/pre_authorization_context.rb +44 -40
  197. data/spec/context/refund_context.rb +32 -32
  198. data/spec/context/report_context.rb +21 -21
  199. data/spec/context/repudiation_context.rb +18 -18
  200. data/spec/context/settlement_transfer_context.rb +27 -27
  201. data/spec/context/transfer_context.rb +50 -50
  202. data/spec/context/ubo_declaration_context.rb +29 -24
  203. data/spec/context/user_context.rb +83 -82
  204. data/spec/context/wallet_context.rb +52 -52
  205. data/spec/mangopay/bank_accounts_spec.rb +228 -228
  206. data/spec/mangopay/banking_alias_spec.rb +85 -0
  207. data/spec/mangopay/cards_spec.rb +133 -134
  208. data/spec/mangopay/client_wallets_spec.rb +147 -147
  209. data/spec/mangopay/clients_spec.rb +56 -54
  210. data/spec/mangopay/configuration_spec.rb +125 -125
  211. data/spec/mangopay/dispute_documents_spec.rb +173 -173
  212. data/spec/mangopay/disputes_spec.rb +264 -264
  213. data/spec/mangopay/e_money_spec.rb +57 -37
  214. data/spec/mangopay/events_spec.rb +49 -49
  215. data/spec/mangopay/hooks_spec.rb +70 -70
  216. data/spec/mangopay/kyc_documents_spec.rb +179 -179
  217. data/spec/mangopay/mandates_spec.rb +218 -218
  218. data/spec/mangopay/oauth_tokens_spec.rb +40 -40
  219. data/spec/mangopay/pay_ins_spec.rb +279 -180
  220. data/spec/mangopay/pay_outs_spec.rb +38 -38
  221. data/spec/mangopay/pre_authorizations_spec.rb +134 -57
  222. data/spec/mangopay/refunds_spec.rb +187 -39
  223. data/spec/mangopay/reports_spec.rb +118 -120
  224. data/spec/mangopay/responses_spec.rb +324 -294
  225. data/spec/mangopay/settlement_transfers_spec.rb +36 -36
  226. data/spec/mangopay/transactions_spec.rb +347 -232
  227. data/spec/mangopay/transfers_spec.rb +37 -37
  228. data/spec/mangopay/ubo_declarations_spec.rb +127 -64
  229. data/spec/mangopay/users_spec.rb +145 -145
  230. data/spec/mangopay/wallets_spec.rb +103 -103
  231. data/spec/spec_helper.rb +72 -72
  232. data/spec/tmp/MangoPay.AuthorizationToken.FileStore.tmp +6 -0
  233. data/spec/tmp/mangopay.log.tmp +1201 -0
  234. metadata +31 -5
@@ -1,45 +1,44 @@
1
- require_relative 'address_context'
2
- require_relative '../../lib/mangopay/model/entity/client'
3
-
4
- shared_context 'client_context' do
5
-
6
- CLIENT_DATA ||= build_client_data
7
- end
8
-
9
- def build_client_data
10
- client = MangoModel::Client.new
11
- client.primary_theme_colour = '#508c4a'
12
- client.primary_button_colour = '#d0ae5f'
13
- client.tech_emails = ['tech@mangopay.com']
14
- client.admin_emails = ['admin@mangopay.com']
15
- client.fraud_emails = ['fraud@mangopay.com']
16
- client.billing_emails = ['billing@mangopay.com']
17
- client.platform_description = "Test description (time = #{Time.now})"
18
- client.platform_type = MangoModel::PlatformType::MARKETPLACE
19
- client.platform_url = 'https://www.mangopay.com'
20
- client.headquarters_address = build_address
21
- client.tax_number = 'FR52BSSS'
22
- client
23
- end
24
-
25
- def its_the_same_client(client1, client2)
26
- client1.primary_theme_colour == client2.primary_theme_colour\
27
- && client1.primary_button_colour == client2.primary_button_colour\
28
- && same_values(client1.tech_emails, client2.tech_emails)\
29
- && same_values(client1.admin_emails, client2.admin_emails)\
30
- && same_values(client1.fraud_emails, client2.fraud_emails)\
31
- && same_values(client1.billing_emails, client2.billing_emails)\
32
- && client1.platform_description == client2.platform_description\
33
- && client1.platform_type.eql?(client2.platform_type)\
34
- && client1.platform_url == client2.platform_url\
35
- && its_the_same_address(client1.headquarters_address, client2.headquarters_address)\
36
- && client1.tax_number == client2.tax_number
37
- end
38
-
39
- def same_values(array1, array2)
40
- return false unless array1.length == array2.length
41
- array1.each do |value|
42
- return false unless array2.include? value
43
- end
44
- true
1
+ require_relative 'address_context'
2
+ require_relative '../../lib/mangopay/model/entity/client'
3
+
4
+ shared_context 'client_context' do
5
+
6
+ CLIENT_DATA ||= build_client_data
7
+ end
8
+
9
+ def build_client_data
10
+ client = MangoModel::Client.new
11
+ client.primary_theme_colour = '#508c4a'
12
+ client.primary_button_colour = '#d0ae5f'
13
+ client.tech_emails = ['tech@mangopay.com']
14
+ client.admin_emails = ['admin@mangopay.com']
15
+ client.fraud_emails = ['fraud@mangopay.com']
16
+ client.billing_emails = ['billing@mangopay.com']
17
+ client.platform_description = "Test description (time = #{Time.now})"
18
+ client.platform_url = 'https://www.mangopay.com'
19
+ client.headquarters_address = build_address
20
+ client.tax_number = 'FR52BSSS'
21
+ client.headquarters_phone_number = rand(999999999).to_s
22
+ client
23
+ end
24
+
25
+ def its_the_same_client(client1, client2)
26
+ client1.primary_theme_colour == client2.primary_theme_colour\
27
+ && client1.primary_button_colour == client2.primary_button_colour\
28
+ && same_values(client1.tech_emails, client2.tech_emails)\
29
+ && same_values(client1.admin_emails, client2.admin_emails)\
30
+ && same_values(client1.fraud_emails, client2.fraud_emails)\
31
+ && same_values(client1.billing_emails, client2.billing_emails)\
32
+ && client1.platform_description == client2.platform_description\
33
+ && client1.platform_url == client2.platform_url\
34
+ && its_the_same_address(client1.headquarters_address, client2.headquarters_address)\
35
+ && client1.tax_number == client2.tax_number
36
+ end
37
+
38
+ def same_values(array1, array2)
39
+ return false unless array1.length == array2.length
40
+ array1.each do |value|
41
+ return false unless array2.include? value
42
+ end
43
+ true
45
44
  end
@@ -1,37 +1,37 @@
1
- require_relative 'wallet_context'
2
- require_relative '../../lib/mangopay/api/service/disputes'
3
-
4
- shared_context 'dispute_context' do
5
- include_context 'wallet_context'
6
-
7
- DISPUTE_PERSISTED ||= first_dispute
8
- end
9
-
10
- def first_dispute
11
- MangoApi::Disputes.all[0]
12
- end
13
-
14
- def its_the_same_dispute(dispute1, dispute2)
15
- dispute1.contest_deadline_date == dispute2.contest_deadline_date\
16
- && its_the_same_money(dispute1.contested_funds, dispute2.contested_funds)\
17
- && its_the_same_money(dispute1.disputed_funds, dispute2.disputed_funds)\
18
- && its_the_same_reason(dispute1.dispute_reason, dispute2.dispute_reason)\
19
- && dispute1.dispute_type.eql?(dispute2.dispute_type)\
20
- && dispute1.initial_transaction_id == dispute2.initial_transaction_id\
21
- && dispute1.initial_transaction_type.eql?(dispute2.initial_transaction_type)\
22
- && dispute1.repudiation_id == dispute2.repudiation_id\
23
- && dispute1.result_code == dispute2.result_code\
24
- && dispute1.result_message == dispute2.result_message\
25
- && dispute1.status.eql?(dispute2.status)\
26
- && dispute1.status_message == dispute2.status_message
27
- end
28
-
29
- def its_the_same_money(money1, money2)
30
- money1.currency.eql?(money2.currency)\
31
- && money1.amount == money2.amount
32
- end
33
-
34
- def its_the_same_reason(reason1, reason2)
35
- reason1.dispute_reason_message == reason2.dispute_reason_message\
36
- && reason1.dispute_reason_type.eql?(reason2.dispute_reason_type)
1
+ require_relative 'wallet_context'
2
+ require_relative '../../lib/mangopay/api/service/disputes'
3
+
4
+ shared_context 'dispute_context' do
5
+ include_context 'wallet_context'
6
+
7
+ DISPUTE_PERSISTED ||= first_dispute
8
+ end
9
+
10
+ def first_dispute
11
+ MangoApi::Disputes.all[0]
12
+ end
13
+
14
+ def its_the_same_dispute(dispute1, dispute2)
15
+ dispute1.contest_deadline_date == dispute2.contest_deadline_date\
16
+ && its_the_same_money(dispute1.contested_funds, dispute2.contested_funds)\
17
+ && its_the_same_money(dispute1.disputed_funds, dispute2.disputed_funds)\
18
+ && its_the_same_reason(dispute1.dispute_reason, dispute2.dispute_reason)\
19
+ && dispute1.dispute_type.eql?(dispute2.dispute_type)\
20
+ && dispute1.initial_transaction_id == dispute2.initial_transaction_id\
21
+ && dispute1.initial_transaction_type.eql?(dispute2.initial_transaction_type)\
22
+ && dispute1.repudiation_id == dispute2.repudiation_id\
23
+ && dispute1.result_code == dispute2.result_code\
24
+ && dispute1.result_message == dispute2.result_message\
25
+ && dispute1.status.eql?(dispute2.status)\
26
+ && dispute1.status_message == dispute2.status_message
27
+ end
28
+
29
+ def its_the_same_money(money1, money2)
30
+ money1.currency.eql?(money2.currency)\
31
+ && money1.amount == money2.amount
32
+ end
33
+
34
+ def its_the_same_reason(reason1, reason2)
35
+ reason1.dispute_reason_message == reason2.dispute_reason_message\
36
+ && reason1.dispute_reason_type.eql?(reason2.dispute_reason_type)
37
37
  end
@@ -1,20 +1,20 @@
1
- require_relative 'dispute_context'
2
- require_relative '../../lib/mangopay/model/entity/dispute_document'
3
- require_relative '../../lib/mangopay/model/enum/dispute_document_type'
4
-
5
- shared_context 'dispute_document_context' do
6
- include_context 'dispute_context'
7
-
8
- DISPUTE_DOCUMENT_DATA ||= build_dispute_document
9
- DISPUTE_DOCUMENT_PERSISTED ||= persisted_dispute_doc
10
- end
11
-
12
- def persisted_dispute_doc
13
- MangoApi::DisputeDocuments.all[0]
14
- end
15
-
16
- def build_dispute_document
17
- document = MangoModel::DisputeDocument.new
18
- document.type = MangoModel::DisputeDocumentType::REFUND_PROOF
19
- document
1
+ require_relative 'dispute_context'
2
+ require_relative '../../lib/mangopay/model/entity/dispute_document'
3
+ require_relative '../../lib/mangopay/model/enum/dispute_document_type'
4
+
5
+ shared_context 'dispute_document_context' do
6
+ include_context 'dispute_context'
7
+
8
+ DISPUTE_DOCUMENT_DATA ||= build_dispute_document
9
+ DISPUTE_DOCUMENT_PERSISTED ||= persisted_dispute_doc
10
+ end
11
+
12
+ def persisted_dispute_doc
13
+ MangoApi::DisputeDocuments.all[0]
14
+ end
15
+
16
+ def build_dispute_document
17
+ document = MangoModel::DisputeDocument.new
18
+ document.type = MangoModel::DisputeDocumentType::REFUND_PROOF
19
+ document
20
20
  end
@@ -1,16 +1,16 @@
1
- require_relative '../../lib/mangopay/api/service/hooks'
2
- require_relative '../../lib/mangopay/model/enum/event_type'
3
- require_relative '../../lib/mangopay/model/entity/hook'
4
-
5
- shared_context 'hook_context' do
6
-
7
- HOOK_DATA = build_hook
8
- HOOK_PERSISTED = MangoApi::Hooks.all[0]
9
- end
10
-
11
- def build_hook
12
- hook = MangoModel::Hook.new
13
- hook.event_type = MangoModel::EventType::PAYIN_REPUDIATION_CREATED
14
- hook.url = 'http://www.my-site.com/hooks/'
15
- hook
1
+ require_relative '../../lib/mangopay/api/service/hooks'
2
+ require_relative '../../lib/mangopay/model/enum/event_type'
3
+ require_relative '../../lib/mangopay/model/entity/hook'
4
+
5
+ shared_context 'hook_context' do
6
+
7
+ HOOK_DATA = build_hook
8
+ HOOK_PERSISTED = MangoApi::Hooks.all[0]
9
+ end
10
+
11
+ def build_hook
12
+ hook = MangoModel::Hook.new
13
+ hook.event_type = MangoModel::EventType::PAYIN_REPUDIATION_CREATED
14
+ hook.url = 'http://www.my-site.com/hooks/'
15
+ hook
16
16
  end
@@ -1,23 +1,23 @@
1
- require_relative 'user_context'
2
- require_relative '../../lib/mangopay/api/service/kyc_documents'
3
-
4
- shared_context 'kyc_document_context' do
5
- include_context 'user_context'
6
-
7
- KYC_DOCUMENT_DATA ||= build_kyc_document
8
- KYC_DOCUMENT_PERSISTED ||= persist_kyc_doc KYC_DOCUMENT_DATA
9
- end
10
-
11
- def persist_kyc_doc(kyc_doc)
12
- MangoApi::KycDocuments.create kyc_doc, NATURAL_USER_PERSISTED.id
13
- end
14
-
15
- def build_kyc_document
16
- kyc_doc = MangoModel::KycDocument.new
17
- kyc_doc.type = MangoModel::KycDocumentType::IDENTITY_PROOF
18
- kyc_doc
19
- end
20
-
21
- def its_the_same_kyc_doc(kyc_doc1, kyc_doc2)
22
- kyc_doc1.type.eql?(kyc_doc2.type)
1
+ require_relative 'user_context'
2
+ require_relative '../../lib/mangopay/api/service/kyc_documents'
3
+
4
+ shared_context 'kyc_document_context' do
5
+ include_context 'user_context'
6
+
7
+ KYC_DOCUMENT_DATA ||= build_kyc_document
8
+ KYC_DOCUMENT_PERSISTED ||= persist_kyc_doc KYC_DOCUMENT_DATA
9
+ end
10
+
11
+ def persist_kyc_doc(kyc_doc)
12
+ MangoApi::KycDocuments.create kyc_doc, NATURAL_USER_PERSISTED.id
13
+ end
14
+
15
+ def build_kyc_document
16
+ kyc_doc = MangoModel::KycDocument.new
17
+ kyc_doc.type = MangoModel::KycDocumentType::IDENTITY_PROOF
18
+ kyc_doc
19
+ end
20
+
21
+ def its_the_same_kyc_doc(kyc_doc1, kyc_doc2)
22
+ kyc_doc1.type.eql?(kyc_doc2.type)
23
23
  end
@@ -1,27 +1,27 @@
1
- require_relative 'bank_account_context'
2
- require_relative '../../lib/mangopay/model/enum/mandate_culture_code'
3
- require_relative '../../lib/mangopay/api/service/mandates'
4
-
5
- shared_context 'mandate_context' do
6
- include_context 'bank_account_context'
7
-
8
- MANDATE_DATA ||= build_mandate
9
- MANDATE_PERSISTED ||= persist_mandate MANDATE_DATA
10
- end
11
-
12
- def persist_mandate(mandate)
13
- MangoApi::Mandates.create mandate
14
- end
15
-
16
- def build_mandate
17
- mandate = MangoModel::Mandate.new
18
- mandate.bank_account_id = IBAN_ACCOUNT_PERSISTED.id
19
- mandate.culture = MangoModel::MandateCultureCode::EN
20
- mandate.return_url = 'http://www.my-site.com/returnURL/'
21
- mandate
22
- end
23
-
24
- def its_the_same_mandate(mandate1, mandate2)
25
- mandate1.bank_account_id == mandate2.bank_account_id\
26
- && mandate1.culture.eql?(mandate2.culture)
1
+ require_relative 'bank_account_context'
2
+ require_relative '../../lib/mangopay/model/enum/mandate_culture_code'
3
+ require_relative '../../lib/mangopay/api/service/mandates'
4
+
5
+ shared_context 'mandate_context' do
6
+ include_context 'bank_account_context'
7
+
8
+ MANDATE_DATA ||= build_mandate
9
+ MANDATE_PERSISTED ||= persist_mandate MANDATE_DATA
10
+ end
11
+
12
+ def persist_mandate(mandate)
13
+ MangoApi::Mandates.create mandate
14
+ end
15
+
16
+ def build_mandate
17
+ mandate = MangoModel::Mandate.new
18
+ mandate.bank_account_id = IBAN_ACCOUNT_PERSISTED.id
19
+ mandate.culture = MangoModel::MandateCultureCode::EN
20
+ mandate.return_url = 'http://www.my-site.com/returnURL/'
21
+ mandate
22
+ end
23
+
24
+ def its_the_same_mandate(mandate1, mandate2)
25
+ mandate1.bank_account_id == mandate2.bank_account_id\
26
+ && mandate1.culture.eql?(mandate2.culture)
27
27
  end
@@ -1,225 +1,320 @@
1
- require_relative 'wallet_context'
2
- require_relative 'card_context'
3
- require_relative 'pre_authorization_context'
4
- require_relative 'mandate_context'
5
- require_relative '../../lib/mangopay/api/service/pay_ins'
6
- require_relative '../../lib/mangopay/model/enum/card_type'
7
- require_relative '../../lib/mangopay/model/enum/direct_debit_type'
8
- require_relative '../../lib/mangopay/model/entity/pay_in/card_web_pay_in'
9
- require_relative '../../lib/mangopay/model/entity/pay_in/card_direct_pay_in'
10
- require_relative '../../lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in'
11
- require_relative '../../lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in'
12
- require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in'
13
- require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in'
14
- require_relative '../../lib/mangopay/common/template_url_options'
15
-
16
- shared_context 'pay_in_context' do
17
- include_context 'wallet_context'
18
- include_context 'card_context'
19
- include_context 'pre_authorization_context'
20
- include_context 'mandate_context'
21
-
22
- CARD_WEB_PAY_IN_DATA ||= build_card_web_pay_in
23
- CARD_DIRECT_PAY_IN_DATA ||= build_card_direct_pay_in
24
- CARD_PRE_AUTH_PAY_IN_DATA ||= build_card_pre_auth_pay_in
25
- BANK_WIRE_DIRECT_PAY_IN_DATA ||= build_bank_wire_direct_pay_in
26
- DIRECT_DEBIT_WEB_PAY_IN_DATA ||= build_direct_debit_web_pay_in
27
- DIRECT_DEBIT_DIRECT_PAY_IN_DATA ||= build_direct_debit_direct_pay_in
28
- CARD_WEB_PAY_IN_PERSISTED ||= persist_card_web CARD_WEB_PAY_IN_DATA
29
- CARD_DIRECT_PAY_IN_PERSISTED ||= persist_card_direct CARD_DIRECT_PAY_IN_DATA
30
- CARD_PRE_AUTH_PAY_IN_PERSISTED ||= persist_card_pre_auth CARD_PRE_AUTH_PAY_IN_DATA
31
- BANK_WIRE_DIRECT_PAY_IN_PERSISTED ||= persist_bank_wire_direct BANK_WIRE_DIRECT_PAY_IN_DATA
32
- DIRECT_DEBIT_WEB_PAY_IN_PERSISTED ||= persist_direct_debit_web DIRECT_DEBIT_WEB_PAY_IN_DATA
33
- DIRECT_DEBIT_DIRECT_PAY_IN_PERSISTED ||= persist_direct_debit_direct DIRECT_DEBIT_DIRECT_PAY_IN_DATA
34
- end
35
-
36
- def persist_card_web(pay_in)
37
- MangoApi::PayIns.create_card_web pay_in
38
- end
39
-
40
- def persist_card_direct(pay_in)
41
- MangoApi::PayIns.create_card_direct pay_in
42
- end
43
-
44
- def persist_card_pre_auth(pay_in)
45
- MangoApi::PayIns.create_card_pre_authorized pay_in
46
- end
47
-
48
- def persist_bank_wire_direct(pay_in)
49
- MangoApi::PayIns.create_bank_wire_direct pay_in
50
- end
51
-
52
- def persist_direct_debit_web(pay_in)
53
- MangoApi::PayIns.create_direct_debit_web pay_in
54
- end
55
-
56
- def persist_direct_debit_direct(pay_in)
57
- MangoApi::PayIns.create_direct_debit_direct pay_in
58
- end
59
-
60
- def build_card_web_pay_in
61
- pay_in = MangoModel::CardWebPayIn.new
62
- pay_in.author_id = NATURAL_USER_PERSISTED.id
63
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
64
- pay_in.debited_funds = MangoModel::Money.new
65
- pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
66
- pay_in.debited_funds.amount = 120
67
- pay_in.fees = MangoModel::Money.new
68
- pay_in.fees.currency = MangoModel::CurrencyIso::EUR
69
- pay_in.fees.amount = 30
70
- pay_in.return_url = 'http://www.my-site.com/returnURL/'
71
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
72
- pay_in.card_type = MangoModel::CardType::CB_VISA_MASTERCARD
73
- pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
74
- pay_in.culture = MangoModel::CultureCode::EN
75
- pay_in.template_url_options = TemplateUrlOptions.new
76
- pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
77
- pay_in.statement_descriptor = 'Mar2016'
78
- pay_in
79
- end
80
-
81
- def build_card_direct_pay_in
82
- pay_in = MangoModel::CardDirectPayIn.new
83
- pay_in.author_id = NATURAL_USER_PERSISTED.id
84
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
85
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
86
- pay_in.debited_funds = MangoModel::Money.new
87
- pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
88
- pay_in.debited_funds.amount = 120
89
- pay_in.fees = MangoModel::Money.new
90
- pay_in.fees.currency = MangoModel::CurrencyIso::EUR
91
- pay_in.fees.amount = 30
92
- pay_in.secure_mode_return_url = 'http://www.my-site.com/returnURL/'
93
- pay_in.card_id = CARD.id
94
- pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
95
- pay_in.statement_descriptor = 'Mar2016'
96
- pay_in
97
- end
98
-
99
- def build_card_pre_auth_pay_in
100
- pay_in = MangoModel::CardPreAuthorizedPayIn.new
101
- pay_in.author_id = NATURAL_USER_PERSISTED.id
102
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
103
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
104
- pay_in.debited_funds = MangoModel::Money.new
105
- pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
106
- pay_in.debited_funds.amount = 120
107
- pay_in.fees = MangoModel::Money.new
108
- pay_in.fees.currency = MangoModel::CurrencyIso::EUR
109
- pay_in.fees.amount = 30
110
- pay_in.preauthorization_id = PRE_AUTHORIZATION_PERSISTED.id
111
- pay_in
112
- end
113
-
114
- def build_bank_wire_direct_pay_in
115
- pay_in = MangoModel::BankWireDirectPayIn.new
116
- pay_in.author_id = NATURAL_USER_PERSISTED.id
117
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
118
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
119
- pay_in.declared_debited_funds = MangoModel::Money.new
120
- pay_in.declared_debited_funds.currency = MangoModel::CurrencyIso::EUR
121
- pay_in.declared_debited_funds.amount = 120
122
- pay_in.declared_fees = MangoModel::Money.new
123
- pay_in.declared_fees.currency = MangoModel::CurrencyIso::EUR
124
- pay_in.declared_fees.amount = 80
125
- pay_in
126
- end
127
-
128
- def build_direct_debit_web_pay_in
129
- pay_in = MangoModel::DirectDebitWebPayIn.new
130
- pay_in.author_id = NATURAL_USER_PERSISTED.id
131
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
132
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
133
- pay_in.debited_funds = MangoModel::Money.new
134
- pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
135
- pay_in.debited_funds.amount = 120
136
- pay_in.fees = MangoModel::Money.new
137
- pay_in.fees.currency = MangoModel::CurrencyIso::EUR
138
- pay_in.fees.amount = 80
139
- pay_in.return_url = 'http://www.my-site.com/returnURL/'
140
- pay_in.direct_debit_type = MangoModel::DirectDebitType::SOFORT
141
- pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
142
- pay_in.culture = MangoModel::CultureCode::EN
143
- pay_in.template_url_options = TemplateUrlOptions.new
144
- pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
145
- pay_in
146
- end
147
-
148
- def build_direct_debit_direct_pay_in
149
- pay_in = MangoModel::DirectDebitDirectPayIn.new
150
- pay_in.author_id = NATURAL_USER_PERSISTED.id
151
- pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
152
- pay_in.credited_wallet_id = WALLET_PERSISTED.id
153
- pay_in.debited_funds = MangoModel::Money.new
154
- pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
155
- pay_in.debited_funds.amount = 120
156
- pay_in.fees = MangoModel::Money.new
157
- pay_in.fees.currency = MangoModel::CurrencyIso::EUR
158
- pay_in.fees.amount = 80
159
- pay_in.mandate_id = MANDATE_PERSISTED.id
160
- pay_in.statement_descriptor = 'Nov2016'
161
- pay_in
162
- end
163
-
164
- def its_the_same_card_web(pay_in1, pay_in2)
165
- pay_in1.author_id == pay_in2.author_id\
166
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
167
- && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
168
- && its_the_same_money(pay_in1.fees, pay_in2.fees)\
169
- && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
170
- && pay_in1.card_type.eql?(pay_in2.card_type)\
171
- && pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
172
- && pay_in1.culture.eql?(pay_in2.culture)\
173
- && pay_in1.statement_descriptor == pay_in2.statement_descriptor
174
- end
175
-
176
- def its_the_same_card_direct(pay_in1, pay_in2)
177
- pay_in1.author_id == pay_in2.author_id\
178
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
179
- && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
180
- && its_the_same_money(pay_in1.fees, pay_in2.fees)\
181
- && pay_in1.card_id == pay_in2.card_id\
182
- && pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
183
- && pay_in1.statement_descriptor == pay_in2.statement_descriptor
184
- end
185
-
186
- def its_the_same_card_pre_auth(pay_in1, pay_in2)
187
- pay_in1.author_id == pay_in2.author_id\
188
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
189
- && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
190
- && its_the_same_money(pay_in1.fees, pay_in2.fees)\
191
- && pay_in1.preauthorization_id == pay_in2.preauthorization_id
192
- end
193
-
194
- def its_the_same_bank_wire_direct(pay_in1, pay_in2)
195
- pay_in1.author_id == pay_in2.author_id\
196
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
197
- && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
198
- && its_the_same_money(pay_in1.declared_debited_funds, pay_in2.declared_debited_funds)\
199
- && its_the_same_money(pay_in1.declared_fees, pay_in2.declared_fees)
200
- end
201
-
202
- def its_the_same_direct_debit_web(pay_in1, pay_in2)
203
- pay_in1.author_id == pay_in2.author_id\
204
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
205
- && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
206
- && its_the_same_money(pay_in1.fees, pay_in2.fees)\
207
- && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
208
- && pay_in1.direct_debit_type.eql?(pay_in2.direct_debit_type)\
209
- && pay_in1.culture.eql?(pay_in2.culture)
210
- end
211
-
212
- def its_the_same_direct_debit_direct(pay_in1, pay_in2)
213
- pay_in1.author_id == pay_in2.author_id\
214
- && pay_in1.credited_user_id == pay_in2.credited_user_id\
215
- && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
216
- && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
217
- && its_the_same_money(pay_in1.fees, pay_in2.fees)\
218
- && pay_in1.mandate_id == pay_in2.mandate_id\
219
- && pay_in1.statement_descriptor == pay_in2.statement_descriptor
220
- end
221
-
222
- def its_the_same_money(money1, money2)
223
- money1.currency.eql?(money2.currency)\
224
- && money1.amount == money2.amount
1
+ require_relative 'wallet_context'
2
+ require_relative 'card_context'
3
+ require_relative 'pre_authorization_context'
4
+ require_relative 'mandate_context'
5
+ require_relative '../../lib/mangopay/api/service/pay_ins'
6
+ require_relative '../../lib/mangopay/model/enum/card_type'
7
+ require_relative '../../lib/mangopay/model/enum/direct_debit_type'
8
+ require_relative '../../lib/mangopay/model/entity/pay_in/card_web_pay_in'
9
+ require_relative '../../lib/mangopay/model/entity/pay_in/card_direct_pay_in'
10
+ require_relative '../../lib/mangopay/model/entity/pay_in/card_pre_authorized_pay_in'
11
+ require_relative '../../lib/mangopay/model/entity/pay_in/bank_wire_direct_pay_in'
12
+ require_relative '../../lib/mangopay/model/entity/pay_in/bank_wire_external_instruction_pay_in'
13
+ require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_web_pay_in'
14
+ require_relative '../../lib/mangopay/model/entity/pay_in/direct_debit_direct_pay_in'
15
+ require_relative '../../lib/mangopay/model/entity/pay_in/apple_pay_direct_pay_in'
16
+ require_relative '../../lib/mangopay/model/entity/pay_in/paypal_web_pay_in'
17
+ require_relative '../../lib/mangopay/common/template_url_options'
18
+
19
+ shared_context 'pay_in_context' do
20
+ include_context 'wallet_context'
21
+ include_context 'card_context'
22
+ include_context 'pre_authorization_context'
23
+ include_context 'mandate_context'
24
+
25
+ CARD_WEB_PAY_IN_DATA ||= build_card_web_pay_in
26
+ CARD_DIRECT_PAY_IN_DATA ||= build_card_direct_pay_in
27
+ CARD_PRE_AUTH_PAY_IN_DATA ||= build_card_pre_auth_pay_in
28
+ BANK_WIRE_DIRECT_PAY_IN_DATA ||= build_bank_wire_direct_pay_in
29
+ DIRECT_DEBIT_WEB_PAY_IN_DATA ||= build_direct_debit_web_pay_in
30
+ DIRECT_DEBIT_DIRECT_PAY_IN_DATA ||= build_direct_debit_direct_pay_in
31
+ PAYPAL_PAY_IN_DATA ||= build_paypal_pay_in
32
+ APPLE_PAY_PAY_IN_DATA ||= build_apple_pay_pay_in
33
+ CARD_WEB_PAY_IN_PERSISTED ||= persist_card_web CARD_WEB_PAY_IN_DATA
34
+ CARD_DIRECT_PAY_IN_PERSISTED ||= persist_card_direct CARD_DIRECT_PAY_IN_DATA
35
+ CARD_PRE_AUTH_PAY_IN_PERSISTED ||= persist_card_pre_auth CARD_PRE_AUTH_PAY_IN_DATA
36
+ BANK_WIRE_DIRECT_PAY_IN_PERSISTED ||= persist_bank_wire_direct BANK_WIRE_DIRECT_PAY_IN_DATA
37
+ DIRECT_DEBIT_WEB_PAY_IN_PERSISTED ||= persist_direct_debit_web DIRECT_DEBIT_WEB_PAY_IN_DATA
38
+ DIRECT_DEBIT_DIRECT_PAY_IN_PERSISTED ||= persist_direct_debit_direct DIRECT_DEBIT_DIRECT_PAY_IN_DATA
39
+ PAYPAL_PAY_IN_PERSISTED ||= persist_paypal_web PAYPAL_PAY_IN_DATA
40
+ APPLE_PAY_PAY_IN_PERSISTED ||= persis_apple_pay_direct APPLE_PAY_PAY_IN_DATA
41
+ end
42
+
43
+ def persist_card_web(pay_in)
44
+ MangoApi::PayIns.create_card_web pay_in
45
+ end
46
+
47
+ def persist_card_direct(pay_in)
48
+ MangoApi::PayIns.create_card_direct pay_in
49
+ end
50
+
51
+ def persist_card_pre_auth(pay_in)
52
+ MangoApi::PayIns.create_card_pre_authorized pay_in
53
+ end
54
+
55
+ def persist_bank_wire_direct(pay_in)
56
+ MangoApi::PayIns.create_bank_wire_direct pay_in
57
+ end
58
+
59
+ def persist_direct_debit_web(pay_in)
60
+ MangoApi::PayIns.create_direct_debit_web pay_in
61
+ end
62
+
63
+ def persist_direct_debit_direct(pay_in)
64
+ MangoApi::PayIns.create_direct_debit_direct pay_in
65
+ end
66
+
67
+ def persist_paypal_web(pay_in)
68
+ MangoApi::PayIns.create_paypal_web pay_in
69
+ end
70
+
71
+ def persis_apple_pay_direct(pay_in)
72
+ MangoApi::PayIns.create_apple_pay_direct pay_in
73
+ end
74
+
75
+ def build_card_web_pay_in
76
+ pay_in = MangoModel::CardWebPayIn.new
77
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
78
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
79
+ pay_in.debited_funds = MangoModel::Money.new
80
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
81
+ pay_in.debited_funds.amount = 120
82
+ pay_in.fees = MangoModel::Money.new
83
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
84
+ pay_in.fees.amount = 30
85
+ pay_in.return_url = 'http://www.my-site.com/returnURL/'
86
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
87
+ pay_in.card_type = MangoModel::CardType::CB_VISA_MASTERCARD
88
+ pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
89
+ pay_in.culture = MangoModel::CultureCode::EN
90
+ pay_in.template_url_options = TemplateUrlOptions.new
91
+ pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
92
+ pay_in.statement_descriptor = 'Mar2016'
93
+ pay_in
94
+ end
95
+
96
+ def build_card_direct_pay_in
97
+ pay_in = MangoModel::CardDirectPayIn.new
98
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
99
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
100
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
101
+ pay_in.debited_funds = MangoModel::Money.new
102
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
103
+ pay_in.debited_funds.amount = 120
104
+ pay_in.fees = MangoModel::Money.new
105
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
106
+ pay_in.fees.amount = 30
107
+ pay_in.secure_mode_return_url = 'http://www.my-site.com/returnURL/'
108
+ pay_in.card_id = CARD.id
109
+ pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
110
+ pay_in.statement_descriptor = 'Mar2016'
111
+ billing = MangoModel::Billing.new
112
+ billing.address = build_address
113
+ billing.address.postal_code = '68400'
114
+ pay_in.billing = billing
115
+ pay_in.culture = MangoModel::CultureCode::FR
116
+ pay_in
117
+ end
118
+
119
+ def build_card_pre_auth_pay_in
120
+ pay_in = MangoModel::CardPreAuthorizedPayIn.new
121
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
122
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
123
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
124
+ pay_in.debited_funds = MangoModel::Money.new
125
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
126
+ pay_in.debited_funds.amount = 120
127
+ pay_in.fees = MangoModel::Money.new
128
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
129
+ pay_in.fees.amount = 30
130
+ pay_in.preauthorization_id = PRE_AUTHORIZATION_PERSISTED.id
131
+ pay_in.culture = MangoModel::CultureCode::FR
132
+ pay_in
133
+ end
134
+
135
+ def build_bank_wire_direct_pay_in
136
+ pay_in = MangoModel::BankWireDirectPayIn.new
137
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
138
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
139
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
140
+ pay_in.declared_debited_funds = MangoModel::Money.new
141
+ pay_in.declared_debited_funds.currency = MangoModel::CurrencyIso::EUR
142
+ pay_in.declared_debited_funds.amount = 120
143
+ pay_in.declared_fees = MangoModel::Money.new
144
+ pay_in.declared_fees.currency = MangoModel::CurrencyIso::EUR
145
+ pay_in.declared_fees.amount = 80
146
+ pay_in.culture = MangoModel::CultureCode::FR
147
+ pay_in
148
+ end
149
+
150
+ def build_direct_debit_web_pay_in
151
+ pay_in = MangoModel::DirectDebitWebPayIn.new
152
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
153
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
154
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
155
+ pay_in.debited_funds = MangoModel::Money.new
156
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
157
+ pay_in.debited_funds.amount = 10000
158
+ pay_in.fees = MangoModel::Money.new
159
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
160
+ pay_in.fees.amount = 100
161
+ pay_in.return_url = 'http://www.my-site.com/returnURL/'
162
+ pay_in.direct_debit_type = MangoModel::DirectDebitType::GIROPAY
163
+ pay_in.secure_mode = MangoModel::SecureMode::DEFAULT
164
+ pay_in.culture = MangoModel::CultureCode::EN
165
+ pay_in.template_url_options = TemplateUrlOptions.new
166
+ pay_in.template_url_options.payline = 'https://www.mysite.com/template/'
167
+ pay_in
168
+ end
169
+
170
+ def build_paypal_pay_in
171
+ pay_in = MangoModel::PaypalWebPayIn.new
172
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
173
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
174
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
175
+ pay_in.debited_funds = MangoModel::Money.new
176
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
177
+ pay_in.debited_funds.amount = 10000
178
+ pay_in.fees = MangoModel::Money.new
179
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
180
+ pay_in.fees.amount = 100
181
+ pay_in.return_url = 'http://www.my-site.com/returnURL/'
182
+ pay_in.culture = MangoModel::CultureCode::FR
183
+ pay_in
184
+ end
185
+
186
+ def build_direct_debit_direct_pay_in
187
+ pay_in = MangoModel::DirectDebitDirectPayIn.new
188
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
189
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
190
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
191
+ pay_in.debited_funds = MangoModel::Money.new
192
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
193
+ pay_in.debited_funds.amount = 10000
194
+ pay_in.fees = MangoModel::Money.new
195
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
196
+ pay_in.fees.amount = 100
197
+ pay_in.mandate_id = MANDATE_PERSISTED.id
198
+ pay_in.culture = MangoModel::CultureCode::FR
199
+ pay_in
200
+ end
201
+
202
+ def build_apple_pay_pay_in
203
+ pay_in = MangoModel::ApplePayPayIn.new
204
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
205
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
206
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
207
+ pay_in.debited_funds = MangoModel::Money.new
208
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
209
+ pay_in.debited_funds.amount = 199
210
+ pay_in.fees = MangoModel::Money.new
211
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
212
+ pay_in.fees.amount = 1
213
+ pay_in.return_url = 'http://www.my-site.com/returnURL/'
214
+ pay_in.payment_data = {
215
+ TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
216
+ Network: 'VISA',
217
+ TokenData: "{\"version\":\"EC_v1\",\"data\":\"w4HMBVqNC9ghPP4zncTA\\/0oQAsduERfsx78oxgniynNjZLANTL6+0koEtkQnW\\/K38Zew8qV1GLp+fLHo+qCBpiKCIwlz3eoFBTbZU+8pYcjaeIYBX9SOxcwxXsNGrGLk+kBUqnpiSIPaAG1E+WPT8R1kjOCnGvtdombvricwRTQkGjtovPfzZo8LzD3ZQJnHMsWJ8QYDLyr\\/ZN9gtLAtsBAMvwManwiaG3pOIWpyeOQOb01YcEVO16EZBjaY4x4C\\/oyFLWDuKGvhbJwZqWh1d1o9JT29QVmvy3Oq2JEjq3c3NutYut4rwDE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QfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
218
+ }
219
+ pay_in
220
+ end
221
+
222
+ def build_google_pay_pay_in
223
+ pay_in = MangoModel::GooglePayPayIn.new
224
+ pay_in.author_id = NATURAL_USER_PERSISTED.id
225
+ pay_in.credited_user_id = NATURAL_USER_PERSISTED.id
226
+ pay_in.credited_wallet_id = WALLET_PERSISTED.id
227
+ pay_in.debited_funds = MangoModel::Money.new
228
+ pay_in.debited_funds.currency = MangoModel::CurrencyIso::EUR
229
+ pay_in.debited_funds.amount = 199
230
+ pay_in.fees = MangoModel::Money.new
231
+ pay_in.fees.currency = MangoModel::CurrencyIso::EUR
232
+ pay_in.fees.amount = 1
233
+ pay_in.return_url = 'http://www.my-site.com/returnURL/'
234
+ pay_in.payment_data = {
235
+ TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
236
+ Network: 'VISA',
237
+ TokenData: "token_data"
238
+ }
239
+ pay_in
240
+ end
241
+
242
+ def its_the_same_card_web(pay_in1, pay_in2)
243
+ pay_in1.author_id == pay_in2.author_id\
244
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
245
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
246
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
247
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
248
+ && pay_in1.card_type.eql?(pay_in2.card_type)\
249
+ && pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
250
+ && pay_in1.culture.eql?(pay_in2.culture)\
251
+ && pay_in1.statement_descriptor == pay_in2.statement_descriptor
252
+ end
253
+
254
+ def its_the_same_card_direct(pay_in1, pay_in2)
255
+ pay_in1.author_id == pay_in2.author_id\
256
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
257
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
258
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
259
+ && pay_in1.card_id == pay_in2.card_id\
260
+ && pay_in1.secure_mode.eql?(pay_in2.secure_mode)\
261
+ && pay_in1.statement_descriptor == pay_in2.statement_descriptor
262
+ end
263
+
264
+ def its_the_same_card_pre_auth(pay_in1, pay_in2)
265
+ pay_in1.author_id == pay_in2.author_id\
266
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
267
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
268
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
269
+ && pay_in1.preauthorization_id == pay_in2.preauthorization_id
270
+ end
271
+
272
+ def its_the_same_bank_wire_direct(pay_in1, pay_in2)
273
+ pay_in1.author_id == pay_in2.author_id\
274
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
275
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
276
+ && its_the_same_money(pay_in1.declared_debited_funds, pay_in2.declared_debited_funds)\
277
+ && its_the_same_money(pay_in1.declared_fees, pay_in2.declared_fees)
278
+ end
279
+
280
+ def its_the_same_direct_debit_web(pay_in1, pay_in2)
281
+ pay_in1.author_id == pay_in2.author_id\
282
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
283
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
284
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
285
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
286
+ && pay_in1.direct_debit_type.eql?(pay_in2.direct_debit_type)\
287
+ && pay_in1.culture.eql?(pay_in2.culture)
288
+ end
289
+
290
+ def its_the_same_paypal_web(pay_in1, pay_in2)
291
+ pay_in1.author_id == pay_in2.author_id\
292
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
293
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
294
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
295
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
296
+ && pay_in1.culture.eql?(pay_in2.culture)
297
+ end
298
+
299
+ def its_the_same_direct_debit_direct(pay_in1, pay_in2)
300
+ pay_in1.author_id == pay_in2.author_id\
301
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
302
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
303
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
304
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)\
305
+ && pay_in1.mandate_id == pay_in2.mandate_id\
306
+ && pay_in1.statement_descriptor == pay_in2.statement_descriptor
307
+ end
308
+
309
+ def its_the_same_apple_pay_direct(pay_in1, pay_in2)
310
+ pay_in1.author_id == pay_in2.author_id\
311
+ && pay_in1.credited_user_id == pay_in2.credited_user_id\
312
+ && pay_in1.credited_wallet_id == pay_in2.credited_wallet_id\
313
+ && its_the_same_money(pay_in1.debited_funds, pay_in2.debited_funds)\
314
+ && its_the_same_money(pay_in1.fees, pay_in2.fees)
315
+ end
316
+
317
+ def its_the_same_money(money1, money2)
318
+ money1.currency.eql?(money2.currency)\
319
+ && money1.amount == money2.amount
225
320
  end