judopay 2.1.0 → 2.1.3

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 (122) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +24 -23
  3. data/.rspec +1 -1
  4. data/.rubocop.yml +54 -51
  5. data/.travis.yml +6 -6
  6. data/CHANGELOG.md +17 -17
  7. data/Gemfile +4 -4
  8. data/LICENSE +21 -21
  9. data/README.md +96 -94
  10. data/Rakefile +22 -22
  11. data/judopay.gemspec +38 -38
  12. data/lib/certs/digicert_sha256_ca.pem +49 -49
  13. data/lib/certs/rapidssl_ca.crt +63 -63
  14. data/lib/faraday/judo_mashify.rb +11 -11
  15. data/lib/faraday/raise_http_exception.rb +19 -19
  16. data/lib/judopay.rb +70 -70
  17. data/lib/judopay/api.rb +10 -10
  18. data/lib/judopay/connection.rb +77 -77
  19. data/lib/judopay/core_ext/hash.rb +29 -29
  20. data/lib/judopay/core_ext/string.rb +32 -32
  21. data/lib/judopay/error.rb +117 -115
  22. data/lib/judopay/mash.rb +11 -11
  23. data/lib/judopay/model.rb +134 -134
  24. data/lib/judopay/models/android_payment.rb +26 -26
  25. data/lib/judopay/models/android_preauth.rb +8 -8
  26. data/lib/judopay/models/apple_payment.rb +26 -26
  27. data/lib/judopay/models/apple_preauth.rb +9 -9
  28. data/lib/judopay/models/card_address.rb +11 -11
  29. data/lib/judopay/models/card_payment.rb +33 -33
  30. data/lib/judopay/models/card_preauth.rb +11 -11
  31. data/lib/judopay/models/collection.rb +16 -16
  32. data/lib/judopay/models/encrypt_details.rb +18 -0
  33. data/lib/judopay/models/inner/pk_payment.rb +17 -17
  34. data/lib/judopay/models/inner/pk_payment_token.rb +13 -13
  35. data/lib/judopay/models/inner/transmitted_field.rb +39 -39
  36. data/lib/judopay/models/inner/wallet.rb +30 -30
  37. data/lib/judopay/models/market/collection.rb +10 -10
  38. data/lib/judopay/models/market/payment.rb +10 -10
  39. data/lib/judopay/models/market/preauth.rb +10 -10
  40. data/lib/judopay/models/market/refund.rb +10 -10
  41. data/lib/judopay/models/market/transaction.rb +10 -10
  42. data/lib/judopay/models/one_use_token_payment.rb +29 -0
  43. data/lib/judopay/models/payment.rb +8 -8
  44. data/lib/judopay/models/preauth.rb +8 -8
  45. data/lib/judopay/models/refund.rb +16 -16
  46. data/lib/judopay/models/register_card.rb +27 -27
  47. data/lib/judopay/models/save_card.rb +24 -25
  48. data/lib/judopay/models/token_payment.rb +30 -30
  49. data/lib/judopay/models/token_preauth.rb +10 -10
  50. data/lib/judopay/models/transaction.rb +8 -8
  51. data/lib/judopay/models/void.rb +19 -19
  52. data/lib/judopay/models/web_payments/payment.rb +28 -28
  53. data/lib/judopay/models/web_payments/preauth.rb +10 -10
  54. data/lib/judopay/models/web_payments/transaction.rb +19 -19
  55. data/lib/judopay/models/web_payments/web_payment_operation.rb +8 -8
  56. data/lib/judopay/null_logger.rb +9 -11
  57. data/lib/judopay/request.rb +50 -50
  58. data/lib/judopay/response.rb +7 -7
  59. data/lib/judopay/serializer.rb +27 -27
  60. data/lib/judopay/version.rb +4 -4
  61. data/spec/factories.rb +227 -208
  62. data/spec/faraday/response_spec.rb +27 -27
  63. data/spec/fixtures/card_payments/create.json +21 -21
  64. data/spec/fixtures/card_payments/create_3dsecure.json +7 -7
  65. data/spec/fixtures/card_payments/create_bad_request.json +12 -12
  66. data/spec/fixtures/card_payments/create_declined.json +23 -23
  67. data/spec/fixtures/card_payments/validate.json +4 -4
  68. data/spec/fixtures/token_payments/create.json +21 -21
  69. data/spec/fixtures/transactions/all.json +237 -237
  70. data/spec/fixtures/transactions/android_payment.json +26 -26
  71. data/spec/fixtures/transactions/apple_payment.json +26 -26
  72. data/spec/fixtures/transactions/find.json +22 -22
  73. data/spec/fixtures/transactions/find_not_found.json +4 -4
  74. data/spec/fixtures/transactions/register_card.json +28 -28
  75. data/spec/fixtures/transactions/save_card.json +27 -27
  76. data/spec/fixtures/transactions/void.json +26 -26
  77. data/spec/fixtures/web_payments/payments/create.json +3 -3
  78. data/spec/fixtures/web_payments/payments/find.json +38 -38
  79. data/spec/judopay/android_payment_spec.rb +74 -74
  80. data/spec/judopay/apple_payment_spec.rb +80 -80
  81. data/spec/judopay/card_address_spec.rb +10 -10
  82. data/spec/judopay/card_payment_spec.rb +51 -63
  83. data/spec/judopay/card_preauth_spec.rb +35 -35
  84. data/spec/judopay/collection_spec.rb +26 -26
  85. data/spec/judopay/core_ext/hash_spec.rb +24 -24
  86. data/spec/judopay/core_ext/string_spec.rb +16 -16
  87. data/spec/judopay/error_spec.rb +70 -70
  88. data/spec/judopay/judopay_spec.rb +19 -19
  89. data/spec/judopay/market/collection_spec.rb +26 -26
  90. data/spec/judopay/market/payment_spec.rb +14 -14
  91. data/spec/judopay/market/preauth_spec.rb +14 -14
  92. data/spec/judopay/market/refund_spec.rb +26 -26
  93. data/spec/judopay/market/transaction_spec.rb +14 -14
  94. data/spec/judopay/payment_spec.rb +14 -14
  95. data/spec/judopay/preauth_spec.rb +14 -14
  96. data/spec/judopay/refund_spec.rb +26 -26
  97. data/spec/judopay/register_card_spec.rb +24 -24
  98. data/spec/judopay/save_card_spec.rb +23 -23
  99. data/spec/judopay/token_payment_spec.rb +22 -22
  100. data/spec/judopay/token_preauth_spec.rb +22 -22
  101. data/spec/judopay/transaction_spec.rb +51 -51
  102. data/spec/judopay/void_spec.rb +24 -24
  103. data/spec/judopay/web_payments/payment_spec.rb +16 -16
  104. data/spec/judopay/web_payments/preauth_spec.rb +16 -16
  105. data/spec/judopay/web_payments/transaction_spec.rb +15 -15
  106. data/spec/spec_helper.rb +41 -41
  107. data/test/additions_payment_test.rb +30 -0
  108. data/test/authentication_test.rb +23 -23
  109. data/test/base/integration_base.rb +20 -20
  110. data/test/base/payments_tests.rb +47 -47
  111. data/test/base/token_payment_tests.rb +98 -98
  112. data/test/card_details_test.rb +21 -21
  113. data/test/configuration_test.rb +35 -35
  114. data/test/helper/assertion_helper.rb +29 -29
  115. data/test/payment_test.rb +10 -10
  116. data/test/preauth_test.rb +10 -10
  117. data/test/register_card_test.rb +42 -42
  118. data/test/save_card_test.rb +23 -0
  119. data/test/token_payment_test.rb +10 -10
  120. data/test/token_preauth_test.rb +10 -10
  121. data/test/void_test.rb +45 -45
  122. metadata +18 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ee2fddf46aa4fa23cc6e41a1bf37766134704c47
