defra_ruby_mocks 2.3.2 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -75
  3. data/app/controllers/defra_ruby_mocks/govpay_controller.rb +28 -3
  4. data/app/jobs/defra_ruby_mocks/application_job.rb +6 -0
  5. data/app/jobs/defra_ruby_mocks/govpay_payment_callback_job.rb +17 -0
  6. data/app/services/defra_ruby_mocks/govpay_create_payment_service.rb +41 -13
  7. data/app/services/defra_ruby_mocks/govpay_get_payment_service.rb +74 -16
  8. data/app/services/defra_ruby_mocks/govpay_refund_details_service.rb +43 -0
  9. data/app/services/defra_ruby_mocks/govpay_request_refund_service.rb +27 -0
  10. data/config/routes.rb +10 -10
  11. data/lib/defra_ruby_mocks/configuration.rb +1 -1
  12. data/lib/defra_ruby_mocks/engine.rb +0 -1
  13. data/lib/defra_ruby_mocks/version.rb +1 -1
  14. data/spec/dummy/log/test.log +1279 -972
  15. data/spec/examples.txt +68 -121
  16. data/spec/fixtures/files/govpay/create_payment_created_response.json +24 -0
  17. data/spec/fixtures/files/govpay/create_payment_error_response.json +5 -0
  18. data/spec/fixtures/files/govpay/get_payment_response_cancelled.json +61 -0
  19. data/spec/fixtures/files/govpay/get_payment_response_created.json +73 -0
  20. data/spec/fixtures/files/govpay/get_payment_response_error.json +5 -0
  21. data/spec/fixtures/files/govpay/get_payment_response_failure.json +9 -0
  22. data/spec/fixtures/files/govpay/get_payment_response_not_found.json +4 -0
  23. data/spec/fixtures/files/govpay/get_payment_response_submitted.json +75 -0
  24. data/spec/fixtures/files/govpay/get_payment_response_success.json +62 -0
  25. data/spec/requests/govpay_spec.rb +64 -1
  26. data/spec/services/govpay_create_payment_service_spec.rb +44 -0
  27. data/spec/services/govpay_get_payment_service_spec.rb +30 -0
  28. data/spec/services/govpay_refund_details_service_spec.rb +58 -0
  29. data/spec/services/govpay_request_refund_service_spec.rb +31 -0
  30. metadata +32 -48
  31. data/app/controllers/defra_ruby_mocks/worldpay_controller.rb +0 -57
  32. data/app/services/defra_ruby_mocks/worldpay_payment_service.rb +0 -47
  33. data/app/services/defra_ruby_mocks/worldpay_refund_service.rb +0 -37
  34. data/app/services/defra_ruby_mocks/worldpay_request_handler_service.rb +0 -40
  35. data/app/services/defra_ruby_mocks/worldpay_resource_service.rb +0 -55
  36. data/app/services/defra_ruby_mocks/worldpay_response_service.rb +0 -119
  37. data/app/views/defra_ruby_mocks/worldpay/payment_request.xml.erb +0 -4
  38. data/app/views/defra_ruby_mocks/worldpay/refund_request.xml.erb +0 -4
  39. data/app/views/defra_ruby_mocks/worldpay/stuck.html.erb +0 -37
  40. data/lib/defra_ruby_mocks/unrecognised_worldpay_request_error.rb +0 -5
  41. data/spec/fixtures/payment_request_invalid.xml +0 -6
  42. data/spec/fixtures/payment_request_valid.xml +0 -30
  43. data/spec/fixtures/refund_request_invalid.xml +0 -6
  44. data/spec/fixtures/refund_request_valid.xml +0 -11
  45. data/spec/fixtures/unrecognised_request.xml +0 -6
  46. data/spec/requests/worldpay_spec.rb +0 -163
  47. data/spec/services/worldpay_payment_service_spec.rb +0 -95
  48. data/spec/services/worldpay_refund_service_spec.rb +0 -68
  49. data/spec/services/worldpay_request_handler_service_spec.rb +0 -79
  50. data/spec/services/worldpay_resource_service_spec.rb +0 -120
  51. data/spec/services/worldpay_response_service_spec.rb +0 -280
