bk-apimatic-sdk 1.0.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 (140) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +203 -0
  4. data/bin/console +15 -0
  5. data/lib/boku_direct_payments_api/api_helper.rb +10 -0
  6. data/lib/boku_direct_payments_api/client.rb +99 -0
  7. data/lib/boku_direct_payments_api/configuration.rb +168 -0
  8. data/lib/boku_direct_payments_api/controllers/account_resources_controller.rb +45 -0
  9. data/lib/boku_direct_payments_api/controllers/base_controller.rb +60 -0
  10. data/lib/boku_direct_payments_api/controllers/charge_controller.rb +247 -0
  11. data/lib/boku_direct_payments_api/controllers/config_resources_controller.rb +50 -0
  12. data/lib/boku_direct_payments_api/controllers/consumer_registration_controller.rb +428 -0
  13. data/lib/boku_direct_payments_api/controllers/forex_controller.rb +38 -0
  14. data/lib/boku_direct_payments_api/controllers/fund_check_controller.rb +39 -0
  15. data/lib/boku_direct_payments_api/controllers/refund_controller.rb +80 -0
  16. data/lib/boku_direct_payments_api/controllers/seller_of_record_controller.rb +69 -0
  17. data/lib/boku_direct_payments_api/exceptions/api_exception.rb +21 -0
  18. data/lib/boku_direct_payments_api/http/http_call_back.rb +10 -0
  19. data/lib/boku_direct_payments_api/http/http_method_enum.rb +10 -0
  20. data/lib/boku_direct_payments_api/http/http_request.rb +10 -0
  21. data/lib/boku_direct_payments_api/http/http_response.rb +10 -0
  22. data/lib/boku_direct_payments_api/http/proxy_settings.rb +22 -0
  23. data/lib/boku_direct_payments_api/models/account_profile.rb +122 -0
  24. data/lib/boku_direct_payments_api/models/account_profile_attribute.rb +90 -0
  25. data/lib/boku_direct_payments_api/models/account_profile_request.rb +131 -0
  26. data/lib/boku_direct_payments_api/models/account_profile_response.rb +104 -0
  27. data/lib/boku_direct_payments_api/models/account_profile_response_record.rb +142 -0
  28. data/lib/boku_direct_payments_api/models/account_profile_result_status_enum.rb +47 -0
  29. data/lib/boku_direct_payments_api/models/account_profile_selector.rb +132 -0
  30. data/lib/boku_direct_payments_api/models/base_model.rb +110 -0
  31. data/lib/boku_direct_payments_api/models/begin_single_charge_request.rb +360 -0
  32. data/lib/boku_direct_payments_api/models/begin_single_charge_request_hosted.rb +110 -0
  33. data/lib/boku_direct_payments_api/models/begin_single_charge_request_qr_info.rb +74 -0
  34. data/lib/boku_direct_payments_api/models/begin_single_charge_response.rb +254 -0
  35. data/lib/boku_direct_payments_api/models/begin_single_charge_response_hosted.rb +90 -0
  36. data/lib/boku_direct_payments_api/models/begin_single_charge_response_qr_info.rb +85 -0
  37. data/lib/boku_direct_payments_api/models/business_details.rb +209 -0
  38. data/lib/boku_direct_payments_api/models/cancel_optin_request.rb +123 -0
  39. data/lib/boku_direct_payments_api/models/cancel_optin_response.rb +143 -0
  40. data/lib/boku_direct_payments_api/models/carrier_gw.rb +82 -0
  41. data/lib/boku_direct_payments_api/models/charge.rb +288 -0
  42. data/lib/boku_direct_payments_api/models/charge_msisdn_request.rb +233 -0
  43. data/lib/boku_direct_payments_api/models/charge_plus_optin_request.rb +390 -0
  44. data/lib/boku_direct_payments_api/models/charge_plus_optin_request_hosted.rb +96 -0
  45. data/lib/boku_direct_payments_api/models/charge_plus_optin_response.rb +278 -0
  46. data/lib/boku_direct_payments_api/models/charge_plus_optin_response_hosted.rb +75 -0
  47. data/lib/boku_direct_payments_api/models/charge_request.rb +332 -0
  48. data/lib/boku_direct_payments_api/models/charge_response.rb +253 -0
  49. data/lib/boku_direct_payments_api/models/charge_status_enum.rb +43 -0
  50. data/lib/boku_direct_payments_api/models/check_eligibility_request.rb +117 -0
  51. data/lib/boku_direct_payments_api/models/check_eligibility_response.rb +116 -0
  52. data/lib/boku_direct_payments_api/models/client_call.rb +91 -0
  53. data/lib/boku_direct_payments_api/models/confirm_optin_request.rb +141 -0
  54. data/lib/boku_direct_payments_api/models/confirm_optin_response.rb +211 -0
  55. data/lib/boku_direct_payments_api/models/confirm_verify_device_request.rb +161 -0
  56. data/lib/boku_direct_payments_api/models/confirm_verify_device_response.rb +137 -0
  57. data/lib/boku_direct_payments_api/models/eligibility_status_enum.rb +40 -0
  58. data/lib/boku_direct_payments_api/models/forex_request.rb +97 -0
  59. data/lib/boku_direct_payments_api/models/forex_response.rb +127 -0
  60. data/lib/boku_direct_payments_api/models/fund_check_request.rb +132 -0
  61. data/lib/boku_direct_payments_api/models/fund_check_response.rb +89 -0
  62. data/lib/boku_direct_payments_api/models/invalid_request_field.rb +93 -0
  63. data/lib/boku_direct_payments_api/models/mandate_constraint.rb +92 -0
  64. data/lib/boku_direct_payments_api/models/mandate_period_enum.rb +48 -0
  65. data/lib/boku_direct_payments_api/models/mcc_mnc_mapping.rb +85 -0
  66. data/lib/boku_direct_payments_api/models/method_enum.rb +36 -0
  67. data/lib/boku_direct_payments_api/models/msisdn_network_request.rb +97 -0
  68. data/lib/boku_direct_payments_api/models/msisdn_network_response.rb +116 -0
  69. data/lib/boku_direct_payments_api/models/network_info.rb +84 -0
  70. data/lib/boku_direct_payments_api/models/network_info_network.rb +168 -0
  71. data/lib/boku_direct_payments_api/models/optin_accept_networks.rb +87 -0
  72. data/lib/boku_direct_payments_api/models/optin_info.rb +99 -0
  73. data/lib/boku_direct_payments_api/models/optin_info_optin_network.rb +104 -0
  74. data/lib/boku_direct_payments_api/models/optin_info_optin_types.rb +128 -0
  75. data/lib/boku_direct_payments_api/models/optin_network.rb +115 -0
  76. data/lib/boku_direct_payments_api/models/optin_purpose_enum.rb +62 -0
  77. data/lib/boku_direct_payments_api/models/optin_request.rb +338 -0
  78. data/lib/boku_direct_payments_api/models/optin_request_hosted.rb +110 -0
  79. data/lib/boku_direct_payments_api/models/optin_request_qr_info.rb +75 -0
  80. data/lib/boku_direct_payments_api/models/optin_response.rb +220 -0
  81. data/lib/boku_direct_payments_api/models/optin_response_hosted.rb +87 -0
  82. data/lib/boku_direct_payments_api/models/optin_response_qr_info.rb +85 -0
  83. data/lib/boku_direct_payments_api/models/optin_state.rb +164 -0
  84. data/lib/boku_direct_payments_api/models/optin_status_enum.rb +51 -0
  85. data/lib/boku_direct_payments_api/models/optin_terms.rb +214 -0
  86. data/lib/boku_direct_payments_api/models/optin_type_enum.rb +45 -0
  87. data/lib/boku_direct_payments_api/models/payment_method_status_enum.rb +44 -0
  88. data/lib/boku_direct_payments_api/models/period.rb +89 -0
  89. data/lib/boku_direct_payments_api/models/period_unit_enum.rb +46 -0
  90. data/lib/boku_direct_payments_api/models/query_charge_request.rb +149 -0
  91. data/lib/boku_direct_payments_api/models/query_charge_response.rb +101 -0
  92. data/lib/boku_direct_payments_api/models/query_optin_request.rb +104 -0
  93. data/lib/boku_direct_payments_api/models/query_optin_response.rb +129 -0
  94. data/lib/boku_direct_payments_api/models/query_refund_request.rb +122 -0
  95. data/lib/boku_direct_payments_api/models/query_refund_response.rb +101 -0
  96. data/lib/boku_direct_payments_api/models/refund.rb +249 -0
  97. data/lib/boku_direct_payments_api/models/refund_charge_notification.rb +88 -0
  98. data/lib/boku_direct_payments_api/models/refund_charge_request.rb +231 -0
  99. data/lib/boku_direct_payments_api/models/refund_charge_response.rb +203 -0
  100. data/lib/boku_direct_payments_api/models/refund_status_enum.rb +43 -0
  101. data/lib/boku_direct_payments_api/models/refund_type_enum.rb +36 -0
  102. data/lib/boku_direct_payments_api/models/register_payment_method_request.rb +152 -0
  103. data/lib/boku_direct_payments_api/models/register_payment_method_response.rb +172 -0
  104. data/lib/boku_direct_payments_api/models/register_seller_of_record_request.rb +118 -0
  105. data/lib/boku_direct_payments_api/models/register_seller_of_record_response.rb +156 -0
  106. data/lib/boku_direct_payments_api/models/resend_otp_request.rb +167 -0
  107. data/lib/boku_direct_payments_api/models/resend_otp_response.rb +118 -0
  108. data/lib/boku_direct_payments_api/models/result.rb +154 -0
  109. data/lib/boku_direct_payments_api/models/result_status_enum.rb +36 -0
  110. data/lib/boku_direct_payments_api/models/reversal.rb +89 -0
  111. data/lib/boku_direct_payments_api/models/reverse_charge_request.rb +104 -0
  112. data/lib/boku_direct_payments_api/models/reverse_charge_response.rb +157 -0
  113. data/lib/boku_direct_payments_api/models/seller_of_record.rb +76 -0
  114. data/lib/boku_direct_payments_api/models/seller_of_record_status_enum.rb +44 -0
  115. data/lib/boku_direct_payments_api/models/send_sms.rb +89 -0
  116. data/lib/boku_direct_payments_api/models/settlement.rb +126 -0
  117. data/lib/boku_direct_payments_api/models/silent_mo.rb +78 -0
  118. data/lib/boku_direct_payments_api/models/status_enum.rb +40 -0
  119. data/lib/boku_direct_payments_api/models/subscription.rb +105 -0
  120. data/lib/boku_direct_payments_api/models/timeout.rb +75 -0
  121. data/lib/boku_direct_payments_api/models/type_enum.rb +36 -0
  122. data/lib/boku_direct_payments_api/models/validate_optin_request.rb +179 -0
  123. data/lib/boku_direct_payments_api/models/validate_optin_response.rb +195 -0
  124. data/lib/boku_direct_payments_api/models/verify_device_request.rb +135 -0
  125. data/lib/boku_direct_payments_api/models/verify_device_response.rb +137 -0
  126. data/lib/boku_direct_payments_api/utilities/date_time_helper.rb +11 -0
  127. data/lib/boku_direct_payments_api/utilities/file_wrapper.rb +28 -0
  128. data/lib/boku_direct_payments_api/utilities/xml_utilities.rb +12 -0
  129. data/lib/boku_direct_payments_api.rb +166 -0
  130. data/test/controllers/controller_test_base.rb +23 -0
  131. data/test/controllers/test_account_resources_controller.rb +44 -0
  132. data/test/controllers/test_charge_controller.rb +159 -0
  133. data/test/controllers/test_config_resources_controller.rb +47 -0
  134. data/test/controllers/test_consumer_registration_controller.rb +262 -0
  135. data/test/controllers/test_forex_controller.rb +40 -0
  136. data/test/controllers/test_fund_check_controller.rb +41 -0
  137. data/test/controllers/test_refund_controller.rb +76 -0
  138. data/test/controllers/test_seller_of_record_controller.rb +72 -0
  139. data/test/http_response_catcher.rb +19 -0
  140. metadata +255 -0