4
- data.tar.gz: 41e0f0af43a8c59434748d81a4a7a2f3b3736da1
2
+ SHA256:
3
+ metadata.gz: c4322bcef8c0b210b38579fe124137e8b92e9ff150f2b76449e9d91b4b5c4174
4
+ data.tar.gz: 29e03ee4dba7843a6417842348f77dc02eae10f1fbe25ddbc70800a5cbb1a2b3
5
5
  SHA512:
6
- metadata.gz: 3b73e9514861890092abbfc44c3538298a2231ca8f296efb9cd602658c0f37061e1f1acce80b0194f0c9e55c7b8436de87130af057402038e40a025ddd703569
7
- data.tar.gz: 505a41b6bfe31584202759a318fdc24369851b3d3cf12d511cbc293f4e757871384ec8fb99b1b007cb16536296851a93bab80694b6561b55d512d63f0a355a0d
6
+ metadata.gz: d2d9f55bd0cb4b04ad493ebd46a18ab5749e42c15302a44967679a93dc33399505fa1855bc17d81bdcc6b4136f310dd6959a7a9a408df5d4c7a1bbabafbbffa6
7
+ data.tar.gz: 377e8961642271df5917446752e9d09f85a27228d81c2e117fd1a8d87ae2a973493f595effa402e79a9c4fac84d82595635d8d0c004b9f23e88b2933dbbe2aae
data/.gitignore CHANGED
@@ -1,23 +1,24 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
-
19
- log.txt
20
-
21
- cmd.txt
22
-
23
- output.txt
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ log.txt
21
+
22
+ cmd.txt
23
+
24
+ output.txt
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --color
1
+ --color
2
2
  --require spec_helper
