|
13 | 13 |
|
14 | 14 | -export([payment_start_idempotency/1]). |
15 | 15 | -export([payment_success/1]). |
| 16 | +-export([payment_w_first_blacklisted_success/1]). |
| 17 | +-export([payment_w_all_blacklisted/1]). |
16 | 18 | -export([register_payment_success/1]). |
17 | 19 | -export([register_payment_customer_payer_success/1]). |
18 | 20 | -export([payment_success_additional_info/1]). |
@@ -51,6 +53,8 @@ groups() -> |
51 | 53 | {payments, [parallel], [ |
52 | 54 | payment_start_idempotency, |
53 | 55 | payment_success, |
| 56 | + payment_w_first_blacklisted_success, |
| 57 | + payment_w_all_blacklisted, |
54 | 58 | register_payment_success, |
55 | 59 | register_payment_customer_payer_success, |
56 | 60 | payment_success_additional_info, |
@@ -189,6 +193,54 @@ payment_success(C) -> |
189 | 193 | Trx |
190 | 194 | ). |
191 | 195 |
|
| 196 | +-spec payment_w_first_blacklisted_success(config()) -> test_return(). |
| 197 | +payment_w_first_blacklisted_success(C) -> |
| 198 | + Client = cfg(client, C), |
| 199 | + InvoiceID = start_invoice(<<"rubberduck">>, make_due_date(10), 42000, C), |
| 200 | + {PaymentTool, Session} = hg_dummy_provider:make_payment_tool(inspector_fail_first, ?pmt_sys(<<"visa-ref">>)), |
| 201 | + PaymentParams = make_payment_params(PaymentTool, Session, instant), |
| 202 | + PaymentID = process_payment(InvoiceID, PaymentParams, Client), |
| 203 | + PaymentID = await_payment_capture(InvoiceID, PaymentID, Client), |
| 204 | + ?invoice_state( |
| 205 | + ?invoice_w_status(?invoice_paid()), |
| 206 | + [_PaymentSt] |
| 207 | + ) = hg_client_invoicing:get(InvoiceID, Client), |
| 208 | + _Explanation = |
| 209 | + #payproc_InvoicePaymentExplanation{ |
| 210 | + explained_routes = [ |
| 211 | + #payproc_InvoicePaymentRouteExplanation{ |
| 212 | + route = ?route(?prv(1), ?trm(2)), |
| 213 | + is_chosen = true |
| 214 | + }, |
| 215 | + #payproc_InvoicePaymentRouteExplanation{ |
| 216 | + route = ?route(?prv(1), ?trm(1)), |
| 217 | + is_chosen = false, |
| 218 | + rejection_description = Desc |
| 219 | + } |
| 220 | + ] |
| 221 | + } = hg_client_invoicing:explain_route(InvoiceID, PaymentID, Client), |
| 222 | + ?assertEqual( |
| 223 | + <<"Route was blacklisted {domain_PaymentRoute,{domain_ProviderRef,1},{domain_TerminalRef,1}}.">>, Desc |
| 224 | + ). |
| 225 | + |
| 226 | +-spec payment_w_all_blacklisted(config()) -> test_return(). |
| 227 | +payment_w_all_blacklisted(C) -> |
| 228 | + Client = cfg(client, C), |
| 229 | + InvoiceID = start_invoice(<<"rubberduck">>, make_due_date(10), 42000, C), |
| 230 | + {PaymentTool, Session} = hg_dummy_provider:make_payment_tool(inspector_fail_all, ?pmt_sys(<<"visa-ref">>)), |
| 231 | + PaymentParams = make_payment_params(PaymentTool, Session, instant), |
| 232 | + ?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client), |
| 233 | + [ |
| 234 | + ?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))), |
| 235 | + ?payment_ev(PaymentID, ?risk_score_changed(_RiskScore)), |
| 236 | + ?payment_ev(PaymentID, ?route_changed(_Route)), |
| 237 | + ?payment_ev(PaymentID, ?payment_rollback_started({failure, _Failure})) |
| 238 | + ] = next_changes(InvoiceID, 4, Client), |
| 239 | + ?invoice_state( |
| 240 | + ?invoice_w_status(?invoice_unpaid()), |
| 241 | + [_PaymentSt] |
| 242 | + ) = hg_client_invoicing:get(InvoiceID, Client). |
| 243 | + |
192 | 244 | -spec register_payment_success(config()) -> test_return(). |
193 | 245 | register_payment_success(C) -> |
194 | 246 | Client = cfg(client, C), |
@@ -580,7 +632,7 @@ construct_domain_fixture() -> |
580 | 632 | allocations = #domain_PaymentAllocationServiceTerms{ |
581 | 633 | allow = {constant, true} |
582 | 634 | }, |
583 | | - attempt_limit = {value, #domain_AttemptLimit{attempts = 2}} |
| 635 | + attempt_limit = {value, #domain_AttemptLimit{attempts = 1}} |
584 | 636 | }, |
585 | 637 | recurrent_paytools = #domain_RecurrentPaytoolsServiceTerms{ |
586 | 638 | payment_methods = |
@@ -623,7 +675,8 @@ construct_domain_fixture() -> |
623 | 675 | ?ruleset(1), |
624 | 676 | <<"Policies">>, |
625 | 677 | {candidates, [ |
626 | | - ?candidate({constant, true}, ?trm(1)) |
| 678 | + ?candidate({constant, true}, ?trm(1)), |
| 679 | + ?candidate({constant, true}, ?trm(2)) |
627 | 680 | ]} |
628 | 681 | ), |
629 | 682 | hg_ct_fixture:construct_payment_routing_ruleset( |
@@ -809,6 +862,14 @@ construct_domain_fixture() -> |
809 | 862 | provider_ref = ?prv(1) |
810 | 863 | } |
811 | 864 | }}, |
| 865 | + {terminal, #domain_TerminalObject{ |
| 866 | + ref = ?trm(2), |
| 867 | + data = #domain_Terminal{ |
| 868 | + name = <<"Brominal 2">>, |
| 869 | + description = <<"Brominal 2">>, |
| 870 | + provider_ref = ?prv(1) |
| 871 | + } |
| 872 | + }}, |
812 | 873 |
|
813 | 874 | hg_ct_fixture:construct_mobile_operator(?mob(<<"mts-ref">>), <<"mts mobile operator">>), |
814 | 875 | hg_ct_fixture:construct_payment_service(?pmt_srv(<<"qiwi-ref">>), <<"qiwi payment service">>), |
|
0 commit comments