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.
- checksums.yaml +5 -5
- data/.gitignore +24 -23
- data/.rspec +1 -1
- data/.rubocop.yml +54 -51
- data/.travis.yml +6 -6
- data/CHANGELOG.md +17 -17
- data/Gemfile +4 -4
- data/LICENSE +21 -21
- data/README.md +96 -94
- data/Rakefile +22 -22
- data/judopay.gemspec +38 -38
- data/lib/certs/digicert_sha256_ca.pem +49 -49
- data/lib/certs/rapidssl_ca.crt +63 -63
- data/lib/faraday/judo_mashify.rb +11 -11
- data/lib/faraday/raise_http_exception.rb +19 -19
- data/lib/judopay.rb +70 -70
- data/lib/judopay/api.rb +10 -10
- data/lib/judopay/connection.rb +77 -77
- data/lib/judopay/core_ext/hash.rb +29 -29
- data/lib/judopay/core_ext/string.rb +32 -32
- data/lib/judopay/error.rb +117 -115
- data/lib/judopay/mash.rb +11 -11
- data/lib/judopay/model.rb +134 -134
- data/lib/judopay/models/android_payment.rb +26 -26
- data/lib/judopay/models/android_preauth.rb +8 -8
- data/lib/judopay/models/apple_payment.rb +26 -26
- data/lib/judopay/models/apple_preauth.rb +9 -9
- data/lib/judopay/models/card_address.rb +11 -11
- data/lib/judopay/models/card_payment.rb +33 -33
- data/lib/judopay/models/card_preauth.rb +11 -11
- data/lib/judopay/models/collection.rb +16 -16
- data/lib/judopay/models/encrypt_details.rb +18 -0
- data/lib/judopay/models/inner/pk_payment.rb +17 -17
- data/lib/judopay/models/inner/pk_payment_token.rb +13 -13
- data/lib/judopay/models/inner/transmitted_field.rb +39 -39
- data/lib/judopay/models/inner/wallet.rb +30 -30
- data/lib/judopay/models/market/collection.rb +10 -10
- data/lib/judopay/models/market/payment.rb +10 -10
- data/lib/judopay/models/market/preauth.rb +10 -10
- data/lib/judopay/models/market/refund.rb +10 -10
- data/lib/judopay/models/market/transaction.rb +10 -10
- data/lib/judopay/models/one_use_token_payment.rb +29 -0
- data/lib/judopay/models/payment.rb +8 -8
- data/lib/judopay/models/preauth.rb +8 -8
- data/lib/judopay/models/refund.rb +16 -16
- data/lib/judopay/models/register_card.rb +27 -27
- data/lib/judopay/models/save_card.rb +24 -25
- data/lib/judopay/models/token_payment.rb +30 -30
- data/lib/judopay/models/token_preauth.rb +10 -10
- data/lib/judopay/models/transaction.rb +8 -8
- data/lib/judopay/models/void.rb +19 -19
- data/lib/judopay/models/web_payments/payment.rb +28 -28
- data/lib/judopay/models/web_payments/preauth.rb +10 -10
- data/lib/judopay/models/web_payments/transaction.rb +19 -19
- data/lib/judopay/models/web_payments/web_payment_operation.rb +8 -8
- data/lib/judopay/null_logger.rb +9 -11
- data/lib/judopay/request.rb +50 -50
- data/lib/judopay/response.rb +7 -7
- data/lib/judopay/serializer.rb +27 -27
- data/lib/judopay/version.rb +4 -4
- data/spec/factories.rb +227 -208
- data/spec/faraday/response_spec.rb +27 -27
- data/spec/fixtures/card_payments/create.json +21 -21
- data/spec/fixtures/card_payments/create_3dsecure.json +7 -7
- data/spec/fixtures/card_payments/create_bad_request.json +12 -12
- data/spec/fixtures/card_payments/create_declined.json +23 -23
- data/spec/fixtures/card_payments/validate.json +4 -4
- data/spec/fixtures/token_payments/create.json +21 -21
- data/spec/fixtures/transactions/all.json +237 -237
- data/spec/fixtures/transactions/android_payment.json +26 -26
- data/spec/fixtures/transactions/apple_payment.json +26 -26
- data/spec/fixtures/transactions/find.json +22 -22
- data/spec/fixtures/transactions/find_not_found.json +4 -4
- data/spec/fixtures/transactions/register_card.json +28 -28
- data/spec/fixtures/transactions/save_card.json +27 -27
- data/spec/fixtures/transactions/void.json +26 -26
- data/spec/fixtures/web_payments/payments/create.json +3 -3
- data/spec/fixtures/web_payments/payments/find.json +38 -38
- data/spec/judopay/android_payment_spec.rb +74 -74
- data/spec/judopay/apple_payment_spec.rb +80 -80
- data/spec/judopay/card_address_spec.rb +10 -10
- data/spec/judopay/card_payment_spec.rb +51 -63
- data/spec/judopay/card_preauth_spec.rb +35 -35
- data/spec/judopay/collection_spec.rb +26 -26
- data/spec/judopay/core_ext/hash_spec.rb +24 -24
- data/spec/judopay/core_ext/string_spec.rb +16 -16
- data/spec/judopay/error_spec.rb +70 -70
- data/spec/judopay/judopay_spec.rb +19 -19
- data/spec/judopay/market/collection_spec.rb +26 -26
- data/spec/judopay/market/payment_spec.rb +14 -14
- data/spec/judopay/market/preauth_spec.rb +14 -14
- data/spec/judopay/market/refund_spec.rb +26 -26
- data/spec/judopay/market/transaction_spec.rb +14 -14
- data/spec/judopay/payment_spec.rb +14 -14
- data/spec/judopay/preauth_spec.rb +14 -14
- data/spec/judopay/refund_spec.rb +26 -26
- data/spec/judopay/register_card_spec.rb +24 -24
- data/spec/judopay/save_card_spec.rb +23 -23
- data/spec/judopay/token_payment_spec.rb +22 -22
- data/spec/judopay/token_preauth_spec.rb +22 -22
- data/spec/judopay/transaction_spec.rb +51 -51
- data/spec/judopay/void_spec.rb +24 -24
- data/spec/judopay/web_payments/payment_spec.rb +16 -16
- data/spec/judopay/web_payments/preauth_spec.rb +16 -16
- data/spec/judopay/web_payments/transaction_spec.rb +15 -15
- data/spec/spec_helper.rb +41 -41
- data/test/additions_payment_test.rb +30 -0
- data/test/authentication_test.rb +23 -23
- data/test/base/integration_base.rb +20 -20
- data/test/base/payments_tests.rb +47 -47
- data/test/base/token_payment_tests.rb +98 -98
- data/test/card_details_test.rb +21 -21
- data/test/configuration_test.rb +35 -35
- data/test/helper/assertion_helper.rb +29 -29
- data/test/payment_test.rb +10 -10
- data/test/preauth_test.rb +10 -10
- data/test/register_card_test.rb +42 -42
- data/test/save_card_test.rb +23 -0
- data/test/token_payment_test.rb +10 -10
- data/test/token_preauth_test.rb +10 -10
- data/test/void_test.rb +45 -45
- metadata +18 -12
@@ -1,26 +1,26 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "xxxxxxx",
|
3
|
-
"yourPaymentReference": "xxxxxxxxxxxxxxxxxxxxxx",
|
4
|
-
"type": "Payment",
|
5
|
-
"createdAt": "2016-11-03T15:02:26.8290+00:00",
|
6
|
-
"result": "Success",
|
7
|
-
"message": "AuthCode: xxxxxx",
|
8
|
-
"judoId": "xxxxxxxxx",
|
9
|
-
"merchantName": "xxxxxxxxxxxx",
|
10
|
-
"appearsOnStatementAs": "xxxxxxxxxxxxx",
|
11
|
-
"originalAmount": "0.02",
|
12
|
-
"netAmount": "0.02",
|
13
|
-
"amount": "0.02",
|
14
|
-
"currency": "GBP",
|
15
|
-
"cardDetails": {
|
16
|
-
"cardLastfour": "xxxx",
|
17
|
-
"endDate": "xxxx",
|
18
|
-
"cardToken": "xxxx",
|
19
|
-
"cardType": 1
|
20
|
-
},
|
21
|
-
"consumer": {
|
22
|
-
"consumerToken": "xxxxxxxxxxxxxx",
|
23
|
-
"yourConsumerReference": "xxxxxxxxxxxxxxxx"
|
24
|
-
},
|
25
|
-
"walletType": 2
|
26
|
-
}
|
1
|
+
{
|
2
|
+
"receiptId": "xxxxxxx",
|
3
|
+
"yourPaymentReference": "xxxxxxxxxxxxxxxxxxxxxx",
|
4
|
+
"type": "Payment",
|
5
|
+
"createdAt": "2016-11-03T15:02:26.8290+00:00",
|
6
|
+
"result": "Success",
|
7
|
+
"message": "AuthCode: xxxxxx",
|
8
|
+
"judoId": "xxxxxxxxx",
|
9
|
+
"merchantName": "xxxxxxxxxxxx",
|
10
|
+
"appearsOnStatementAs": "xxxxxxxxxxxxx",
|
11
|
+
"originalAmount": "0.02",
|
12
|
+
"netAmount": "0.02",
|
13
|
+
"amount": "0.02",
|
14
|
+
"currency": "GBP",
|
15
|
+
"cardDetails": {
|
16
|
+
"cardLastfour": "xxxx",
|
17
|
+
"endDate": "xxxx",
|
18
|
+
"cardToken": "xxxx",
|
19
|
+
"cardType": 1
|
20
|
+
},
|
21
|
+
"consumer": {
|
22
|
+
"consumerToken": "xxxxxxxxxxxxxx",
|
23
|
+
"yourConsumerReference": "xxxxxxxxxxxxxxxx"
|
24
|
+
},
|
25
|
+
"walletType": 2
|
26
|
+
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "someReceipt",
|
3
|
-
"yourPaymentReference": "NEW_PR_123123123",
|
4
|
-
"type": "Payment",
|
5
|
-
"createdAt": "2016-10-31T10:09:10.4378+00:00",
|
6
|
-
"result": "Success",
|
7
|
-
"message": "AuthCode: xxxxxx",
|
8
|
-
"judoId": "someId",
|
9
|
-
"merchantName": "PiePay Project",
|
10
|
-
"appearsOnStatementAs": "APL*\/PiePayProject ",
|
11
|
-
"originalAmount": "0.02",
|
12
|
-
"netAmount": "0.02",
|
13
|
-
"amount": "0.02",
|
14
|
-
"currency": "GBP",
|
15
|
-
"cardDetails": {
|
16
|
-
"cardLastfour": "xxxx",
|
17
|
-
"endDate": "xxxx",
|
18
|
-
"cardToken": "xxxxxxxxxxxxxx",
|
19
|
-
"cardType": 1
|
20
|
-
},
|
21
|
-
"consumer": {
|
22
|
-
"consumerToken": "xxxxxxxxx",
|
23
|
-
"yourConsumerReference": "Myconsumerref"
|
24
|
-
},
|
25
|
-
"walletType": 1
|
26
|
-
}
|
1
|
+
{
|
2
|
+
"receiptId": "someReceipt",
|
3
|
+
"yourPaymentReference": "NEW_PR_123123123",
|
4
|
+
"type": "Payment",
|
5
|
+
"createdAt": "2016-10-31T10:09:10.4378+00:00",
|
6
|
+
"result": "Success",
|
7
|
+
"message": "AuthCode: xxxxxx",
|
8
|
+
"judoId": "someId",
|
9
|
+
"merchantName": "PiePay Project",
|
10
|
+
"appearsOnStatementAs": "APL*\/PiePayProject ",
|
11
|
+
"originalAmount": "0.02",
|
12
|
+
"netAmount": "0.02",
|
13
|
+
"amount": "0.02",
|
14
|
+
"currency": "GBP",
|
15
|
+
"cardDetails": {
|
16
|
+
"cardLastfour": "xxxx",
|
17
|
+
"endDate": "xxxx",
|
18
|
+
"cardToken": "xxxxxxxxxxxxxx",
|
19
|
+
"cardType": 1
|
20
|
+
},
|
21
|
+
"consumer": {
|
22
|
+
"consumerToken": "xxxxxxxxx",
|
23
|
+
"yourConsumerReference": "Myconsumerref"
|
24
|
+
},
|
25
|
+
"walletType": 1
|
26
|
+
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "439539",
|
3
|
-
"type": "Payment",
|
4
|
-
"createdAt": "2014-06-17T14:56:49.7571+01:00",
|
5
|
-
"result": "Success",
|
6
|
-
"message": "AuthCode: 210658",
|
7
|
-
"judoId": 100016,
|
8
|
-
"merchantName": "Judo Pay test",
|
9
|
-
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
10
|
-
"netAmount": 1.01,
|
11
|
-
"amount": 1.01,
|
12
|
-
"currency": "GBP",
|
13
|
-
"cardDetails": {
|
14
|
-
"cardLastfour": "5462",
|
15
|
-
"endDate": "1215",
|
16
|
-
"cardType": 11
|
17
|
-
},
|
18
|
-
"consumer": {
|
19
|
-
"consumerToken": "HUClqv3MSdCh6g5M",
|
20
|
-
"yourConsumerReference": "WebPayDemo_17/06/2014 14:56:53 +01:00"
|
21
|
-
},
|
22
|
-
"yourPaymentMetaData": {}
|
1
|
+
{
|
2
|
+
"receiptId": "439539",
|
3
|
+
"type": "Payment",
|
4
|
+
"createdAt": "2014-06-17T14:56:49.7571+01:00",
|
5
|
+
"result": "Success",
|
6
|
+
"message": "AuthCode: 210658",
|
7
|
+
"judoId": 100016,
|
8
|
+
"merchantName": "Judo Pay test",
|
9
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
10
|
+
"netAmount": 1.01,
|
11
|
+
"amount": 1.01,
|
12
|
+
"currency": "GBP",
|
13
|
+
"cardDetails": {
|
14
|
+
"cardLastfour": "5462",
|
15
|
+
"endDate": "1215",
|
16
|
+
"cardType": 11
|
17
|
+
},
|
18
|
+
"consumer": {
|
19
|
+
"consumerToken": "HUClqv3MSdCh6g5M",
|
20
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:56:53 +01:00"
|
21
|
+
},
|
22
|
+
"yourPaymentMetaData": {}
|
23
23
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
{
|
2
|
-
"errorMessage": "No transaction found for receipt id",
|
3
|
-
"errorType": 19,
|
4
|
-
"modelErrors": []
|
1
|
+
{
|
2
|
+
"errorMessage": "No transaction found for receipt id",
|
3
|
+
"errorType": 19,
|
4
|
+
"modelErrors": []
|
5
5
|
}
|
@@ -1,29 +1,29 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "5050240",
|
3
|
-
"yourPaymentReference": "Judo_RegisterCardPreAuth_636059257945294942",
|
4
|
-
"type": "PreAuth",
|
5
|
-
"createdAt": "2016-08-04T16:43:14.7482+01:00",
|
6
|
-
"result": "Success",
|
7
|
-
"message": "AuthCode: 910333",
|
8
|
-
"judoId": 100435197,
|
9
|
-
"merchantName": "Oleg",
|
10
|
-
"appearsOnStatementAs": "APL\/Oleg ",
|
11
|
-
"originalAmount": "1.01",
|
12
|
-
"amountCollected": "0.00",
|
13
|
-
"netAmount": "1.01",
|
14
|
-
"amount": "1.01",
|
15
|
-
"currency": "GBP",
|
16
|
-
"cardDetails": {
|
17
|
-
"cardLastfour": "3436",
|
18
|
-
"endDate": "1220",
|
19
|
-
"cardToken": "123123123",
|
20
|
-
"cardType": 1
|
21
|
-
},
|
22
|
-
"consumer": {
|
23
|
-
"consumerToken": "123123123",
|
24
|
-
"yourConsumerReference": "12345"
|
25
|
-
},
|
26
|
-
"risks": {
|
27
|
-
"postCodeCheck": "UNKNOWN"
|
28
|
-
}
|
1
|
+
{
|
2
|
+
"receiptId": "5050240",
|
3
|
+
"yourPaymentReference": "Judo_RegisterCardPreAuth_636059257945294942",
|
4
|
+
"type": "PreAuth",
|
5
|
+
"createdAt": "2016-08-04T16:43:14.7482+01:00",
|
6
|
+
"result": "Success",
|
7
|
+
"message": "AuthCode: 910333",
|
8
|
+
"judoId": 100435197,
|
9
|
+
"merchantName": "Oleg",
|
10
|
+
"appearsOnStatementAs": "APL\/Oleg ",
|
11
|
+
"originalAmount": "1.01",
|
12
|
+
"amountCollected": "0.00",
|
13
|
+
"netAmount": "1.01",
|
14
|
+
"amount": "1.01",
|
15
|
+
"currency": "GBP",
|
16
|
+
"cardDetails": {
|
17
|
+
"cardLastfour": "3436",
|
18
|
+
"endDate": "1220",
|
19
|
+
"cardToken": "123123123",
|
20
|
+
"cardType": 1
|
21
|
+
},
|
22
|
+
"consumer": {
|
23
|
+
"consumerToken": "123123123",
|
24
|
+
"yourConsumerReference": "12345"
|
25
|
+
},
|
26
|
+
"risks": {
|
27
|
+
"postCodeCheck": "UNKNOWN"
|
28
|
+
}
|
29
29
|
}
|
@@ -1,28 +1,28 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "123123123",
|
3
|
-
"yourPaymentReference": "Judo_RegisterCard_636051228548063948",
|
4
|
-
"type": "Register",
|
5
|
-
"createdAt": "2016-07-26T09:40:54.9313+01:00",
|
6
|
-
"result": "Success",
|
7
|
-
"message": "Register Card",
|
8
|
-
"judoId": 323123123,
|
9
|
-
"merchantName": "SomeMerch",
|
10
|
-
"appearsOnStatementAs": "APL123",
|
11
|
-
"originalAmount": "0.00",
|
12
|
-
"netAmount": "0.00",
|
13
|
-
"amount": "0.00",
|
14
|
-
"currency": "GBP",
|
15
|
-
"cardDetails": {
|
16
|
-
"cardLastfour": "3436",
|
17
|
-
"endDate": "1220",
|
18
|
-
"cardToken": "abc",
|
19
|
-
"cardType": 1
|
20
|
-
},
|
21
|
-
"consumer": {
|
22
|
-
"consumerToken": "abc",
|
23
|
-
"yourConsumerReference": "12345"
|
24
|
-
},
|
25
|
-
"risks": {
|
26
|
-
"postCodeCheck": "UNKNOWN"
|
27
|
-
}
|
1
|
+
{
|
2
|
+
"receiptId": "123123123",
|
3
|
+
"yourPaymentReference": "Judo_RegisterCard_636051228548063948",
|
4
|
+
"type": "Register",
|
5
|
+
"createdAt": "2016-07-26T09:40:54.9313+01:00",
|
6
|
+
"result": "Success",
|
7
|
+
"message": "Register Card",
|
8
|
+
"judoId": 323123123,
|
9
|
+
"merchantName": "SomeMerch",
|
10
|
+
"appearsOnStatementAs": "APL123",
|
11
|
+
"originalAmount": "0.00",
|
12
|
+
"netAmount": "0.00",
|
13
|
+
"amount": "0.00",
|
14
|
+
"currency": "GBP",
|
15
|
+
"cardDetails": {
|
16
|
+
"cardLastfour": "3436",
|
17
|
+
"endDate": "1220",
|
18
|
+
"cardToken": "abc",
|
19
|
+
"cardType": 1
|
20
|
+
},
|
21
|
+
"consumer": {
|
22
|
+
"consumerToken": "abc",
|
23
|
+
"yourConsumerReference": "12345"
|
24
|
+
},
|
25
|
+
"risks": {
|
26
|
+
"postCodeCheck": "UNKNOWN"
|
27
|
+
}
|
28
28
|
}
|
@@ -1,27 +1,27 @@
|
|
1
|
-
{
|
2
|
-
"receiptId": "XXXXXX",
|
3
|
-
"originalReceiptId": "12345",
|
4
|
-
"yourPaymentReference": "12345",
|
5
|
-
"type": "VOID",
|
6
|
-
"createdAt": "2016-08-11T13:30:38.1849+01:00",
|
7
|
-
"result": "Success",
|
8
|
-
"message": "Void successful",
|
9
|
-
"judoId": 123123123,
|
10
|
-
"merchantName": "xxxx",
|
11
|
-
"appearsOnStatementAs": "xxxxxxx",
|
12
|
-
"originalAmount": "1.02",
|
13
|
-
"amountCollected": "0.00",
|
14
|
-
"netAmount": "1.02",
|
15
|
-
"amount": "1.02",
|
16
|
-
"currency": "GBP",
|
17
|
-
"cardDetails": {
|
18
|
-
"cardLastfour": "3436",
|
19
|
-
"endDate": "1220",
|
20
|
-
"cardToken": "xxxxxxxxxxxxxxxxxxxx",
|
21
|
-
"cardType": 1
|
22
|
-
},
|
23
|
-
"consumer": {
|
24
|
-
"consumerToken": "xxxxxxxxxxxxxxxx",
|
25
|
-
"yourConsumerReference": "12345"
|
26
|
-
}
|
1
|
+
{
|
2
|
+
"receiptId": "XXXXXX",
|
3
|
+
"originalReceiptId": "12345",
|
4
|
+
"yourPaymentReference": "12345",
|
5
|
+
"type": "VOID",
|
6
|
+
"createdAt": "2016-08-11T13:30:38.1849+01:00",
|
7
|
+
"result": "Success",
|
8
|
+
"message": "Void successful",
|
9
|
+
"judoId": 123123123,
|
10
|
+
"merchantName": "xxxx",
|
11
|
+
"appearsOnStatementAs": "xxxxxxx",
|
12
|
+
"originalAmount": "1.02",
|
13
|
+
"amountCollected": "0.00",
|
14
|
+
"netAmount": "1.02",
|
15
|
+
"amount": "1.02",
|
16
|
+
"currency": "GBP",
|
17
|
+
"cardDetails": {
|
18
|
+
"cardLastfour": "3436",
|
19
|
+
"endDate": "1220",
|
20
|
+
"cardToken": "xxxxxxxxxxxxxxxxxxxx",
|
21
|
+
"cardType": 1
|
22
|
+
},
|
23
|
+
"consumer": {
|
24
|
+
"consumerToken": "xxxxxxxxxxxxxxxx",
|
25
|
+
"yourConsumerReference": "12345"
|
26
|
+
}
|
27
27
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
{
|
2
|
-
"postUrl": "https://pay.judopay-sandbox.com/",
|
3
|
-
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ"
|
1
|
+
{
|
2
|
+
"postUrl": "https://pay.judopay-sandbox.com/",
|
3
|
+
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ"
|
4
4
|
}
|
@@ -1,39 +1,39 @@
|
|
1
|
-
{
|
2
|
-
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ",
|
3
|
-
"status": "Open",
|
4
|
-
"transactionType": "Payment",
|
5
|
-
"judoId": "1234-4567",
|
6
|
-
"amount": 12.34,
|
7
|
-
"currency": "GBP",
|
8
|
-
"expiryDate": "2014-03-18T14:35:54.5428+00:00",
|
9
|
-
"companyName": "AnyMerchant Ltd",
|
10
|
-
"yourConsumerReference": "consumer0053252",
|
11
|
-
"yourPaymentReference": "payment12412312",
|
12
|
-
"yourPaymentMetaData": {},
|
13
|
-
"response": {
|
14
|
-
"postUrl": "http://pay.judopay-sandbox.com/",
|
15
|
-
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ"
|
16
|
-
},
|
17
|
-
"cardAddress": "",
|
18
|
-
"clientIpAddress": "127.0.0.1",
|
19
|
-
"clientUserAgent": "Mozilla/5.0 (Windows NT 6.2; Win64; x64)...",
|
20
|
-
"paymentSuccessUrl": "http://www.yourcompany.co.uk/success",
|
21
|
-
"paymentCancelUrl": "http://www.yourcompany.co.uk/cancel",
|
22
|
-
"receipt": {
|
23
|
-
"receiptId": "1234",
|
24
|
-
"type": "Payment",
|
25
|
-
"createdAt": "2012-12-05T14:40:53.4529+00:00",
|
26
|
-
"result": "Success",
|
27
|
-
"message": "Payment was successful",
|
28
|
-
"judoId": "123-4567",
|
29
|
-
"merchantName": "AnyMerchant Ltd",
|
30
|
-
"appearsOnStatementAs": "Judo Payments/AnyMerch",
|
31
|
-
"refunds": 0.00,
|
32
|
-
"netAmount": 12.34,
|
33
|
-
"cardDetails": {
|
34
|
-
"cardLastFour": "3436",
|
35
|
-
"endDate": "12/15",
|
36
|
-
"cardType": 1
|
37
|
-
}
|
38
|
-
}
|
1
|
+
{
|
2
|
+
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ",
|
3
|
+
"status": "Open",
|
4
|
+
"transactionType": "Payment",
|
5
|
+
"judoId": "1234-4567",
|
6
|
+
"amount": 12.34,
|
7
|
+
"currency": "GBP",
|
8
|
+
"expiryDate": "2014-03-18T14:35:54.5428+00:00",
|
9
|
+
"companyName": "AnyMerchant Ltd",
|
10
|
+
"yourConsumerReference": "consumer0053252",
|
11
|
+
"yourPaymentReference": "payment12412312",
|
12
|
+
"yourPaymentMetaData": {},
|
13
|
+
"response": {
|
14
|
+
"postUrl": "http://pay.judopay-sandbox.com/",
|
15
|
+
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ"
|
16
|
+
},
|
17
|
+
"cardAddress": "",
|
18
|
+
"clientIpAddress": "127.0.0.1",
|
19
|
+
"clientUserAgent": "Mozilla/5.0 (Windows NT 6.2; Win64; x64)...",
|
20
|
+
"paymentSuccessUrl": "http://www.yourcompany.co.uk/success",
|
21
|
+
"paymentCancelUrl": "http://www.yourcompany.co.uk/cancel",
|
22
|
+
"receipt": {
|
23
|
+
"receiptId": "1234",
|
24
|
+
"type": "Payment",
|
25
|
+
"createdAt": "2012-12-05T14:40:53.4529+00:00",
|
26
|
+
"result": "Success",
|
27
|
+
"message": "Payment was successful",
|
28
|
+
"judoId": "123-4567",
|
29
|
+
"merchantName": "AnyMerchant Ltd",
|
30
|
+
"appearsOnStatementAs": "Judo Payments/AnyMerch",
|
31
|
+
"refunds": 0.00,
|
32
|
+
"netAmount": 12.34,
|
33
|
+
"cardDetails": {
|
34
|
+
"cardLastFour": "3436",
|
35
|
+
"endDate": "12/15",
|
36
|
+
"cardType": 1
|
37
|
+
}
|
38
|
+
}
|
39
39
|
}
|
@@ -1,74 +1,74 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/judopay/models/android_payment'
|
3
|
-
|
4
|
-
describe Judopay::AndroidPayment do
|
5
|
-
it 'should create a new payment given wallet object' do
|
6
|
-
stub_post('/transactions/payments').
|
7
|
-
to_return(:status => 200,
|
8
|
-
:body => lambda { |_request| fixture('transactions/android_payment.json') })
|
9
|
-
|
10
|
-
payment = build(:android_payment)
|
11
|
-
response = payment.create
|
12
|
-
|
13
|
-
expect(response).to be_a(Hash)
|
14
|
-
expect(response.result).to eq('Success')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should return a bad request exception if basic validation fails' do
|
18
|
-
expect(lambda do
|
19
|
-
Judopay::AndroidPayment.new.create
|
20
|
-
end).to raise_error(Judopay::ValidationError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should use the configured Judo ID if one isn\'t provided in the payment request' do
|
24
|
-
stub_post('/transactions/payments').
|
25
|
-
to_return(:status => 200,
|
26
|
-
:body => lambda { |_request| fixture('transactions/android_payment.json') })
|
27
|
-
|
28
|
-
Judopay.configure do |config|
|
29
|
-
config.judo_id = '123-456'
|
30
|
-
end
|
31
|
-
|
32
|
-
payment = build(:android_payment, :judo_id => nil)
|
33
|
-
payment.create
|
34
|
-
|
35
|
-
expect(payment.valid?).to eq(true)
|
36
|
-
expect(payment.judo_id).to eq('123-456')
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'properly coerces wallet field from_json' do
|
40
|
-
json_string = '{"wallet":{"encryptedMessage":"SomeBase64encodedData","environment":1,'\
|
41
|
-
'"ephemeralPublicKey":"SomeBase64encodedData","googleTransactionId":"someId",'\
|
42
|
-
'"instrumentDetails":"1234","instrumentType":"VISA","publicKey":"SomeBase64encodedData",'\
|
43
|
-
'"tag":"SomeBase64encodedData","version":1}}'
|
44
|
-
|
45
|
-
wallet = Judopay::Wallet.new(
|
46
|
-
:encrypted_message => 'SomeBase64encodedData',
|
47
|
-
:environment => 1,
|
48
|
-
:ephemeral_public_key => 'SomeBase64encodedData',
|
49
|
-
:google_transaction_id => 'someId',
|
50
|
-
:instrument_details => '1234',
|
51
|
-
:instrument_type => 'VISA',
|
52
|
-
:publicKey => 'SomeBase64encodedData',
|
53
|
-
:tag => 'SomeBase64encodedData',
|
54
|
-
:version => 1
|
55
|
-
)
|
56
|
-
|
57
|
-
payment = build(:android_payment, :wallet => json_string)
|
58
|
-
expect(payment.wallet).to be == wallet
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should raise an error when bad wallet passed' do
|
62
|
-
expect(lambda do
|
63
|
-
Judopay::AndroidPayment.new(:wallet => '{"someInvalidJson}}')
|
64
|
-
end).to raise_error(Judopay::ValidationError, format(Judopay::Wallet::WRONG_JSON_ERROR_MESSAGE, 'Judopay::Wallet'))
|
65
|
-
|
66
|
-
expect(lambda do
|
67
|
-
Judopay::AndroidPayment.new(:wallet => 1)
|
68
|
-
end).to raise_error(Judopay::ValidationError, format(Judopay::Wallet::WRONG_OBJECT_ERROR_MESSAGE, 'Judopay::Wallet'))
|
69
|
-
|
70
|
-
expect(lambda do
|
71
|
-
build(:android_payment, :wallet => '{"valid_json":"Without token field"}').create
|
72
|
-
end).to raise_error(Judopay::ValidationError)
|
73
|
-
end
|
74
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/android_payment'
|
3
|
+
|
4
|
+
describe Judopay::AndroidPayment do
|
5
|
+
it 'should create a new payment given wallet object' do
|
6
|
+
stub_post('/transactions/payments').
|
7
|
+
to_return(:status => 200,
|
8
|
+
:body => lambda { |_request| fixture('transactions/android_payment.json') })
|
9
|
+
|
10
|
+
payment = build(:android_payment)
|
11
|
+
response = payment.create
|
12
|
+
|
13
|
+
expect(response).to be_a(Hash)
|
14
|
+
expect(response.result).to eq('Success')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return a bad request exception if basic validation fails' do
|
18
|
+
expect(lambda do
|
19
|
+
Judopay::AndroidPayment.new.create
|
20
|
+
end).to raise_error(Judopay::ValidationError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should use the configured Judo ID if one isn\'t provided in the payment request' do
|
24
|
+
stub_post('/transactions/payments').
|
25
|
+
to_return(:status => 200,
|
26
|
+
:body => lambda { |_request| fixture('transactions/android_payment.json') })
|
27
|
+
|
28
|
+
Judopay.configure do |config|
|
29
|
+
config.judo_id = '123-456'
|
30
|
+
end
|
31
|
+
|
32
|
+
payment = build(:android_payment, :judo_id => nil)
|
33
|
+
payment.create
|
34
|
+
|
35
|
+
expect(payment.valid?).to eq(true)
|
36
|
+
expect(payment.judo_id).to eq('123-456')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'properly coerces wallet field from_json' do
|
40
|
+
json_string = '{"wallet":{"encryptedMessage":"SomeBase64encodedData","environment":1,'\
|
41
|
+
'"ephemeralPublicKey":"SomeBase64encodedData","googleTransactionId":"someId",'\
|
42
|
+
'"instrumentDetails":"1234","instrumentType":"VISA","publicKey":"SomeBase64encodedData",'\
|
43
|
+
'"tag":"SomeBase64encodedData","version":1}}'
|
44
|
+
|
45
|
+
wallet = Judopay::Wallet.new(
|
46
|
+
:encrypted_message => 'SomeBase64encodedData',
|
47
|
+
:environment => 1,
|
48
|
+
:ephemeral_public_key => 'SomeBase64encodedData',
|
49
|
+
:google_transaction_id => 'someId',
|
50
|
+
:instrument_details => '1234',
|
51
|
+
:instrument_type => 'VISA',
|
52
|
+
:publicKey => 'SomeBase64encodedData',
|
53
|
+
:tag => 'SomeBase64encodedData',
|
54
|
+
:version => 1
|
55
|
+
)
|
56
|
+
|
57
|
+
payment = build(:android_payment, :wallet => json_string)
|
58
|
+
expect(payment.wallet).to be == wallet
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should raise an error when bad wallet passed' do
|
62
|
+
expect(lambda do
|
63
|
+
Judopay::AndroidPayment.new(:wallet => '{"someInvalidJson}}')
|
64
|
+
end).to raise_error(Judopay::ValidationError, format(Judopay::Wallet::WRONG_JSON_ERROR_MESSAGE, :foo => 'Judopay::Wallet'))
|
65
|
+
|
66
|
+
expect(lambda do
|
67
|
+
Judopay::AndroidPayment.new(:wallet => 1)
|
68
|
+
end).to raise_error(Judopay::ValidationError, format(Judopay::Wallet::WRONG_OBJECT_ERROR_MESSAGE, :foo => 'Judopay::Wallet'))
|
69
|
+
|
70
|
+
expect(lambda do
|
71
|
+
build(:android_payment, :wallet => '{"valid_json":"Without token field"}').create
|
72
|
+
end).to raise_error(Judopay::ValidationError)
|
73
|
+
end
|
74
|
+
end
|