@@ -1,51 +1,54 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-06-26 17:06:45 +0100 using RuboCop version 0.23.0.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Offense count: 2
9
- # Cop supports --auto-correct.
10
- Lint/UnusedMethodArgument:
11
- Enabled: false
12
-
13
- # Offense count: 1
14
- Style/CyclomaticComplexity:
15
- Max: 10
16
-
17
- # Offense count: 15
18
- Style/Documentation:
19
- Enabled: false
20
-
21
- # Offense count: 18
22
- # Configuration parameters: EnforcedStyle, SupportedStyles.
23
- Style/DotPosition:
24
- Enabled: false
25
-
26
- # Offense count: 73
27
- # Cop supports --auto-correct.
28
- # Configuration parameters: SupportedStyles.
29
- Style/HashSyntax:
30
- EnforcedStyle: hash_rockets
31
-
32
- # Offense count: 18
33
- Style/Lambda:
34
- Enabled: false
35
-
36
- # Offense count: 25
37
- Style/LineLength:
38
- Max: 138
39
-
40
- # Offense count: 3
41
- # Configuration parameters: CountComments.
42
- Style/MethodLength:
43
- Max: 32
44
-
45
- # Offense count: 2
46
- Style/RegexpLiteral:
47
- MaxSlashes: 0
48
-
49
- AllCops:
50
- Exclude:
51
- - 'judopay.gemspec'
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-06-26 17:06:45 +0100 using RuboCop version 0.23.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 2
9
+ # Cop supports --auto-correct.
10
+ Lint/UnusedMethodArgument:
11
+ Enabled: false
12
+
13
+ # Offense count: 1
14
+ Metrics/CyclomaticComplexity:
15
+ Max: 10
16
+
17
+ # Offense count: 15
18
+ Style/Documentation:
19
+ Enabled: false
20
+
21
+ # Offense count: 18
22
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
23
+ Layout/DotPosition:
24
+ Enabled: false
25
+
26
+ # Offense count: 73
27
+ # Cop supports --auto-correct.
28
+ # Configuration parameters: SupportedStyles.
29
+ Style/HashSyntax:
30
+ EnforcedStyle: hash_rockets
31
+
32
+ # Offense count: 18
33
+ Style/Lambda:
34
+ Enabled: false
35
+
36
+ Style/SymbolArray:
37
+ Enabled: false
38
+
39
+ # Offense count: 25
40
+ Metrics/LineLength:
41
+ Max: 141
42
+
43
+ # Offense count: 3
44
+ # Configuration parameters: CountComments.
45
+ Metrics/MethodLength:
46
+ Max: 80
47
+
48
+ Metrics/BlockLength:
49
+ Max: 65
50
+
51
+ AllCops:
52
+ Exclude:
53
+ - 'judopay.gemspec'
54
+ - 'spec/factories.rb'
@@ -1,6 +1,6 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- - 2.1.2
5
- - 2.0.0
6
- sudo: false
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.1.2
5
+ - 2.0.0
6
+ sudo: false
@@ -1,17 +1,17 @@
1
- # Version 2.0.0
2
-
3
- #### Modifications
4
- In version 2.0 we changed error model and added couple of new models.
5
-
6
- We decreased amount of Exceptions to two:
7
- - Local validation error (ValidationError)
8
- - ApiException which arise when Judo REST API returns error.
9
-
10
- So at first you need to update your error handling principle. See example at [Error handling](https://github.com/JudoPay/RubySdk/wiki/Error-handling).
11
-
12
- #### Additions
13
- - ```validate``` method added to [Collect](https://github.com/JudoPay/RubySdk/wiki/Collecting-on-a-Pre-Authorization#validating-the-collection) and [Refund](https://github.com/JudoPay/PhpSdk/wiki/Refund-a-Payment#validating-the-refund) models so now you could check yours transactions.
14
- - [Void model](https://github.com/JudoPay/RubySdk/wiki/Voiding-requests)
15
- - [Register card model](https://github.com/JudoPay/RubySdk/wiki/Registering-a-Card)
16
- - [Save card model](https://github.com/JudoPay/RubySdk/wiki/Saving-a-Card)
17
- - Integration tests
1
+ # Version 2.0.0
2
+
3
+ #### Modifications
4
+ In version 2.0 we changed error model and added couple of new models.
5
+
6
+ We decreased amount of Exceptions to two:
7
+ - Local validation error (ValidationError)
8
+ - ApiException which arise when Judo REST API returns error.
9
+
10
+ So at first you need to update your error handling principle. See example at [Error handling](https://github.com/JudoPay/RubySdk/wiki/Error-handling).
11
+
12
+ #### Additions
13
+ - ```validate``` method added to [Collect](https://github.com/JudoPay/RubySdk/wiki/Collecting-on-a-Pre-Authorization#validating-the-collection) and [Refund](https://github.com/JudoPay/PhpSdk/wiki/Refund-a-Payment#validating-the-refund) models so now you could check yours transactions.
14
+ - [Void model](https://github.com/JudoPay/RubySdk/wiki/Voiding-requests)
15
+ - [Register card model](https://github.com/JudoPay/RubySdk/wiki/Registering-a-Card)
16
+ - [Save card model](https://github.com/JudoPay/RubySdk/wiki/Saving-a-Card)
17
+ - Integration tests
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in judopay.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in judopay.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2016 Alternative Payments Ltd
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Alternative Payments Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,94 +1,96 @@
1
- # Judopay Ruby gem [![Build Status](https://travis-ci.org/JudoPay/Judo-Ruby.svg?branch=master)](https://travis-ci.org/JudoPay/Judo-Ruby)
2
- The JudoPay gem provides you with ability to integrate card payments into your Ruby and Rails projects. Judo's SDK enables a faster, simpler and more secure payment experience within your app.
3
- ##### **\*\*\*Due to industry-wide security updates, versions below 2.0 of this SDK will no longer be supported after 1st Oct 2016. For more information regarding these updates, please read our blog [here](http://hub.judopay.com/pci31-security-updates/).*****
4
-
5
- ## Requirements
6
- The Judopay gem supports Ruby 1.9.3 and above (including 2.0.x and 2.1.x).
7
-
8
- ## Getting started
9
- ##### 1. Integration
10
- Add this line to your application's Gemfile:
11
-
12
- gem 'judopay'
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install judopay
21
-
22
- ##### 2. Setup
23
- To start using the gem, you need to pass block with your API credentials:
24
- ```ruby
25
- Judopay.configure do |config|
26
- config.judo_id = 'your-judo-id'
27
- config.api_token = 'your-token'
28
- config.api_secret = 'your-secret'
29
- config.use_production = false # set to true on production, defaults to false which is the sandbox
30
- end
31
- ```
32
-
33
- ##### 3. Make a payment
34
- To make a new payment with full card details:
35
- ```ruby
36
- payment = Judopay::CardPayment.new(
37
- :judoId => 'your_judo_id',
38
- :your_consumer_reference => 'xxxxxxxx',
39
- :your_payment_reference => 'xxxxxxxx',
40
- :amount => 5.01,
41
- :currency => 'GBP',
42
- :card_number => '4976000000003436',
43
- :expiry_date => '12/20',
44
- :cv2 => '452',
45
- :card_address => {
46
- :line1 => '32 Edward Street',
47
- :town => 'Camborne',
48
- :postcode => 'TR14 8PA'
49
- },
50
- :consumer_location => {
51
- :latitude => 51.5033630,
52
- :longitude => -0.1276250
53
- }
54
- )
55
- ```
56
- **Note:** Please make sure that you are using a unique Consumer Reference for each different consumer, and a unique Payment Reference for each transaction.
57
-
58
- You can check on the required fields and the format of each field in the [Judopay REST API reference](https://www.judopay.com/docs/version-52/api/restful-api/#post-card-payment).
59
-
60
- To send the request to the API, call:
61
- ```ruby
62
- payment_response = payment.create
63
- ```
64
-
65
- ##### 4. Check the payment result
66
- If the payment is successful, you'll `payment_response` variable will contain Mash like this (see full response [here](https://www.judopay.com/docs/v5/api-reference/restful-api/#post-card-payment)):
67
- ```ruby
68
- {
69
- "receipt_id"=>"xxxxxxx",
70
- "type"=>"Payment",
71
- "created_at"=>"2016-09-23T09:28:47.1207+01:00",
72
- "result"=>"Success",
73
- ...
74
- "amount"=>"5.01",
75
- "currency"=>"GBP",
76
- ...
77
- }
78
- ```
79
- So your check code might look like this:
80
- ```ruby
81
- if result_payment.result == 'Success'
82
- puts 'Payment successful'
83
- else
84
- puts 'There were some problems while processing your payment'
85
- end
86
- ```
87
-
88
- Also important to handle different exceptions in your code. See more details in our [error handling section](https://github.com/JudoPay/RubySdk/wiki/Error-handling).
89
-
90
- ## Next steps
91
- The Judopay gem supports a range of customization options. For more information on using judo see our [wiki documentation](https://github.com/JudoPay/RubySdk/wiki).
92
-
93
- ## License
94
- See the [LICENSE](https://github.com/JudoPay/RubySdk/blob/master/LICENSE.txt) file for license rights and limitations (MIT).
1
+ # Judopay Ruby gem [![Build Status](https://travis-ci.org/Judopay/Judo-Ruby.svg?branch=master)](https://travis-ci.org/Judopay/Judo-Ruby)
2
+ The JudoPay gem provides you with ability to integrate card payments into your Ruby and Rails projects. Judo's SDK enables a faster, simpler and more secure payment experience within your app.
3
+
4
+
5
+ ## Requirements
6
+ The Judopay gem supports Ruby 1.9.3 and above (including 2.x).
7
+
8
+ ## Getting started
9
+ ##### 1. Integration
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'judopay'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install judopay
21
+
22
+ ##### 2. Setup
23
+ To start using the gem, you need to pass block with your API credentials:
24
+ ```ruby
25
+ require 'judopay'
26
+ Judopay.configure do |config|
27
+ config.judo_id = '<JUDO_ID>'
28
+ config.api_token = '<TOKEN>'
29
+ config.api_secret = '<SECRET>'
30
+ config.use_production = false # set to true on production, defaults to false which is the sandbox
31
+ end
32
+ ```
33
+
34
+ ##### 3. Make a payment
35
+ Add model inclusion to your source code:
36
+ ```ruby
37
+ require 'judopay/models/card_payment'
38
+ ```
39
+ **Note:** by default we only include the minimum models in order to keep memory footprint down. You will need to include it explicitly when using each type of payment model as defined in the wiki.
40
+
41
+ To make a new payment with full card details:
42
+ ```ruby
43
+ payment = Judopay::CardPayment.new(
44
+ :judoId => '<JUDO_ID>',
45
+ :your_consumer_reference => '<CONSUMER_REFERENCE>',
46
+ :your_payment_reference => '<PAYMENT_REFERENCE>',
47
+ :amount => 5.01,
48
+ :currency => 'GBP',
49
+ :card_number => '4976000000003436',
50
+ :expiry_date => '12/20',
51
+ :cv2 => '452',
52
+ :card_address => {
53
+ :line1 => '32 Edward Street',
54
+ :town => 'Camborne',
55
+ :postcode => 'TR14 8PA'
56
+ }
57
+ )
58
+ ```
59
+ **Note:** Please make sure that you are using a unique `your_consumer_reference` for each different consumer, and a unique `your_payment_reference` for each transaction.
60
+
61
+ You can check on the required fields and the format of each field in the [Judopay REST API reference](https://www.judopay.com/docs/version-52/api/restful-api/#post-card-payment).
62
+
63
+ To send the request to the API, call:
64
+ ```ruby
65
+ payment_response = payment.create
66
+ ```
67
+
68
+ ##### 4. Check the payment result
69
+ The response will contain the full details of the transaction: (see full response [here](https://www.judopay.com/docs/v5/api-reference/restful-api/#post-card-payment)):
70
+ ```ruby
71
+ {
72
+ "receipt_id"=>"xxxxxxx",
73
+ "type"=>"Payment",
74
+ "created_at"=>"2016-09-23T09:28:47.1207+01:00",
75
+ "result"=>"Success",
76
+ "amount"=>"5.01",
77
+ "currency"=>"GBP",
78
+ ...
79
+ }
80
+ ```
81
+ The status of the transaction can be checked to see if it was successful:
82
+ ```ruby
83
+ if payment_response.result == 'Success'
84
+ puts 'Payment successful'
85
+ else
86
+ puts 'There was an issue while processing the payment'
87
+ end
88
+ ```
89
+
90
+ It's important to handle different exceptions in your code. See more details in our [error handling section](https://github.com/JudoPay/RubySdk/wiki/Error-handling).
91
+
92
+ ## Next steps
93
+ The Judopay gem supports a range of customization options. For more information on using the Judo Ruby SDK see our [wiki documentation](https://github.com/JudoPay/RubySdk/wiki).
94
+
95
+ ## License
96
+ See the [LICENSE](https://github.com/JudoPay/RubySdk/blob/master/LICENSE.txt) file for license rights and limitations (MIT).