cloud_payments 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +4 -0
- data/.travis.yml +8 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +106 -0
- data/Rakefile +7 -0
- data/cloud_payments.gemspec +28 -0
- data/config.ru +58 -0
- data/lib/cloud_payments.rb +34 -0
- data/lib/cloud_payments/client.rb +50 -0
- data/lib/cloud_payments/client/errors.rb +68 -0
- data/lib/cloud_payments/client/gateway_errors.rb +36 -0
- data/lib/cloud_payments/client/response.rb +22 -0
- data/lib/cloud_payments/client/serializer.rb +9 -0
- data/lib/cloud_payments/client/serializer/base.rb +46 -0
- data/lib/cloud_payments/client/serializer/multi_json.rb +17 -0
- data/lib/cloud_payments/config.rb +44 -0
- data/lib/cloud_payments/models.rb +4 -0
- data/lib/cloud_payments/models/model.rb +5 -0
- data/lib/cloud_payments/models/secure3d.rb +15 -0
- data/lib/cloud_payments/models/subscription.rb +49 -0
- data/lib/cloud_payments/models/transaction.rb +82 -0
- data/lib/cloud_payments/namespaces.rb +23 -0
- data/lib/cloud_payments/namespaces/base.rb +50 -0
- data/lib/cloud_payments/namespaces/cards.rb +25 -0
- data/lib/cloud_payments/namespaces/payments.rb +32 -0
- data/lib/cloud_payments/namespaces/subscriptions.rb +24 -0
- data/lib/cloud_payments/namespaces/tokens.rb +15 -0
- data/lib/cloud_payments/version.rb +3 -0
- data/spec/cloud_payments/client/response_spec.rb +35 -0
- data/spec/cloud_payments/client/serializer/multi_json_spec.rb +16 -0
- data/spec/cloud_payments/client_spec.rb +5 -0
- data/spec/cloud_payments/models/secure3d_spec.rb +37 -0
- data/spec/cloud_payments/models/subscription_spec.rb +141 -0
- data/spec/cloud_payments/models/transaction_spec.rb +254 -0
- data/spec/cloud_payments/namespaces/base_spec.rb +75 -0
- data/spec/cloud_payments/namespaces/cards_spec.rb +119 -0
- data/spec/cloud_payments/namespaces/payments_spec.rb +96 -0
- data/spec/cloud_payments/namespaces/subscriptions_spec.rb +82 -0
- data/spec/cloud_payments/namespaces/tokens_spec.rb +90 -0
- data/spec/cloud_payments/namespaces_spec.rb +45 -0
- data/spec/cloud_payments_spec.rb +14 -0
- data/spec/fixtures/apis/cards/auth/failed.yml +45 -0
- data/spec/fixtures/apis/cards/auth/secure3d.yml +15 -0
- data/spec/fixtures/apis/cards/auth/successful.yml +48 -0
- data/spec/fixtures/apis/cards/charge/failed.yml +45 -0
- data/spec/fixtures/apis/cards/charge/secure3d.yml +15 -0
- data/spec/fixtures/apis/cards/charge/successful.yml +48 -0
- data/spec/fixtures/apis/payments/confirm/failed.yml +6 -0
- data/spec/fixtures/apis/payments/confirm/failed_with_message.yml +6 -0
- data/spec/fixtures/apis/payments/confirm/successful.yml +6 -0
- data/spec/fixtures/apis/payments/post3ds/failed.yml +45 -0
- data/spec/fixtures/apis/payments/post3ds/successful.yml +48 -0
- data/spec/fixtures/apis/payments/refund/failed.yml +6 -0
- data/spec/fixtures/apis/payments/refund/failed_with_message.yml +6 -0
- data/spec/fixtures/apis/payments/refund/successful.yml +6 -0
- data/spec/fixtures/apis/payments/void/failed.yml +6 -0
- data/spec/fixtures/apis/payments/void/failed_with_message.yml +6 -0
- data/spec/fixtures/apis/payments/void/successful.yml +6 -0
- data/spec/fixtures/apis/ping/failed.yml +5 -0
- data/spec/fixtures/apis/ping/successful.yml +5 -0
- data/spec/fixtures/apis/subscriptions/cancel/successful.yml +6 -0
- data/spec/fixtures/apis/subscriptions/create/successful.yml +31 -0
- data/spec/fixtures/apis/subscriptions/find/successful.yml +31 -0
- data/spec/fixtures/apis/subscriptions/update/successful.yml +31 -0
- data/spec/fixtures/apis/tokens/auth/failed.yml +45 -0
- data/spec/fixtures/apis/tokens/auth/successful.yml +48 -0
- data/spec/fixtures/apis/tokens/charge/failed.yml +45 -0
- data/spec/fixtures/apis/tokens/charge/successful.yml +48 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/examples.rb +27 -0
- data/spec/support/helpers.rb +89 -0
- metadata +244 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CloudPayments::Namespaces do
|
4
|
+
subject{ CloudPayments::Client.new }
|
5
|
+
|
6
|
+
describe '#payments' do
|
7
|
+
specify{ expect(subject.payments).to be_instance_of(CloudPayments::Namespaces::Payments) }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#subscriptions' do
|
11
|
+
specify{ expect(subject.subscriptions).to be_instance_of(CloudPayments::Namespaces::Subscriptions) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#ping' do
|
15
|
+
context 'when successful response' do
|
16
|
+
before{ stub_api_request('ping/successful').perform }
|
17
|
+
specify{ expect(subject.ping).to be_truthy }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when failed response' do
|
21
|
+
before{ stub_api_request('ping/failed').perform }
|
22
|
+
specify{ expect(subject.ping).to be_falsy }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when empty response' do
|
26
|
+
before{ stub_api_request('ping/failed').to_return(body: '') }
|
27
|
+
specify{ expect(subject.ping).to be_falsy }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when error response' do
|
31
|
+
before{ stub_api_request('ping/failed').to_return(status: 404) }
|
32
|
+
specify{ expect(subject.ping).to be_falsy }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when exception occurs while request' do
|
36
|
+
before{ stub_api_request('ping/failed').to_raise(::Faraday::Error::ConnectionFailed) }
|
37
|
+
specify{ expect(subject.ping).to be_falsy }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when timeout occurs while request' do
|
41
|
+
before{ stub_api_request('ping/failed').to_timeout }
|
42
|
+
specify{ expect(subject.ping).to be_falsy }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CloudPayments do
|
4
|
+
describe '#config=' do
|
5
|
+
before{ @old_config = CloudPayments.config }
|
6
|
+
after{ CloudPayments.config = @old_config }
|
7
|
+
|
8
|
+
specify{ expect{ CloudPayments.config = 'config' }.to change{ CloudPayments.config }.to('config') }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#config' do
|
12
|
+
specify{ expect(CloudPayments.config).to be_instance_of(CloudPayments::Config) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/auth'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model": {
|
9
|
+
"TransactionId": 12345,
|
10
|
+
"Amount": 10.0,
|
11
|
+
"Currency": "RUB",
|
12
|
+
"CurrencyCode": 0,
|
13
|
+
"PaymentAmount": 10.0,
|
14
|
+
"PaymentCurrency": "RUB",
|
15
|
+
"PaymentCurrencyCode": 0,
|
16
|
+
"InvoiceId": "1234567",
|
17
|
+
"AccountId": "user_x",
|
18
|
+
"Email": null,
|
19
|
+
"Description": "Payment for goods on example.com",
|
20
|
+
"JsonData": null,
|
21
|
+
"CreatedDate": "\/Date(1401718880000)\/",
|
22
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
23
|
+
"TestMode": true,
|
24
|
+
"IpAddress": "195.91.194.13",
|
25
|
+
"IpCountry": "RU",
|
26
|
+
"IpCity": "Ufa",
|
27
|
+
"IpRegion": "Bashkortostan Republic",
|
28
|
+
"IpDistrict": "Volga Federal District",
|
29
|
+
"IpLatitude": 54.7355,
|
30
|
+
"IpLongitude": 55.991982,
|
31
|
+
"CardFirstSix": "411111",
|
32
|
+
"CardLastFour": "1111",
|
33
|
+
"CardType": "Visa",
|
34
|
+
"CardTypeCode": 0,
|
35
|
+
"IssuerBankCountry": "RU",
|
36
|
+
"Status": "Declined",
|
37
|
+
"StatusCode": 5,
|
38
|
+
"Reason": "InsufficientFunds",
|
39
|
+
"ReasonCode": 5051,
|
40
|
+
"CardHolderMessage": "Insufficient funds on account",
|
41
|
+
"Name": "CARDHOLDER NAME"
|
42
|
+
},
|
43
|
+
"Success": false,
|
44
|
+
"Message": null
|
45
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/auth'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model": {
|
9
|
+
"TransactionId": 12345,
|
10
|
+
"PaReq": "eJxVUdtugkAQ",
|
11
|
+
"AcsUrl": "https://test.paymentgate.ru/acs/auth/start.do"
|
12
|
+
},
|
13
|
+
"Success": false,
|
14
|
+
"Message": null
|
15
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/auth'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model":{
|
9
|
+
"TransactionId":12345,
|
10
|
+
"Amount":10.0,
|
11
|
+
"Currency":"RUB",
|
12
|
+
"CurrencyCode":0,
|
13
|
+
"InvoiceId":"1234567",
|
14
|
+
"AccountId":"user_x",
|
15
|
+
"Email":null,
|
16
|
+
"Description":"Payment for goods on example.com",
|
17
|
+
"JsonData":null,
|
18
|
+
"CreatedDate":"\/Date(1401718880000)\/",
|
19
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
20
|
+
"AuthDate":"\/Date(1401733880523)\/",
|
21
|
+
"AuthDateIso":"2014-08-09T11:49:42",
|
22
|
+
"ConfirmDate":null,
|
23
|
+
"ConfirmDateIso":null,
|
24
|
+
"AuthCode":"123456",
|
25
|
+
"TestMode":true,
|
26
|
+
"IpAddress":"195.91.194.13",
|
27
|
+
"IpCountry":"RU",
|
28
|
+
"IpCity":"Ufa",
|
29
|
+
"IpRegion":"Bashkortostan Republic",
|
30
|
+
"IpDistrict":"Volga Federal District",
|
31
|
+
"IpLatitude":54.7355,
|
32
|
+
"IpLongitude":55.991982,
|
33
|
+
"CardFirstSix":"411111",
|
34
|
+
"CardLastFour":"1111",
|
35
|
+
"CardType":"Visa",
|
36
|
+
"CardTypeCode":0,
|
37
|
+
"IssuerBankCountry":"RU",
|
38
|
+
"Status":"Authorized",
|
39
|
+
"StatusCode":3,
|
40
|
+
"Reason":"Approved",
|
41
|
+
"ReasonCode":0,
|
42
|
+
"CardHolderMessage":"Payment successful",
|
43
|
+
"Name":"CARDHOLDER NAME",
|
44
|
+
"Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0"
|
45
|
+
},
|
46
|
+
"Success":true,
|
47
|
+
"Message": null
|
48
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/charge'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model": {
|
9
|
+
"TransactionId": 12345,
|
10
|
+
"Amount": 10.0,
|
11
|
+
"Currency": "RUB",
|
12
|
+
"CurrencyCode": 0,
|
13
|
+
"PaymentAmount": 10.0,
|
14
|
+
"PaymentCurrency": "RUB",
|
15
|
+
"PaymentCurrencyCode": 0,
|
16
|
+
"InvoiceId": "1234567",
|
17
|
+
"AccountId": "user_x",
|
18
|
+
"Email": null,
|
19
|
+
"Description": "Payment for goods on example.com",
|
20
|
+
"JsonData": null,
|
21
|
+
"CreatedDate": "\/Date(1401718880000)\/",
|
22
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
23
|
+
"TestMode": true,
|
24
|
+
"IpAddress": "195.91.194.13",
|
25
|
+
"IpCountry": "RU",
|
26
|
+
"IpCity": "Ufa",
|
27
|
+
"IpRegion": "Bashkortostan Republic",
|
28
|
+
"IpDistrict": "Volga Federal District",
|
29
|
+
"IpLatitude": 54.7355,
|
30
|
+
"IpLongitude": 55.991982,
|
31
|
+
"CardFirstSix": "411111",
|
32
|
+
"CardLastFour": "1111",
|
33
|
+
"CardType": "Visa",
|
34
|
+
"CardTypeCode": 0,
|
35
|
+
"IssuerBankCountry": "RU",
|
36
|
+
"Status": "Declined",
|
37
|
+
"StatusCode": 5,
|
38
|
+
"Reason": "InsufficientFunds",
|
39
|
+
"ReasonCode": 5051,
|
40
|
+
"CardHolderMessage": "Insufficient funds on account",
|
41
|
+
"Name": "CARDHOLDER NAME"
|
42
|
+
},
|
43
|
+
"Success": false,
|
44
|
+
"Message": null
|
45
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/charge'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model": {
|
9
|
+
"TransactionId": 12345,
|
10
|
+
"PaReq": "eJxVUdtugkAQ",
|
11
|
+
"AcsUrl": "https://test.paymentgate.ru/acs/auth/start.do"
|
12
|
+
},
|
13
|
+
"Success": false,
|
14
|
+
"Message": null
|
15
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/cards/charge'
|
4
|
+
:body: '{"Amount":10,"Currency":"RUB","InvoiceId":"1234567","Description":"Payment for goods on example.com","AccountId":"user_x","Name":"CARDHOLDER NAME","CardCryptogramPacket":"01492500008719030128SM"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model":{
|
9
|
+
"TransactionId":12345,
|
10
|
+
"Amount":10.0,
|
11
|
+
"Currency":"RUB",
|
12
|
+
"CurrencyCode":0,
|
13
|
+
"InvoiceId":"1234567",
|
14
|
+
"AccountId":"user_x",
|
15
|
+
"Email":null,
|
16
|
+
"Description":"Payment for goods on example.com",
|
17
|
+
"JsonData":null,
|
18
|
+
"CreatedDate":"\/Date(1401718880000)\/",
|
19
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
20
|
+
"AuthDate":"\/Date(1401733880523)\/",
|
21
|
+
"AuthDateIso":"2014-08-09T11:49:42",
|
22
|
+
"ConfirmDate":"\/Date(1401733880523)\/",
|
23
|
+
"ConfirmDateIso":"2014-08-09T11:49:42",
|
24
|
+
"AuthCode":"123456",
|
25
|
+
"TestMode":true,
|
26
|
+
"IpAddress":"195.91.194.13",
|
27
|
+
"IpCountry":"RU",
|
28
|
+
"IpCity":"Ufa",
|
29
|
+
"IpRegion":"Bashkortostan Republic",
|
30
|
+
"IpDistrict":"Volga Federal District",
|
31
|
+
"IpLatitude":54.7355,
|
32
|
+
"IpLongitude":55.991982,
|
33
|
+
"CardFirstSix":"411111",
|
34
|
+
"CardLastFour":"1111",
|
35
|
+
"CardType":"Visa",
|
36
|
+
"CardTypeCode":0,
|
37
|
+
"IssuerBankCountry":"RU",
|
38
|
+
"Status":"Completed",
|
39
|
+
"StatusCode":3,
|
40
|
+
"Reason":"Approved",
|
41
|
+
"ReasonCode":0,
|
42
|
+
"CardHolderMessage":"Payment successful",
|
43
|
+
"Name":"CARDHOLDER NAME",
|
44
|
+
"Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0"
|
45
|
+
},
|
46
|
+
"Success":true,
|
47
|
+
"Message": null
|
48
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/post3ds'
|
4
|
+
:body: '{"TransactionId":12345,"PaRes":"eJxVUdtugkAQ"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model":{
|
9
|
+
"TransactionId":12345,
|
10
|
+
"Amount":10.0,
|
11
|
+
"Currency":"RUB",
|
12
|
+
"CurrencyCode":0,
|
13
|
+
"PaymentAmount":10.0,
|
14
|
+
"PaymentCurrency":"RUB",
|
15
|
+
"PaymentCurrencyCode":0,
|
16
|
+
"InvoiceId":"1234567",
|
17
|
+
"AccountId":"user_x",
|
18
|
+
"Email":null,
|
19
|
+
"Description":"Payment for goods on example.com",
|
20
|
+
"JsonData":null,
|
21
|
+
"CreatedDate":"\/Date(1401718880000)\/",
|
22
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
23
|
+
"TestMode":true,
|
24
|
+
"IpAddress":"195.91.194.13",
|
25
|
+
"IpCountry":"RU",
|
26
|
+
"IpCity":"Ufa",
|
27
|
+
"IpRegion":"Bashkortostan Republic",
|
28
|
+
"IpDistrict":"Volga Federal District",
|
29
|
+
"IpLatitude":54.7355,
|
30
|
+
"IpLongitude":55.991982,
|
31
|
+
"CardFirstSix":"411111",
|
32
|
+
"CardLastFour":"1111",
|
33
|
+
"CardType":"Visa",
|
34
|
+
"CardTypeCode":0,
|
35
|
+
"IssuerBankCountry":"RU",
|
36
|
+
"Status":"Declined",
|
37
|
+
"StatusCode":5,
|
38
|
+
"Reason":"InsufficientFunds",
|
39
|
+
"ReasonCode":5051, //decline code
|
40
|
+
"CardHolderMessage":"Insufficient funds on account",
|
41
|
+
"Name":"CARDHOLDER NAME"
|
42
|
+
},
|
43
|
+
"Success":false,
|
44
|
+
"Message": null
|
45
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
:request:
|
3
|
+
:url: '/payments/post3ds'
|
4
|
+
:body: '{"TransactionId":12345,"PaRes":"eJxVUdtugkAQ"}'
|
5
|
+
:response:
|
6
|
+
:body: >
|
7
|
+
{
|
8
|
+
"Model":{
|
9
|
+
"TransactionId":12345,
|
10
|
+
"Amount":10.0,
|
11
|
+
"Currency":"RUB",
|
12
|
+
"CurrencyCode":0,
|
13
|
+
"InvoiceId":"1234567",
|
14
|
+
"AccountId":"user_x",
|
15
|
+
"Email":null,
|
16
|
+
"Description":"Payment for goods on example.com",
|
17
|
+
"JsonData":null,
|
18
|
+
"CreatedDate":"\/Date(1401718880000)\/",
|
19
|
+
"CreatedDateIso":"2014-08-09T11:49:41",
|
20
|
+
"AuthDate":"\/Date(1401733880523)\/",
|
21
|
+
"AuthDateIso":"2014-08-09T11:49:42",
|
22
|
+
"ConfirmDate":"\/Date(1401733880523)\/",
|
23
|
+
"ConfirmDateIso":"2014-08-09T11:49:42",
|
24
|
+
"AuthCode":"123456",
|
25
|
+
"TestMode":true,
|
26
|
+
"IpAddress":"195.91.194.13",
|
27
|
+
"IpCountry":"RU",
|
28
|
+
"IpCity":"Ufa",
|
29
|
+
"IpRegion":"Bashkortostan Republic",
|
30
|
+
"IpDistrict":"Volga Federal District",
|
31
|
+
"IpLatitude":54.7355,
|
32
|
+
"IpLongitude":55.991982,
|
33
|
+
"CardFirstSix":"411111",
|
34
|
+
"CardLastFour":"1111",
|
35
|
+
"CardType":"Visa",
|
36
|
+
"CardTypeCode":0,
|
37
|
+
"IssuerBankCountry":"RU",
|
38
|
+
"Status":"Completed",
|
39
|
+
"StatusCode":3,
|
40
|
+
"Reason":"Approved",
|
41
|
+
"ReasonCode":0,
|
42
|
+
"CardHolderMessage":"Payment successful",
|
43
|
+
"Name":"CARDHOLDER NAME",
|
44
|
+
"Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0"
|
45
|
+
},
|
46
|
+
"Success":true,
|
47
|
+
"Message": null
|
48
|
+
}
|