@@ -0,0 +1,262 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class ConsumerRegistrationControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.consumer_registration
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # The `optin` API call is one of two ways to initiate the opt-in process. The other is `optin-info`, which uses cached information when available.
17
+ #While `optin` can be used to initiate all opt-ins, it is only _required_ for the following cases:
18
+ #- One-time Pin (OTP) opt-ins – to trigger sending an OTP SMS to the device.
19
+ #- Carrier gateway opt-ins* – when `optin-info` does not return a static URL and a unique URL must be generated per opt-in.
20
+ #After a successful `optin` call, the opt-in typically enters the `pending-validate` status.
21
+ #### Supported Optin Types
22
+ #
23
+ #- `otp` – Sends a one-time PIN to the consumer via SMS, confirmed via `confirm-optin`.
24
+ #- `hosted` – Redirects the consumer to an issuer-provided UI for verification.
25
+ #- `carrier-gw`* – Verifies the consumer via a ping through the carrier gateway.
26
+ #- `silent-mo`* – Verifies the consumer by sending a silent SMS from the device.
27
+ #
28
+ #_*These optin types are use-case specific and not required for most integrations. Only include them if explicitly directed._
29
+ #### Related Methods
30
+ #
31
+ #The `optin` method is used in conjunction with the following to complete consumer approval:
32
+ #- `validate-optin` – Validates the phone number (billing account) the consumer is registering as a payment method.
33
+ #- `submit-optin-parameters` – Submits carrier-specific parameters such as an account PIN, if required.
34
+ #- `confirm-optin` – Finalizes the opt-in and activates it for billing.
35
+ #### OTP Optin Defaults
36
+ #For OTP-based opt-ins using Boku-managed PINs, the following defaults apply:
37
+ #- PIN length: 4 digits
38
+ #- Validity period: 300 seconds
39
+ #- Maximum attempts: 3 (_Note: Carrier-managed PINs may follow different rules_).
40
+ #
41
+ def test_optin
42
+ # Parameters for the API call
43
+ body = OptinRequest.from_hash(APIHelper.json_deserialize(
44
+ '{"country":"GB","merchant-id":"gatewaymerchant","merchant-request-id":"'\
45
+ '2032405","merchant-consumer-id":"10203040","payment-method":"superwalle'\
46
+ 't","msisdn":"15555551212","optin-type":"hosted","hosted":{"forward-url"'\
47
+ ':"https://merchant.com/redirect/2032405"}}', false))
48
+
49
+ # Perform the API call through the SDK function
50
+ result = @controller.optin(body)
51
+
52
+ # Test response code
53
+ assert_equal(200, @response_catcher.response.status_code)
54
+ # Test headers
55
+ expected_headers = {}
56
+ expected_headers['content-type'] = 'application/xml'
57
+
58
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
59
+
60
+ # Test whether the captured response is as we expected
61
+ refute_nil(result)
62
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"timestamp\": \"2015-02-40 04:44:16\",\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"2032405\",\r\n \"optin-id\": \"IVXecDoa2f6Y3oOqp1f7\",\r\n \"optin-state\": {\r\n \"optin-status\": \"pending-validate\",\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\",\r\n \"account-identifier\": \"te****st@boku.com\",\r\n \"issuer-unique-user-id\": \"cc1c4f3\"\r\n },\r\n \"optin-type\": \"hosted\",\r\n \"hosted\": {\r\n \"optin-url\": \"https://www.issuer.com/optin/2032405\"\r\n },\r\n \"payment-method\": \"superwallet\"\r\n}", @response_catcher.response.raw_body)
63
+ end
64
+
65
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
66
+ #
67
+ #The main purpose of an opt-in is to identify and verify the payment method that the end-user wants to register. In the process, the user confirms that they have control over the corresponding payment method. Once an opt-in has begun via an `optin` API call, the `validate-optin` call is used to complete this verification and in most cases retrieve the end-user details such as the account identifier of the user.
68
+ #
69
+ #Specifically for each opt-in type:
70
+ #
71
+ #* **otp**: Submit the OTP, and if correct receive confirmation that the user owns the MSISDN and handset.
72
+ #**Note**: default configuration on Boku-mananged PIN for the number of OTP verification attempts is 3 and the default PIN expiration is 300 seconds.
73
+ #* **carrier-gw**: Confirm receipt of the carrier-gw URL call on Boku's servers, and retrieve the MSISDN via a secure channel if the carrier-gw URL call itself is not sufficiently secured. Potentially block on an asynchronous user identification callback from the carrier.
74
+ #* **silent-mo**: Block upon receipt of the silent MO SMS if not yet received, and once complete retrieve the received MSISDN details.
75
+ #* **hosted**: Confirm successful authentication via opt-in UI, and retrieve the account identifier of the user.
76
+ #
77
+ #After a successful `validate-optin` call, an opt-in should usually be in status `pending-confirm` awaiting a call to `confirm-optin`. In the case of a OTP opt-in, if the PIN expires, a new opt-in will need to be initiated with a new 'optin' request.
78
+ def test_validate_optin
79
+ # Parameters for the API call
80
+ body = ValidateOptinRequest.from_hash(APIHelper.json_deserialize(
81
+ '{"merchant-id":"gatewaymerchant","merchant-request-id":"2032405","optin'\
82
+ '-id":"IVXecDoa2f6Y3oOqp1f7","optin-type":"hosted","otp":"1234"}', false))
83
+
84
+ # Perform the API call through the SDK function
85
+ result = @controller.validate_optin(body)
86
+
87
+ # Test response code
88
+ assert_equal(200, @response_catcher.response.status_code)
89
+ # Test headers
90
+ expected_headers = {}
91
+ expected_headers['content-type'] = 'application/xml'
92
+
93
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
94
+
95
+ # Test whether the captured response is as we expected
96
+ refute_nil(result)
97
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"2032405\",\r\n \"optin-id\": \"IVXecDoa2f6Y3oOqp1f7\",\r\n \"optin-state\": {\r\n \"optin-status\": \"pending-confirm\",\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\",\r\n \"account-identifier\": \"te****st@boku.com\",\r\n \"issuer-unique-user-id\": \"cc1c4f3\"\r\n },\r\n \"optin-type\": \"hosted\",\r\n \"payment-method\": \"superwallet\"\r\n}", @response_catcher.response.raw_body)
98
+ end
99
+
100
+ # Assuming an opt-in is in state `pending-confirm` (i.e. all necessary information about the end-user has already been collected), this call confirms that the opt-in should be activated for billing (after a successful call, optin-status should be `active`).
101
+ #
102
+ #**Note**
103
+ #
104
+ #* In some cases, such as a carrier-gw opt-in where sufficient information was returned in the carrier-gw URL call response, `confirm-optin` may be called directly without first calling `validate-optin`.
105
+ #* If `include-account-profile` is already set to true during `validate-optin`, Boku recommends that merchant sets the `include-account-profile` to false during `confirm-optin` to optimize the optin flow time as account-profile requires an external call to the carrier.
106
+ def test_confirm_optin
107
+ # Parameters for the API call
108
+ body = ConfirmOptinRequest.from_hash(APIHelper.json_deserialize(
109
+ '{"merchant-id":"gatewaymerchant","merchant-request-id":"1002004","optin'\
110
+ '-id":"IVXecDoa2f6Y3oOqp1f7"}', false))
111
+
112
+ # Perform the API call through the SDK function
113
+ result = @controller.confirm_optin(body)
114
+
115
+ # Test response code
116
+ assert_equal(200, @response_catcher.response.status_code)
117
+ # Test headers
118
+ expected_headers = {}
119
+ expected_headers['content-type'] = 'application/xml'
120
+
121
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
122
+
123
+ # Test whether the captured response is as we expected
124
+ refute_nil(result)
125
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"timestamp\": \"2015-02-40 04:44:16\",\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"1002004\",\r\n \"optin-request-id\": \"1002001\",\r\n \"optin-id\": \"IVXecDoa2f6Y3oOqp1f7\",\r\n \"optin-state\": {\r\n \"optin-status\": \"active\",\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\",\r\n \"account-identifier\": \"te****st@boku.com\",\r\n \"issuer-unique-user-id\": \"cc1c4f3\"\r\n },\r\n \"optin-type\": \"hosted\",\r\n \"payment-method\": \"superwallet\"\r\n}", @response_catcher.response.raw_body)
126
+ end
127
+
128
+ # The purpose of the ‘cancel-optin’ API is for deactivating the consumer’s opt-in stored by Boku and the issuer.
129
+ #
130
+ #A merchant can use this method in the following possible scenarios:
131
+ #
132
+ #* User contacts the merchant requesting to remove their payment method
133
+ #* Merchant determines that the consumer’s billing account has encountered a permanent error that should not be retried in the future
134
+ #
135
+ #A cancel-optin request **must** be sent when a user removes the payment method from the merchant account. Various payment methods enforce a 1:1 mapping, that is, a single payment method account can only be associated to a single merchant account. In the case that the merchant does not call cancel-optin, a user would be unable to associate their payment method account with any other merchant account, even though the user has already requested to remove the payment method from the merchant account.
136
+ #
137
+ #The 'optin-id' received from the 'optin' request at the time the consumer added their payment method must be supplied in the 'cancel-optin' request.
138
+ def test_cancel_optin
139
+ # Parameters for the API call
140
+ body = CancelOptinRequest.from_hash(APIHelper.json_deserialize(
141
+ '{"merchant-id":"gatewaymerchant","merchant-request-id":"1002006","optin'\
142
+ '-id":"IVXecDoa2f6Y3oOqp1f7"}', false))
143
+
144
+ # Perform the API call through the SDK function
145
+ result = @controller.cancel_optin(body)
146
+
147
+ # Test response code
148
+ assert_equal(200, @response_catcher.response.status_code)
149
+ # Test headers
150
+ expected_headers = {}
151
+ expected_headers['content-type'] = 'application/xml'
152
+
153
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
154
+
155
+ # Test whether the captured response is as we expected
156
+ refute_nil(result)
157
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"1002006\",\r\n \"optin-id\": \"IVXecDoa2f6Y3oOqp1f7\",\r\n \"optin-state\": {\r\n \"optin-status\": \"closed\",\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\"\r\n },\r\n \"optin-type\": \"hosted\"\r\n}", @response_catcher.response.raw_body)
158
+ end
159
+
160
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
161
+ #
162
+ #Check the carrier billing eligibility of a previously authenticated consumer. The request requires an optin-id. The eligibility check consists of checking the account status of the consumer as well as the billing eligibility.
163
+ def test_check_eligibility
164
+ # Parameters for the API call
165
+ body = CheckEligibilityRequest.from_hash(APIHelper.json_deserialize(
166
+ '{"country":"GB","merchant-id":"gatewaymerchant","optin-id":"CDrOpAAAB8F'\
167
+ 'VUwAAAAAAAA"}', false))
168
+
169
+ # Perform the API call through the SDK function
170
+ result = @controller.check_eligibility(body)
171
+
172
+ # Test response code
173
+ assert_equal(200, @response_catcher.response.status_code)
174
+ # Test headers
175
+ expected_headers = {}
176
+ expected_headers['content-type'] = 'application/xml'
177
+
178
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
179
+
180
+ # Test whether the captured response is as we expected
181
+ refute_nil(result)
182
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"successful\",\r\n \"retriable\": true,\r\n \"status\": \"OK\"\r\n },\r\n \"eligibility-status\": \"eligible\",\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"optin-id\": \"CDrOpAAAB8FVUwAAAAAAAA\"\r\n}", @response_catcher.response.raw_body)
183
+ end
184
+
185
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
186
+ #
187
+ #Sends a PIN code via SMS to device associated with consumer's active opt-in to verify the consumer still controls the device.
188
+ #
189
+ #For OTP validity semantics, see the 'optin' API method.
190
+ #
191
+ #For resend functionality see the 'resend-otp' API method.
192
+ def test_verify_device
193
+ # Parameters for the API call
194
+ body = VerifyDeviceRequest.from_hash(APIHelper.json_deserialize(
195
+ '{"country":"GB","merchant-id":"gatewaymerchant","merchant-request-id":"'\
196
+ '1426034257650","optin-id":"CDrOpAAAB8FVUwAAAAAAAA"}', false))
197
+
198
+ # Perform the API call through the SDK function
199
+ result = @controller.verify_device(body: body)
200
+
201
+ # Test response code
202
+ assert_equal(200, @response_catcher.response.status_code)
203
+ # Test headers
204
+ expected_headers = {}
205
+ expected_headers['content-type'] = 'application/xml'
206
+
207
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
208
+
209
+ # Test whether the captured response is as we expected
210
+ refute_nil(result)
211
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"1426034257650\",\r\n \"optin-id\": \"CDrOpAAAB8FVUwAAAAAAAA\",\r\n \"verify-session-id\": 593013513312536513\r\n}", @response_catcher.response.raw_body)
212
+ end
213
+
214
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
215
+ #
216
+ #The purpose of the ‘msisdn-network’ API is to identify the mobile operator network for a provided msisdn. If the mobile operator network is successfully determined, a Boku network identifier is returned.
217
+ def test_get_msisdn_network
218
+ # Parameters for the API call
219
+ body = MsisdnNetworkRequest.from_hash(APIHelper.json_deserialize(
220
+ '{"merchant-id":"gatewaymerchant","country":"GB","msisdn":"12064591122"}', false))
221
+
222
+ # Perform the API call through the SDK function
223
+ result = @controller.get_msisdn_network(body)
224
+
225
+ # Test response code
226
+ assert_equal(200, @response_catcher.response.status_code)
227
+ # Test headers
228
+ expected_headers = {}
229
+ expected_headers['content-type'] = 'application/xml'
230
+
231
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
232
+
233
+ # Test whether the captured response is as we expected
234
+ refute_nil(result)
235
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"country\": \"GB\",\r\n \"msisdn\": \"12064591122\",\r\n \"network-id\": \"13f050\"\r\n}", @response_catcher.response.raw_body)
236
+ end
237
+
238
+ # When a user has started an opt-in using the `otpin` method or a re-verification session using `verify-device` method, they may subsequently request the OTP to be re-sent. This may be required if network related issues prevented the successful delivery of the OTP message to the user. Currently 'resend-otp' is limited to three calls per unique opt-in. The PIN expiration is not reset when this method is called.
239
+ def test_resend_otp
240
+ # Parameters for the API call
241
+ body = ResendOtpRequest.from_hash(APIHelper.json_deserialize(
242
+ '{"country":"GB","merchant-id":"my-merchant","merchant-request-id":"1002'\
243
+ '006","optin-id":"436278","optin-request-id":"jhkl5438kk4","verify-sessi'\
244
+ 'on-id":5437890456}', false))
245
+
246
+ # Perform the API call through the SDK function
247
+ result = @controller.resend_otp(body: body)
248
+
249
+ # Test response code
250
+ assert_equal(200, @response_catcher.response.status_code)
251
+ # Test headers
252
+ expected_headers = {}
253
+ expected_headers['content-type'] = 'application/xml'
254
+
255
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
256
+
257
+ # Test whether the captured response is as we expected
258
+ refute_nil(result)
259
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"merchant-id\": \"my-merchant\",\r\n \"merchant-request-id\": \"ktl54fd96534\",\r\n \"optin-id\": \"543798789\"\r\n}", @response_catcher.response.raw_body)
260
+ end
261
+
262
+ end
@@ -0,0 +1,40 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class ForexControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.forex
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
17
+ #
18
+ #The 'forex' request retrieves the latest foreign exchange rate for a given source and destination currency. Boku's foreign exchange rates are daily average mid-point rates and are updated every 24 hours.
19
+ def test_forex
20
+ # Parameters for the API call
21
+ body = ForexRequest.from_hash(APIHelper.json_deserialize(
22
+ '{"merchant-id":"gatewaymerchant","from":"EUR","to":"GBP"}', false))
23
+
24
+ # Perform the API call through the SDK function
25
+ result = @controller.forex(body)
26
+
27
+ # Test response code
28
+ assert_equal(200, @response_catcher.response.status_code)
29
+ # Test headers
30
+ expected_headers = {}
31
+ expected_headers['content-type'] = 'application/xml'
32
+
33
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
34
+
35
+ # Test whether the captured response is as we expected
36
+ refute_nil(result)
37
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"from\": \"EUR\",\r\n \"to\": \"GBP\",\r\n \"exchange-rate\": 0.853731,\r\n \"merchant-id\": \"gatewaymerchant\"\r\n}", @response_catcher.response.raw_body)
38
+ end
39
+
40
+ end
@@ -0,0 +1,41 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class FundCheckControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.fund_check
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
17
+ #
18
+ #The 'fund-check' request schedules a balance check for a given optin for the amount send in request. If there is not enough balance, sms is send for further user action to top-up balance. Sms will only be send once every seven days for any number of fund-check request.
19
+ def test_schedule_fund_check
20
+ # Parameters for the API call
21
+ body = FundCheckRequest.from_hash(APIHelper.json_deserialize(
22
+ '{"merchant-id":"payment-gatewaytest","optin-id":"IVXecDoa2f6Y3oOqp1f7",'\
23
+ '"amount":12.34,"currency":"GBP"}', false))
24
+
25
+ # Perform the API call through the SDK function
26
+ result = @controller.schedule_fund_check(body)
27
+
28
+ # Test response code
29
+ assert_equal(200, @response_catcher.response.status_code)
30
+ # Test headers
31
+ expected_headers = {}
32
+ expected_headers['content-type'] = 'application/xml'
33
+
34
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
35
+
36
+ # Test whether the captured response is as we expected
37
+ refute_nil(result)
38
+ assert_equal("{\r\n \"merchant-id\": \"payment-gateway-test\",\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n }\r\n}", @response_catcher.response.raw_body)
39
+ end
40
+
41
+ end
@@ -0,0 +1,76 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class RefundControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.refund
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Refunds a confirmed payment from the consumer. The refund request must include the ID of the original charge and a valid reason code that matches one of Boku’s supported [refund codes](page:refund-reason-codes). By default, the full amount of the referenced charge is refunded.
17
+ #
18
+ #If the issuer supports partial refunds, merchants can specify a refund amount less than the full charge. Partial refunds may be issued multiple times until the full amount of the original charge has been refunded.
19
+ #
20
+ def test_refund_charge
21
+ # Parameters for the API call
22
+ body = RefundChargeRequest.from_hash(APIHelper.json_deserialize(
23
+ '{"charge-id":"b368363a00bbddbf794eba33","merchant-id":"gatewaymerchant"'\
24
+ ',"merchant-request-id":"1002009","merchant-refund-id":"1002005","reason'\
25
+ '-code":20,"skip-retry":true,"notification":{"send":true,"url":"https://'\
26
+ 'www.boku.com/notify"}}', false))
27
+ host = nil
28
+
29
+ # Perform the API call through the SDK function
30
+ result = @controller.refund_charge(body, host: host)
31
+
32
+ # Test response code
33
+ assert_equal(200, @response_catcher.response.status_code)
34
+ # Test headers
35
+ expected_headers = {}
36
+ expected_headers['content-type'] = 'application/xml'
37
+
38
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
39
+
40
+ # Test whether the captured response is as we expected
41
+ refute_nil(result)
42
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"timestamp\": \"2015-02-40 04:44:16\",\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-request-id\": \"1002009\",\r\n \"charge-id\": \"b368363a00bbddbf794eba33\",\r\n \"refund-id\": \"XVIbtRtytRtbIVX\",\r\n \"refund-status\": \"success\",\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\"\r\n}", @response_catcher.response.raw_body)
43
+ end
44
+
45
+ # Retrieves the status and all details of prior refunds matching the given request criteria.
46
+ #
47
+ #Each returned refund element is similar to a refund-charge-response: although some elements are missing, all present elements have the same names, format, and meaning as those in the original refund-charge-response.
48
+ #
49
+ #The query-refund API call is guaranteed to return transactions up to 1 year old. If the transaction was created before that period, this API may return no results.
50
+ #
51
+ #Criteria are evaluated in an AND fashion, i.e. if more than one field is supplied then all will be used to filter the returned refund elements. In normal usage, this is not relevant, since you would only supply one of the three fields by itself.
52
+ #
53
+ #The query-refund request one of the following values to be exclusively provided: refund-id or merchant-request-id.
54
+ def test_query_refund
55
+ # Parameters for the API call
56
+ body = QueryRefundRequest.from_hash(APIHelper.json_deserialize(
57
+ '{"country":"GB","merchant-id":"gatewaymerchant","refund-id":"8756616345'\
58
+ '70289152"}', false))
59
+
60
+ # Perform the API call through the SDK function
61
+ result = @controller.query_refund(body)
62
+
63
+ # Test response code
64
+ assert_equal(200, @response_catcher.response.status_code)
65
+ # Test headers
66
+ expected_headers = {}
67
+ expected_headers['content-type'] = 'application/xml'
68
+
69
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
70
+
71
+ # Test whether the captured response is as we expected
72
+ refute_nil(result)
73
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"refunds\": [\r\n {\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"refund-status\": \"success\",\r\n \"refund-id\": \"875661634570289152\",\r\n \"timestamp\": \"2019-06-18 10:34:22\",\r\n \"merchant-id\": \"gatewaymerchant\",\r\n \"merchant-refund-id\": \"refund-5iwtn6ehbjjskyutzmembn2m\",\r\n \"charge-id\": \"5iwtn6ehbjjskyutzmembn2m\",\r\n \"reason-code\": 20,\r\n \"country\": \"GB\",\r\n \"network-id\": \"gb-super\",\r\n \"currency\": \"GBP\",\r\n \"refund-amount\": 12.34,\r\n \"type\": \"refund\",\r\n \"merchant-transaction-id\": \"9002005\"\r\n }\r\n ]\r\n}", @response_catcher.response.raw_body)
74
+ end
75
+
76
+ end
@@ -0,0 +1,72 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class SellerOfRecordControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.seller_of_record
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
17
+ #
18
+ #The register-payment-method call notifies Boku to initiate the onboarding of a payment method. Once the payment method is "approved", the seller of record can accept payments using the requested payment method.
19
+ def test_register_payment_method
20
+ # Parameters for the API call
21
+ body = RegisterPaymentMethodRequest.from_hash(APIHelper.json_deserialize(
22
+ '{"country":"GB","merchant-id":"merchantOfRecord","merchant-request-id":'\
23
+ '"1002001","seller-of-record":{"id":"5kt87k0virro71w3ex78j105"},"payment'\
24
+ '-method":"kakaopay"}', false))
25
+
26
+ # Perform the API call through the SDK function
27
+ result = @controller.register_payment_method(body)
28
+
29
+ # Test response code
30
+ assert_equal(200, @response_catcher.response.status_code)
31
+ # Test headers
32
+ expected_headers = {}
33
+ expected_headers['content-type'] = 'application/xml'
34
+
35
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
36
+
37
+ # Test whether the captured response is as we expected
38
+ refute_nil(result)
39
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"country\": \"GB\",\r\n \"merchant-id\": \"merchantOfRecord\",\r\n \"merchant-request-id\": \"1002001\",\r\n \"seller-of-record-id\": \"5kt87k0virro71w3ex78j105\",\r\n \"payment-method\": \"kakaopay\",\r\n \"payment-method-status\": \"pending\"\r\n}", @response_catcher.response.raw_body)
40
+ end
41
+
42
+ # **DISCLAIMER: This API or element is use-case specific and not needed for generic usage of our payment product. Please disregard unless otherwise directed to include in your integration.**
43
+ #
44
+ #The 'register-seller-of-record' API collects required information for the seller of record to be onboarded on the Boku platform. Information provided here may be used to enable the seller of record with various payment methods. This API call returns a response with a seller-of-record-id, which will be used in subsequent API calls.
45
+ def test_register_seller_of_record
46
+ # Parameters for the API call
47
+ body = RegisterSellerOfRecordRequest.from_hash(APIHelper.json_deserialize(
48
+ '{"country":"GB","merchant-id":"merchantOfRecord","merchant-request-id":'\
49
+ '"1002001","business-details":{"business-legal-name":"Tickets Inc.","doi'\
50
+ 'ng-business-as":"tickets.com","business-contact-person":"Bob Smith","bu'\
51
+ 'siness-contact-number":"14155551234","business-address":"735 Battery St'\
52
+ ', San Francisco, CA 94111","business-registration-number":"345345","mer'\
53
+ 'chant-category-code":"7929","business-url":"https://www.tickets.com","b'\
54
+ 'usiness-category":"Tickets"}}', false))
55
+
56
+ # Perform the API call through the SDK function
57
+ result = @controller.register_seller_of_record(body)
58
+
59
+ # Test response code
60
+ assert_equal(200, @response_catcher.response.status_code)
61
+ # Test headers
62
+ expected_headers = {}
63
+ expected_headers['content-type'] = 'application/xml'
64
+
65
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
66
+
67
+ # Test whether the captured response is as we expected
68
+ refute_nil(result)
69
+ assert_equal("{\r\n \"result\": {\r\n \"reason-code\": 0,\r\n \"message\": \"Operation Successful\",\r\n \"retriable\": false,\r\n \"status\": \"OK\"\r\n },\r\n \"country\": \"GB\",\r\n \"merchant-id\": \"merchantOfRecord\",\r\n \"merchant-request-id\": \"1002001\",\r\n \"seller-of-record-id\": \"5kt87k0virro71w3ex78j105\",\r\n \"seller-of-record-status\": \"approved\"\r\n}", @response_catcher.response.raw_body)
70
+ end
71
+
72
+ end
@@ -0,0 +1,19 @@
1
+ # boku_direct_payments_api
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ class HttpResponseCatcher < BokuDirectPaymentsApi::HttpCallBack
7
+ attr_reader :response
8
+
9
+ def on_before_request(request)
10
+ end
11
+
12
+ # Catching the response
13
+ def on_after_response(response)
14
+ @response = response
15
+ end
16
+ end
17
+
18
+
19
+