data/spec/examples.txt CHANGED
@@ -1,121 +1,68 @@
1
- example_id | status | run_time |
2
- ------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/defra_ruby_mocks_spec.rb[1:1:1] | passed | 0.00217 seconds |
4
- ./spec/defra_ruby_mocks_spec.rb[1:2:1:1] | passed | 0.00014 seconds |
5
- ./spec/defra_ruby_mocks_spec.rb[1:2:2:1] | passed | 0.00011 seconds |
6
- ./spec/lib/configuration_spec.rb[1:1:1:1] | passed | 0.00008 seconds |
7
- ./spec/lib/configuration_spec.rb[1:1:2:1] | passed | 0.00009 seconds |
8
- ./spec/lib/configuration_spec.rb[1:1:3:1] | passed | 0.0009 seconds |
9
- ./spec/lib/configuration_spec.rb[1:1:4:1] | passed | 0.00008 seconds |
10
- ./spec/lib/configuration_spec.rb[1:2:1:1] | passed | 0.00008 seconds |
11
- ./spec/lib/configuration_spec.rb[1:2:2:1] | passed | 0.00008 seconds |
12
- ./spec/lib/configuration_spec.rb[1:2:3:1] | passed | 0.0001 seconds |
13
- ./spec/lib/configuration_spec.rb[1:2:4:1] | passed | 0.00008 seconds |
14
- ./spec/requests/company_spec.rb[1:1:1:1] | passed | 0.00845 seconds |
15
- ./spec/requests/company_spec.rb[1:1:2:1] | passed | 0.00352 seconds |
16
- ./spec/requests/company_spec.rb[1:1:3:1:1] | passed | 0.00231 seconds |
17
- ./spec/requests/company_spec.rb[1:1:3:2:1] | passed | 0.00258 seconds |
18
- ./spec/requests/company_spec.rb[1:2:1] | passed | 0.00106 seconds |
19
- ./spec/requests/govpay_spec.rb[1:1:1:1:1] | passed | 0.00344 seconds |
20
- ./spec/requests/govpay_spec.rb[1:1:1:2:1] | passed | 0.00259 seconds |
21
- ./spec/requests/govpay_spec.rb[1:1:2:1:1] | passed | 0.00309 seconds |
22
- ./spec/requests/govpay_spec.rb[1:1:2:2:1] | passed | 0.00426 seconds |
23
- ./spec/requests/govpay_spec.rb[1:2:1:1] | passed | 0.00093 seconds |
24
- ./spec/requests/govpay_spec.rb[1:2:2:1] | passed | 0.00425 seconds |
25
- ./spec/requests/govpay_spec.rb[1:2:3:1] | passed | 0.00353 seconds |
26
- ./spec/requests/officers_spec.rb[1:1:1] | passed | 0.0031 seconds |
27
- ./spec/requests/officers_spec.rb[1:2:1] | passed | 0.00114 seconds |
28
- ./spec/requests/worldpay_spec.rb[1:1:1:1:1:1] | passed | 0.00355 seconds |
29
- ./spec/requests/worldpay_spec.rb[1:1:1:1:2:1] | passed | 0.0026 seconds |
30
- ./spec/requests/worldpay_spec.rb[1:1:1:2:1:1] | passed | 0.04013 seconds |
31
- ./spec/requests/worldpay_spec.rb[1:1:2:1:1:1] | passed | 0.00372 seconds |
32
- ./spec/requests/worldpay_spec.rb[1:1:2:1:2:1] | passed | 0.00412 seconds |
33
- ./spec/requests/worldpay_spec.rb[1:1:2:2:1:1] | passed | 0.00572 seconds |
34
- ./spec/requests/worldpay_spec.rb[1:2:1:1] | passed | 0.00114 seconds |
35
- ./spec/requests/worldpay_spec.rb[1:2:2:1] | passed | 0.00129 seconds |
36
- ./spec/services/companies_house_service_spec.rb[1:1:1:1] | passed | 0.00011 seconds |
37
- ./spec/services/companies_house_service_spec.rb[1:1:2:1:1] | passed | 0.00008 seconds |
38
- ./spec/services/companies_house_service_spec.rb[1:1:2:1:2] | passed | 0.00009 seconds |
39
- ./spec/services/companies_house_service_spec.rb[1:1:2:2:1] | passed | 0.00008 seconds |
40
- ./spec/services/companies_house_service_spec.rb[1:1:2:2:2] | passed | 0.00014 seconds |
41
- ./spec/services/companies_house_service_spec.rb[1:1:2:3:1] | passed | 0.00008 seconds |
42
- ./spec/services/companies_house_service_spec.rb[1:1:2:3:2] | passed | 0.00008 seconds |
43
- ./spec/services/companies_house_service_spec.rb[1:1:2:4:1] | passed | 0.00009 seconds |
44
- ./spec/services/companies_house_service_spec.rb[1:1:2:4:2] | passed | 0.00008 seconds |
45
- ./spec/services/companies_house_service_spec.rb[1:1:2:5:1] | passed | 0.00008 seconds |
46
- ./spec/services/companies_house_service_spec.rb[1:1:2:5:2] | passed | 0.00008 seconds |
47
- ./spec/services/companies_house_service_spec.rb[1:1:2:6:1] | passed | 0.00008 seconds |
48
- ./spec/services/companies_house_service_spec.rb[1:1:2:6:2] | passed | 0.00009 seconds |
49
- ./spec/services/companies_house_service_spec.rb[1:1:2:7:1] | passed | 0.00009 seconds |
50
- ./spec/services/companies_house_service_spec.rb[1:1:2:7:2] | passed | 0.00008 seconds |
51
- ./spec/services/companies_house_service_spec.rb[1:1:2:8:1] | passed | 0.00009 seconds |
52
- ./spec/services/companies_house_service_spec.rb[1:1:2:8:2] | passed | 0.00008 seconds |
53
- ./spec/services/companies_house_service_spec.rb[1:1:2:9:1] | passed | 0.00008 seconds |
54
- ./spec/services/companies_house_service_spec.rb[1:1:2:9:2] | passed | 0.00008 seconds |
55
- ./spec/services/companies_house_service_spec.rb[1:1:3:1] | passed | 0.00008 seconds |
56
- ./spec/services/companies_house_service_spec.rb[1:1:3:2] | passed | 0.0001 seconds |
57
- ./spec/services/companies_house_service_spec.rb[1:1:3:3] | passed | 0.00009 seconds |
58
- ./spec/services/companies_house_service_spec.rb[1:1:3:4] | passed | 0.00007 seconds |
59
- ./spec/services/companies_house_service_spec.rb[1:1:4:1:1] | passed | 0.0001 seconds |
60
- ./spec/services/companies_house_service_spec.rb[1:1:4:2:1] | passed | 0.00012 seconds |
61
- ./spec/services/worldpay_payment_service_spec.rb[1:1:1:1] | passed | 0.00011 seconds |
62
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:1] | passed | 0.0003 seconds |
63
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:2] | passed | 0.00033 seconds |
64
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:3] | passed | 0.00028 seconds |
65
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:4] | passed | 0.00033 seconds |
66
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:1] | passed | 0.00038 seconds |
67
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:2] | passed | 0.00035 seconds |
68
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:5:3] | passed | 0.00035 seconds |
69
- ./spec/services/worldpay_payment_service_spec.rb[1:1:2:1:6:1] | passed | 0.00033 seconds |
70
- ./spec/services/worldpay_payment_service_spec.rb[1:1:3:1] | passed | 0.00032 seconds |
71
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:1] | passed | 0.00121 seconds |
72
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:2] | passed | 0.0003 seconds |
73
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:3] | passed | 0.00126 seconds |
74
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:4] | passed | 0.00045 seconds |
75
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:5] | passed | 0.00039 seconds |
76
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:6] | passed | 0.00038 seconds |
77
- ./spec/services/worldpay_refund_service_spec.rb[1:1:1:1:7] | passed | 0.00031 seconds |
78
- ./spec/services/worldpay_refund_service_spec.rb[1:1:2:1] | passed | 0.11633 seconds |
79
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:1:1] | passed | 0.00098 seconds |
80
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:1:2] | passed | 0.00079 seconds |
81
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:2:1] | passed | 0.00057 seconds |
82
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:2:2] | passed | 0.00049 seconds |
83
- ./spec/services/worldpay_request_handler_service_spec.rb[1:1:1:3:1] | passed | 0.00051 seconds |
84
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:1] | passed | 0.00069 seconds |
85
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:2] | passed | 0.00065 seconds |
86
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:3] | passed | 0.00046 seconds |
87
- ./spec/services/worldpay_resource_service_spec.rb[1:1:1:4] | passed | 0.00047 seconds |
88
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:1] | passed | 0.00063 seconds |
89
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:2] | passed | 0.00055 seconds |
90
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:3] | passed | 0.00054 seconds |
91
- ./spec/services/worldpay_resource_service_spec.rb[1:1:2:4] | passed | 0.00051 seconds |
92
- ./spec/services/worldpay_resource_service_spec.rb[1:1:3:1] | passed | 0.00176 seconds |
93
- ./spec/services/worldpay_resource_service_spec.rb[1:1:4:1] | passed | 0.00921 seconds |
94
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:1] | passed | 0.00048 seconds |
95
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:2] | passed | 0.00064 seconds |
96
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:3:1] | passed | 0.00046 seconds |
97
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:3:2] | passed | 0.00047 seconds |
98
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:4:1] | passed | 0.00044 seconds |
99
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:4:2] | passed | 0.0005 seconds |
100
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:5:1] | passed | 0.00047 seconds |
101
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:5:2] | passed | 0.00041 seconds |
102
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:6:1] | passed | 0.00044 seconds |
103
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:6:2] | passed | 0.00047 seconds |
104
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:7:1] | passed | 0.00046 seconds |
105
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:7:2] | passed | 0.00047 seconds |
106
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:8:1] | passed | 0.00046 seconds |
107
- ./spec/services/worldpay_response_service_spec.rb[1:1:1:1:8:2] | passed | 0.00048 seconds |
108
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:1] | passed | 0.00048 seconds |
109
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:2] | passed | 0.00048 seconds |
110
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:3:1] | passed | 0.00047 seconds |
111
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:3:2] | passed | 0.00048 seconds |
112
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:4:1] | passed | 0.00047 seconds |
113
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:4:2] | passed | 0.00045 seconds |
114
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:5:1] | passed | 0.00048 seconds |
115
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:5:2] | passed | 0.00042 seconds |
116
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:6:1] | passed | 0.00045 seconds |
117
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:6:2] | passed | 0.00045 seconds |
118
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:7:1] | passed | 0.00044 seconds |
119
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:7:2] | passed | 0.00047 seconds |
120
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:8:1] | passed | 0.00049 seconds |
121
- ./spec/services/worldpay_response_service_spec.rb[1:1:2:1:8:2] | passed | 0.00048 seconds |
1
+ example_id | status | run_time |
2
+ ---------------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/defra_ruby_mocks_spec.rb[1:1:1] | passed | 0.00285 seconds |
4
+ ./spec/defra_ruby_mocks_spec.rb[1:2:1:1] | passed | 0.00139 seconds |
5
+ ./spec/defra_ruby_mocks_spec.rb[1:2:2:1] | passed | 0.00014 seconds |
6
+ ./spec/lib/configuration_spec.rb[1:1:1:1] | passed | 0.0001 seconds |
7
+ ./spec/lib/configuration_spec.rb[1:1:2:1] | passed | 0.00011 seconds |
8
+ ./spec/lib/configuration_spec.rb[1:1:3:1] | passed | 0.00542 seconds |
9
+ ./spec/lib/configuration_spec.rb[1:1:4:1] | passed | 0.0001 seconds |
10
+ ./spec/lib/configuration_spec.rb[1:2:1:1] | passed | 0.00013 seconds |
11
+ ./spec/lib/configuration_spec.rb[1:2:2:1] | passed | 0.0001 seconds |
12
+ ./spec/lib/configuration_spec.rb[1:2:3:1] | passed | 0.0001 seconds |
13
+ ./spec/lib/configuration_spec.rb[1:2:4:1] | passed | 0.0001 seconds |
14
+ ./spec/requests/company_spec.rb[1:1:1:1] | passed | 0.03183 seconds |
15
+ ./spec/requests/company_spec.rb[1:1:2:1] | passed | 0.00373 seconds |
16
+ ./spec/requests/company_spec.rb[1:1:3:1:1] | passed | 0.00642 seconds |
17
+ ./spec/requests/company_spec.rb[1:1:3:2:1] | passed | 0.00371 seconds |
18
+ ./spec/requests/company_spec.rb[1:2:1] | passed | 0.1818 seconds |
19
+ ./spec/requests/govpay_spec.rb[1:1:1:1:1] | passed | 0.00531 seconds |
20
+ ./spec/requests/govpay_spec.rb[1:1:1:1:2] | passed | 0.0086 seconds |
21
+ ./spec/requests/govpay_spec.rb[1:1:1:2:1] | passed | 0.00328 seconds |
22
+ ./spec/requests/govpay_spec.rb[1:1:2:1:1] | passed | 0.00809 seconds |
23
+ ./spec/requests/govpay_spec.rb[1:1:2:2:1] | passed | 0.00472 seconds |
24
+ ./spec/requests/govpay_spec.rb[1:1:3:1:1] | passed | 0.00308 seconds |
25
+ ./spec/requests/govpay_spec.rb[1:1:3:2:1] | passed | 0.00362 seconds |
26
+ ./spec/requests/govpay_spec.rb[1:1:4:1:1] | passed | 0.00454 seconds |
27
+ ./spec/requests/govpay_spec.rb[1:2:1:1] | passed | 0.00158 seconds |
28
+ ./spec/requests/govpay_spec.rb[1:2:2:1] | passed | 0.00622 seconds |
29
+ ./spec/requests/govpay_spec.rb[1:2:3:1] | passed | 0.01293 seconds |
30
+ ./spec/requests/officers_spec.rb[1:1:1] | passed | 0.00639 seconds |
31
+ ./spec/requests/officers_spec.rb[1:2:1] | passed | 0.00178 seconds |
32
+ ./spec/services/companies_house_service_spec.rb[1:1:1:1] | passed | 0.00012 seconds |
33
+ ./spec/services/companies_house_service_spec.rb[1:1:2:1:1] | passed | 0.0001 seconds |
34
+ ./spec/services/companies_house_service_spec.rb[1:1:2:1:2] | passed | 0.00013 seconds |
35
+ ./spec/services/companies_house_service_spec.rb[1:1:2:2:1] | passed | 0.00011 seconds |
36
+ ./spec/services/companies_house_service_spec.rb[1:1:2:2:2] | passed | 0.0001 seconds |
37
+ ./spec/services/companies_house_service_spec.rb[1:1:2:3:1] | passed | 0.0001 seconds |
38
+ ./spec/services/companies_house_service_spec.rb[1:1:2:3:2] | passed | 0.00014 seconds |
39
+ ./spec/services/companies_house_service_spec.rb[1:1:2:4:1] | passed | 0.00011 seconds |
40
+ ./spec/services/companies_house_service_spec.rb[1:1:2:4:2] | passed | 0.00012 seconds |
41
+ ./spec/services/companies_house_service_spec.rb[1:1:2:5:1] | passed | 0.00012 seconds |
42
+ ./spec/services/companies_house_service_spec.rb[1:1:2:5:2] | passed | 0.00015 seconds |
43
+ ./spec/services/companies_house_service_spec.rb[1:1:2:6:1] | passed | 0.00012 seconds |
44
+ ./spec/services/companies_house_service_spec.rb[1:1:2:6:2] | passed | 0.00011 seconds |
45
+ ./spec/services/companies_house_service_spec.rb[1:1:2:7:1] | passed | 0.00011 seconds |
46
+ ./spec/services/companies_house_service_spec.rb[1:1:2:7:2] | passed | 0.00013 seconds |
47
+ ./spec/services/companies_house_service_spec.rb[1:1:2:8:1] | passed | 0.00012 seconds |
48
+ ./spec/services/companies_house_service_spec.rb[1:1:2:8:2] | passed | 0.00013 seconds |
49
+ ./spec/services/companies_house_service_spec.rb[1:1:2:9:1] | passed | 0.00011 seconds |
50
+ ./spec/services/companies_house_service_spec.rb[1:1:2:9:2] | passed | 0.00015 seconds |
51
+ ./spec/services/companies_house_service_spec.rb[1:1:3:1] | passed | 0.00009 seconds |
52
+ ./spec/services/companies_house_service_spec.rb[1:1:3:2] | passed | 0.00016 seconds |
53
+ ./spec/services/companies_house_service_spec.rb[1:1:3:3] | passed | 0.0001 seconds |
54
+ ./spec/services/companies_house_service_spec.rb[1:1:3:4] | passed | 0.00011 seconds |
55
+ ./spec/services/companies_house_service_spec.rb[1:1:4:1:1] | passed | 0.00017 seconds |
56
+ ./spec/services/companies_house_service_spec.rb[1:1:4:2:1] | passed | 0.00016 seconds |
57
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:1] | passed | 0.00452 seconds |
58
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:2] | passed | 0.00528 seconds |
59
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:3] | passed | 0.00464 seconds |
60
+ ./spec/services/govpay_create_payment_service_spec.rb[1:1:1:4] | passed | 2.48 seconds |
61
+ ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:1] | passed | 0.00168 seconds |
62
+ ./spec/services/govpay_get_payment_service_spec.rb[1:1:1:2] | passed | 0.00151 seconds |
63
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:1:1] | passed | 0.03042 seconds |
64
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:1:1] | passed | 0.00249 seconds |
65
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:2:1] | passed | 0.00236 seconds |
66
+ ./spec/services/govpay_refund_details_service_spec.rb[1:1:2:3:1] | passed | 0.0041 seconds |
67
+ ./spec/services/govpay_request_refund_service_spec.rb[1:1:1:1] | passed | 0.00074 seconds |
68
+ ./spec/services/govpay_request_refund_service_spec.rb[1:1:1:2] | passed | 0.0006 seconds |
@@ -0,0 +1,24 @@
1
+ {
2
+ "created_date": "2020-03-03T16:17:19.554Z",
3
+ "state": {
4
+ "status": "created",
5
+ "finished": false
6
+ },
7
+ "_links": {
8
+ "self": {
9
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/hu20sqlact5260q2nanm0q8u93",
10
+ "method": "GET"
11
+ },
12
+ "next_url": {
13
+ "href": "https://www.payments.service.gov.uk/secure/bb0a272c-8eaf-468d-b3xf-ae5e000d2231",
14
+ "method": "GET"
15
+ }
16
+ },
17
+ "amount": 14500,
18
+ "reference" : "12345",
19
+ "description": "Pay your council tax",
20
+ "return_url": "https://your.service.gov.uk/completed",
21
+ "payment_id": "hu20sqlact5260q2nanm0q8u93",
22
+ "payment_provider": "worldpay",
23
+ "provider_id": "10987654321"
24
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "field": "amount",
3
+ "code": "P0101",
4
+ "description": "Missing mandatory attribute: amount"
5
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "amount": 10501,
3
+ "description": "Waste carrier registration upper tier",
4
+ "reference": "12345",
5
+ "language": "en",
6
+ "metadata": {
7
+ "ledger_code": "AB100",
8
+ "an_internal_reference_number": 200
9
+ },
10
+ "email": "sherlock.holmes@example.com",
11
+ "state": {
12
+ "status": "failed",
13
+ "finished": true,
14
+ "message": "Payment was cancelled by the user",
15
+ "code": "P0030"
16
+ },
17
+ "payment_id": "cjgt8i57kavb8jfufhjlh129fm",
18
+ "payment_provider": "sandbox",
19
+ "created_date": "2022-05-18T11:46:54.697Z",
20
+ "refund_summary": {
21
+ "status": "unavailable",
22
+ "amount_available": 10501,
23
+ "amount_submitted": 0
24
+ },
25
+ "settlement_summary": {},
26
+ "card_details": {
27
+ "last_digits_card_number": "5100",
28
+ "first_digits_card_number": "510510",
29
+ "cardholder_name": "Sherlock Holmes",
30
+ "expiry_date": "01/24",
31
+ "billing_address": {
32
+ "line1": "221 Baker Street",
33
+ "line2": "Flat b",
34
+ "postcode": "NW1 6XE",
35
+ "city": "London",
36
+ "country": "GB"
37
+ },
38
+ "card_brand": "Mastercard",
39
+ "card_type": "debit"
40
+ },
41
+ "delayed_capture": false,
42
+ "moto": false,
43
+ "provider_id": "9fda0405-dc56-4d18-bf53-26167a91a1ac",
44
+ "return_url": "https://some-wcr-env.defra.gov.uk/completed",
45
+ "authorisation_mode": "web",
46
+ "card_brand": "Mastercard",
47
+ "_links": {
48
+ "self": {
49
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm",
50
+ "method": "GET"
51
+ },
52
+ "events": {
53
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/events",
54
+ "method": "GET"
55
+ },
56
+ "refunds": {
57
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/refunds",
58
+ "method": "GET"
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "amount": 10501,
3
+ "description": "Waste carrier registration upper tier",
4
+ "reference": "12345",
5
+ "language": "en",
6
+ "metadata": {
7
+ "ledger_code": "AB100",
8
+ "an_internal_reference_number": 200
9
+ },
10
+ "email": "sherlock.holmes@example.com",
11
+ "state": {
12
+ "status": "created",
13
+ "finished": false
14
+ },
15
+ "payment_id": "cjgt8i57kavb8jfufhjlh129fm",
16
+ "payment_provider": "sandbox",
17
+ "created_date": "2022-05-18T11:46:54.697Z",
18
+ "refund_summary": {
19
+ "status": "pending",
20
+ "amount_available": 10501,
21
+ "amount_submitted": 0
22
+ },
23
+ "settlement_summary": {},
24
+ "card_details": {
25
+ "last_digits_card_number": null,
26
+ "first_digits_card_number": null,
27
+ "cardholder_name": "Sherlock Holmes",
28
+ "expiry_date": null,
29
+ "billing_address": {
30
+ "line1": "221 Baker Street",
31
+ "line2": "Flat b",
32
+ "postcode": "NW1 6XE",
33
+ "city": "London",
34
+ "country": "GB"
35
+ },
36
+ "card_brand": "",
37
+ "card_type": null
38
+ },
39
+ "delayed_capture": false,
40
+ "moto": false,
41
+ "return_url": "https://some-wcr-env.defra.gov.uk/completed",
42
+ "authorisation_mode": "web",
43
+ "_links": {
44
+ "self": {
45
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm",
46
+ "method": "GET"
47
+ },
48
+ "next_url": {
49
+ "href": "https://www.payments.service.gov.uk/secure/c3b8908b-68df-478a-ad94-6a724e614e46",
50
+ "method": "GET"
51
+ },
52
+ "next_url_post": {
53
+ "type": "application/x-www-form-urlencoded",
54
+ "params": {
55
+ "chargeTokenId": "c3b8908b-68df-478a-ad94-6a724e614e46"
56
+ },
57
+ "href": "https://www.payments.service.gov.uk/secure",
58
+ "method": "POST"
59
+ },
60
+ "events": {
61
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/events",
62
+ "method": "GET"
63
+ },
64
+ "refunds": {
65
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/refunds",
66
+ "method": "GET"
67
+ },
68
+ "cancel": {
69
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/cancel",
70
+ "method": "POST"
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "field": "payment_id",
3
+ "code": "P0200",
4
+ "description": "Invalid attribute value: payment_id. No payment matched the payment ID you provided."
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "amount": 2000,
3
+ "state": {
4
+ "status": "failed",
5
+ "finished": true,
6
+ "message": "Payment expired",
7
+ "code": "P0020"
8
+ }
9
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": "P0200",
3
+ "description": "Not found"
4
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "amount": 10501,
3
+ "description": "Waste carrier registration upper tier",
4
+ "reference": "12345",
5
+ "language": "en",
6
+ "metadata": {
7
+ "ledger_code": "AB100",
8
+ "an_internal_reference_number": 200
9
+ },
10
+ "email": "sherlock.holmes@example.com",
11
+ "state": {
12
+ "status": "submitted",
13
+ "finished": false
14
+ },
15
+ "payment_id": "cjgt8i57kavb8jfufhjlh129fm",
16
+ "payment_provider": "sandbox",
17
+ "created_date": "2022-05-18T11:46:54.697Z",
18
+ "refund_summary": {
19
+ "status": "pending",
20
+ "amount_available": 10501,
21
+ "amount_submitted": 0
22
+ },
23
+ "settlement_summary": {},
24
+ "card_details": {
25
+ "last_digits_card_number": "5100",
26
+ "first_digits_card_number": "510510",
27
+ "cardholder_name": "Sherlock Holmes",
28
+ "expiry_date": "01/24",
29
+ "billing_address": {
30
+ "line1": "221 Baker Street",
31
+ "line2": "Flat b",
32
+ "postcode": "NW1 6XE",
33
+ "city": "London",
34
+ "country": "GB"
35
+ },
36
+ "card_brand": "Mastercard",
37
+ "card_type": "debit"
38
+ },
39
+ "delayed_capture": false,
40
+ "moto": false,
41
+ "provider_id": "9fda0405-dc56-4d18-bf53-26167a91a1ac",
42
+ "return_url": "https://some-wcr-env.defra.gov.uk/completed",
43
+ "authorisation_mode": "web",
44
+ "card_brand": "Mastercard",
45
+ "_links": {
46
+ "self": {
47
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm",
48
+ "method": "GET"
49
+ },
50
+ "next_url": {
51
+ "href": "https://www.payments.service.gov.uk/secure/18a144e1-f6d8-4d73-a11a-a45187da9138",
52
+ "method": "GET"
53
+ },
54
+ "next_url_post": {
55
+ "type": "application/x-www-form-urlencoded",
56
+ "params": {
57
+ "chargeTokenId": "18a144e1-f6d8-4d73-a11a-a45187da9138"
58
+ },
59
+ "href": "https://www.payments.service.gov.uk/secure",
60
+ "method": "POST"
61
+ },
62
+ "events": {
63
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/events",
64
+ "method": "GET"
65
+ },
66
+ "refunds": {
67
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/refunds",
68
+ "method": "GET"
69
+ },
70
+ "cancel": {
71
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cjgt8i57kavb8jfufhjlh129fm/cancel",
72
+ "method": "POST"
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "amount": 10501,
3
+ "description": "Waste carrier registration upper tier",
4
+ "reference": "12345",
5
+ "language": "en",
6
+ "metadata": {
7
+ "ledger_code": "AB100",
8
+ "an_internal_reference_number": 200
9
+ },
10
+ "email": "sherlock.holmes@example.com",
11
+ "state": {
12
+ "status": "success",
13
+ "finished": true
14
+ },
15
+ "payment_id": "cnnffa1e6s3u9a6n24u2cp527d",
16
+ "payment_provider": "sandbox",
17
+ "created_date": "2022-05-18T11:52:13.669Z",
18
+ "refund_summary": {
19
+ "status": "available",
20
+ "amount_available": 10501,
21
+ "amount_submitted": 0
22
+ },
23
+ "settlement_summary": {
24
+ "capture_submit_time": "2022-05-18T11:52:39.172Z",
25
+ "captured_date": "2022-05-18"
26
+ },
27
+ "card_details": {
28
+ "last_digits_card_number": "5100",
29
+ "first_digits_card_number": "510510",
30
+ "cardholder_name": "Sherlock Holmes",
31
+ "expiry_date": "01/24",
32
+ "billing_address": {
33
+ "line1": "221 Baker Street",
34
+ "line2": "Flat b",
35
+ "postcode": "NW1 6XE",
36
+ "city": "London",
37
+ "country": "GB"
38
+ },
39
+ "card_brand": "Mastercard",
40
+ "card_type": "debit"
41
+ },
42
+ "delayed_capture": false,
43
+ "moto": false,
44
+ "provider_id": "9bb0c2c1-d0c5-4a63-8945-f4240e06f8ae",
45
+ "return_url": "https://some-wcr-env.defra.gov.uk/completed",
46
+ "authorisation_mode": "web",
47
+ "card_brand": "Mastercard",
48
+ "_links": {
49
+ "self": {
50
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cnnffa1e6s3u9a6n24u2cp527d",
51
+ "method": "GET"
52
+ },
53
+ "events": {
54
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cnnffa1e6s3u9a6n24u2cp527d/events",
55
+ "method": "GET"
56
+ },
57
+ "refunds": {
58
+ "href": "https://publicapi.payments.service.gov.uk/v1/payments/cnnffa1e6s3u9a6n24u2cp527d/refunds",
59
+ "method": "GET"
60
+ }
61
+ }
62
+ }
@@ -40,12 +40,17 @@ module DefraRubyMocks
40
40
  expect(response_json["description"]).to eq payment_request[:description]
41
41
  expect(response_json["_links"]["next_url"]["href"]).to eq payment_request[:return_url]
42
42
  end
43
+
44
+ it "enqueues a job to perform the payment callback" do
45
+ ActiveJob::Base.queue_adapter = :test
46
+ expect { post path, params: payment_request.as_json }.to have_enqueued_job(GovpayPaymentCallbackJob)
47
+ end
43
48
  end
44
49
 
45
50
  context "when the request is missing a mandatory parameter" do
46
51
  before { payment_request[:amount] = nil }
47
52
 
48
- it "returns a HTTP 500 responseß" do
53
+ it "returns a HTTP 500 response" do
49
54
  post path, params: payment_request.as_json
50
55
 
51
56
  expect(response.code).to eq "500"
@@ -55,8 +60,16 @@ module DefraRubyMocks
55
60
 
56
61
  describe "#payment_details" do
57
62
  let(:path) { "/defra_ruby_mocks/govpay/v1/payments/#{payment_id}" }
63
+
58
64
  context "when the payment id is valid" do
65
+ before do
66
+ allow(GovpayGetPaymentService).to receive(:run)
67
+ .with(payment_id)
68
+ .and_return(JSON.parse(File.read("spec/fixtures/files/govpay/get_payment_response_success.json")))
69
+ end
70
+
59
71
  let(:payment_id) { "12345678901234567890123456" }
72
+
60
73
  it "returns a valid success response" do
61
74
  get path
62
75
 
@@ -65,7 +78,14 @@ module DefraRubyMocks
65
78
  end
66
79
 
67
80
  context "when the payment id is not valid" do
81
+ before do
82
+ allow(GovpayGetPaymentService).to receive(:run)
83
+ .with(payment_id)
84
+ .and_return(JSON.parse(File.read("spec/fixtures/files/govpay/get_payment_response_error.json")))
85
+ end
86
+
68
87
  let(:payment_id) { "0" }
88
+
69
89
  it "returns a 422 response" do
70
90
  get path
71
91
 
@@ -73,6 +93,49 @@ module DefraRubyMocks
73
93
  end
74
94
  end
75
95
  end
96
+
97
+ describe "#create_refund" do
98
+ let(:payment_id) { "12345678901234567890123456" }
99
+ let(:path) { "/defra_ruby_mocks/govpay/v1/payments/#{payment_id}/refunds" }
100
+ let(:refund_request) do
101
+ {
102
+ "amount": 2000,
103
+ "refund_amount_available": 5000
104
+ }
105
+ end
106
+
107
+ context "when the request is missing a mandatory parameter" do
108
+ before { refund_request[:refund_amount_available] = nil }
109
+
110
+ it "returns a HTTP 500 response" do
111
+ post path, params: refund_request.as_json
112
+
113
+ expect(response.code).to eq "500"
114
+ end
115
+ end
116
+
117
+ context "with a valid request" do
118
+ it "returns a valid success response" do
119
+ post path, params: refund_request.as_json
120
+
121
+ expect(response.code).to eq "200"
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "#refund_details" do
127
+ let(:payment_id) { "12345678901234567890123456" }
128
+ let(:refund_id) { "j6se0f2o427g28g8yg3u3i" }
129
+ let(:path) { "/defra_ruby_mocks/govpay/v1/payments/#{payment_id}/refunds/#{refund_id}" }
130
+
131
+ context "with a valid request" do
132
+ it "returns a valid success response" do
133
+ get path
134
+
135
+ expect(response.code).to eq "200"
136
+ end
137
+ end
138
+ end
76
139
  end
77
140
 
78
141
  context "when mocks are disabled" do