pp-adaptive 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +54 -0
- data/Rakefile +8 -0
- data/lib/pp-adaptive/abstract_request.rb +44 -0
- data/lib/pp-adaptive/abstract_response.rb +46 -0
- data/lib/pp-adaptive/cancel_preapproval_request.rb +7 -0
- data/lib/pp-adaptive/cancel_preapproval_response.rb +7 -0
- data/lib/pp-adaptive/client.rb +56 -0
- data/lib/pp-adaptive/convert_currency_request.rb +33 -0
- data/lib/pp-adaptive/convert_currency_response.rb +11 -0
- data/lib/pp-adaptive/execute_payment_request.rb +9 -0
- data/lib/pp-adaptive/execute_payment_response.rb +12 -0
- data/lib/pp-adaptive/get_payment_options_request.rb +7 -0
- data/lib/pp-adaptive/get_payment_options_response.rb +32 -0
- data/lib/pp-adaptive/pay_request.rb +64 -0
- data/lib/pp-adaptive/pay_response.rb +29 -0
- data/lib/pp-adaptive/payment_details_request.rb +9 -0
- data/lib/pp-adaptive/payment_details_response.rb +53 -0
- data/lib/pp-adaptive/preapproval_details_request.rb +8 -0
- data/lib/pp-adaptive/preapproval_details_response.rb +35 -0
- data/lib/pp-adaptive/preapproval_request.rb +36 -0
- data/lib/pp-adaptive/preapproval_response.rb +7 -0
- data/lib/pp-adaptive/refund_request.rb +14 -0
- data/lib/pp-adaptive/refund_response.rb +12 -0
- data/lib/pp-adaptive/set_payment_options_request.rb +33 -0
- data/lib/pp-adaptive/set_payment_options_response.rb +7 -0
- data/lib/pp-adaptive/support/aliases.rb +33 -0
- data/lib/pp-adaptive/support/coerced_array.rb +52 -0
- data/lib/pp-adaptive/support/json_model.rb +140 -0
- data/lib/pp-adaptive/support/node.rb +45 -0
- data/lib/pp-adaptive/support/node_list.rb +45 -0
- data/lib/pp-adaptive/types/account_identifier.rb +6 -0
- data/lib/pp-adaptive/types/address.rb +17 -0
- data/lib/pp-adaptive/types/address_list.rb +5 -0
- data/lib/pp-adaptive/types/aliases/receiver_aliases.rb +15 -0
- data/lib/pp-adaptive/types/aliases/receiver_list_aliases.rb +32 -0
- data/lib/pp-adaptive/types/base_address.rb +11 -0
- data/lib/pp-adaptive/types/client_details_type.rb +12 -0
- data/lib/pp-adaptive/types/currency_code.rb +5 -0
- data/lib/pp-adaptive/types/currency_conversion.rb +17 -0
- data/lib/pp-adaptive/types/currency_conversion_list.rb +15 -0
- data/lib/pp-adaptive/types/currency_conversion_table.rb +5 -0
- data/lib/pp-adaptive/types/currency_list.rb +5 -0
- data/lib/pp-adaptive/types/currency_type.rb +6 -0
- data/lib/pp-adaptive/types/display_options.rb +8 -0
- data/lib/pp-adaptive/types/error_data.rb +11 -0
- data/lib/pp-adaptive/types/error_list.rb +5 -0
- data/lib/pp-adaptive/types/fault_message.rb +23 -0
- data/lib/pp-adaptive/types/funding_constraint.rb +5 -0
- data/lib/pp-adaptive/types/funding_plan.rb +28 -0
- data/lib/pp-adaptive/types/funding_plan_charge.rb +11 -0
- data/lib/pp-adaptive/types/funding_source.rb +9 -0
- data/lib/pp-adaptive/types/funding_type_info.rb +5 -0
- data/lib/pp-adaptive/types/funding_type_list.rb +5 -0
- data/lib/pp-adaptive/types/initiating_entity.rb +15 -0
- data/lib/pp-adaptive/types/institution_customer.rb +11 -0
- data/lib/pp-adaptive/types/invoice_data.rb +7 -0
- data/lib/pp-adaptive/types/invoice_item.rb +9 -0
- data/lib/pp-adaptive/types/pay_error.rb +18 -0
- data/lib/pp-adaptive/types/pay_error_list.rb +5 -0
- data/lib/pp-adaptive/types/payment_info.rb +16 -0
- data/lib/pp-adaptive/types/payment_info_list.rb +5 -0
- data/lib/pp-adaptive/types/phone_number_type.rb +7 -0
- data/lib/pp-adaptive/types/receiver.rb +17 -0
- data/lib/pp-adaptive/types/receiver_identifier.rb +12 -0
- data/lib/pp-adaptive/types/receiver_list.rb +5 -0
- data/lib/pp-adaptive/types/receiver_options.rb +21 -0
- data/lib/pp-adaptive/types/refund_info.rb +20 -0
- data/lib/pp-adaptive/types/refund_info_list.rb +5 -0
- data/lib/pp-adaptive/types/request_envelope.rb +6 -0
- data/lib/pp-adaptive/types/response_envelope.rb +13 -0
- data/lib/pp-adaptive/types/sender_identifier.rb +5 -0
- data/lib/pp-adaptive/types/sender_options.rb +5 -0
- data/lib/pp-adaptive/version.rb +3 -0
- data/lib/pp-adaptive.rb +75 -0
- data/pp-adaptive.gemspec +25 -0
- data/spec/public/cancel_preapproval_request_spec.rb +15 -0
- data/spec/public/cancel_preapproval_response_spec.rb +6 -0
- data/spec/public/client_spec.rb +85 -0
- data/spec/public/convert_currency_request_spec.rb +29 -0
- data/spec/public/convert_currency_response_spec.rb +62 -0
- data/spec/public/execute_payment_request_spec.rb +30 -0
- data/spec/public/execute_payment_response_spec.rb +66 -0
- data/spec/public/get_payment_options_request_spec.rb +15 -0
- data/spec/public/get_payment_options_response_spec.rb +141 -0
- data/spec/public/json_model_spec.rb +56 -0
- data/spec/public/node_list_spec.rb +58 -0
- data/spec/public/node_spec.rb +54 -0
- data/spec/public/pay_request_spec.rb +150 -0
- data/spec/public/pay_response_spec.rb +197 -0
- data/spec/public/payment_details_request_spec.rb +30 -0
- data/spec/public/payment_details_response_spec.rb +211 -0
- data/spec/public/preapproval_details_request_spec.rb +25 -0
- data/spec/public/preapproval_details_response_spec.rb +200 -0
- data/spec/public/preapproval_request_spec.rb +110 -0
- data/spec/public/preapproval_response_spec.rb +14 -0
- data/spec/public/refund_request_spec.rb +57 -0
- data/spec/public/refund_response_spec.rb +116 -0
- data/spec/public/set_payment_options_request_spec.rb +136 -0
- data/spec/public/set_payment_options_response_spec.rb +6 -0
- data/spec/shared/a_fault_message.rb +60 -0
- data/spec/shared/a_request_envelope.rb +14 -0
- data/spec/shared/a_response_envelope.rb +36 -0
- data/spec/spec_helper.rb +6 -0
- metadata +225 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::RefundResponse do
|
4
|
+
it_behaves_like "a ResponseEnvelope"
|
5
|
+
it_behaves_like "a FaultMessage"
|
6
|
+
|
7
|
+
let(:response) do
|
8
|
+
AdaptivePayments::RefundResponse.from_json(
|
9
|
+
{
|
10
|
+
:currencyCode => "GBP",
|
11
|
+
:refundInfoList => {
|
12
|
+
:refundInfo => [
|
13
|
+
{
|
14
|
+
:receiver => {
|
15
|
+
:email => "bob@site.com",
|
16
|
+
:amount => "20.00",
|
17
|
+
:invoiceId => "77"
|
18
|
+
},
|
19
|
+
:refundStatus => "Pending",
|
20
|
+
:refundNetAmount => "19.20",
|
21
|
+
:refundFeeAmount => "0.80",
|
22
|
+
:refundGrossAmount => "20.00",
|
23
|
+
:totalOfAllRefunds => "20.00",
|
24
|
+
:refundHasBecomeFull => true,
|
25
|
+
:encryptedRefundTransactionId => "abc123",
|
26
|
+
:refundTransactionStatus => "Pending",
|
27
|
+
:errorList => {
|
28
|
+
:error => [
|
29
|
+
{
|
30
|
+
:errorId => "err123",
|
31
|
+
:domain => "APPLICATION"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
:receiver => {
|
38
|
+
:amount => "10.00",
|
39
|
+
:paymentType => "DIGITALGOODS"
|
40
|
+
},
|
41
|
+
:refundStatus => "Completed"
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
}.to_json
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "maps ['currencyCode'] to #currency_code" do
|
50
|
+
response.currency_code.should == "GBP"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "maps ['refundInfoList']['refundInfo'][0]['receiver']['email'] to #refund_info.first.receiver_email" do
|
54
|
+
response.refund_info.first.receiver_email.should == "bob@site.com"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "maps ['refundInfoList']['refundInfo'][0]['receiver']['amount'] to #refund_info.first.receiver_amount" do
|
58
|
+
response.refund_info.first.receiver_amount.should == BigDecimal("20.00")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "maps ['refundInfoList']['refundInfo'][0]['receiver']['invoiceId'] to #refund_info.first.invoice_id" do
|
62
|
+
response.refund_info.first.invoice_id.should == "77"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "maps ['refundInfoList']['refundInfo'][1]['receiver']['amount'] to #refund_info.last.receiver_amount" do
|
66
|
+
response.refund_info.last.receiver_amount.should == BigDecimal("10.00")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "maps ['refundInfoList']['refundInfo'][1]['receiver']['paymentType'] to #refund_info.last.payment_type" do
|
70
|
+
response.refund_info.last.payment_type.should == "DIGITALGOODS"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundStatus'] to #refund_info.first.refund_status" do
|
74
|
+
response.refund_info.first.refund_status.should == "Pending"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "maps ['refundInfoList']['refundInfo'][1]['refundStatus'] to #refund_info.last.refund_status" do
|
78
|
+
response.refund_info.last.refund_status.should == "Completed"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundNetAmount'] to #refund_info.first.refund_net_amount" do
|
82
|
+
response.refund_info.first.refund_net_amount.should == BigDecimal("19.20")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundFeeAmount'] to #refund_info.first.refund_fee_amount" do
|
86
|
+
response.refund_info.first.refund_fee_amount.should == BigDecimal("0.80")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundGrossAmount'] to #refund_info.first.refund_gross_amount" do
|
90
|
+
response.refund_info.first.refund_gross_amount.should == BigDecimal("20.00")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "maps ['refundInfoList']['refundInfo'][0]['totalOfAllRefunds'] to #refund_info.first.total_of_all_refunds" do
|
94
|
+
response.refund_info.first.total_of_all_refunds.should == BigDecimal("20.00")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundHasBecomeFull'] to #refund_info.first.refund_has_become_full? " do
|
98
|
+
response.refund_info.first.refund_has_become_full?.should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "maps ['refundInfoList']['refundInfo'][0]['encryptedRefundTransactionId'] to #refund_info.first.encrypted_refund_transaction_id" do
|
102
|
+
response.refund_info.first.encrypted_refund_transaction_id.should == "abc123"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "maps ['refundInfoList']['refundInfo'][0]['refundTransactionStatus'] to #refund_info.first.refund_transaction_status" do
|
106
|
+
response.refund_info.first.refund_transaction_status.should == "Pending"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "maps ['refundInfoList']['refundInfo'][0]['errorList']['error'][0]['errorId'] to #refundInfo.first.errors.first.id" do
|
110
|
+
response.refund_info.first.errors.first.id.should == "err123"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "maps ['refundInfoList']['refundInfo'][0]['errorList']['error'][0]['domain'] to #refund_info.first.errors.first.domain" do
|
114
|
+
response.refund_info.first.errors.first.domain.should == "APPLICATION"
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::SetPaymentOptionsRequest do
|
4
|
+
it_behaves_like "a RequestEnvelope"
|
5
|
+
|
6
|
+
subject { AdaptivePayments::SetPaymentOptionsRequest }
|
7
|
+
its(:operation) { should == :SetPaymentOptions }
|
8
|
+
|
9
|
+
let(:request) do
|
10
|
+
AdaptivePayments::SetPaymentOptionsRequest.new(
|
11
|
+
{
|
12
|
+
:pay_key => "ABCD-1234",
|
13
|
+
:institution_id => "inst123",
|
14
|
+
:customer_first_name => "Bob",
|
15
|
+
:customer_last_name => "Cat",
|
16
|
+
:customer_display_name => "Bobcat",
|
17
|
+
:institution_customer_id => "77",
|
18
|
+
:customer_country_code => "AU",
|
19
|
+
:customer_email => "bob@site.com",
|
20
|
+
:email_header_image_url => "http://site.com/email.png",
|
21
|
+
:email_marketing_image_url => "http://site.com/marketing.png",
|
22
|
+
:header_image_url => "http://site.com/header.png",
|
23
|
+
:business_name => "Bobcats R us",
|
24
|
+
:shipping_address_id => "addr123",
|
25
|
+
:require_shipping_address_selection => true,
|
26
|
+
:receiver_options => [
|
27
|
+
{
|
28
|
+
:description => "Primary receiver",
|
29
|
+
:custom_id => "cust123",
|
30
|
+
:items => [
|
31
|
+
{
|
32
|
+
:name => "Video Game",
|
33
|
+
:identifier => "ident123",
|
34
|
+
:price => "20.00",
|
35
|
+
:item_price => "10.00",
|
36
|
+
:item_count => "2"
|
37
|
+
}
|
38
|
+
],
|
39
|
+
:total_tax => "2.00",
|
40
|
+
:total_shipping => "0.00"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:json) { JSON.parse(request.to_json) }
|
48
|
+
|
49
|
+
it "maps #pay_key to ['payKey']" do
|
50
|
+
json["payKey"].should == "ABCD-1234"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "maps #institution_id to ['initiatingEntity']['institutionCustomer']['institutionId']" do
|
54
|
+
json["initiatingEntity"]["institutionCustomer"]["institutionId"].should == "inst123"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "maps #customer_first_name to ['initiatingEntity']['institutionCustomer']['firstName']" do
|
58
|
+
json["initiatingEntity"]["institutionCustomer"]["firstName"].should == "Bob"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "maps #customer_last_name to ['initiatingEntity']['institutionCustomer']['lastName']" do
|
62
|
+
json["initiatingEntity"]["institutionCustomer"]["lastName"].should == "Cat"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "maps #customer_display_name to ['initiatingEntity']['institutionCustomer']['displayName']" do
|
66
|
+
json["initiatingEntity"]["institutionCustomer"]["displayName"].should == "Bobcat"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "maps #institution_customer_id to ['initiatingEntity']['institutionCustomer']['institutionCustomerId']" do
|
70
|
+
json["initiatingEntity"]["institutionCustomer"]["institutionCustomerId"].should == "77"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "maps #customer_country_code to ['initiatingEntity']['institutionCustomer']['countryCode']" do
|
74
|
+
json["initiatingEntity"]["institutionCustomer"]["countryCode"].should == "AU"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "maps #customer_email to ['initiatingEntity']['institutionCustomer']['email']" do
|
78
|
+
json["initiatingEntity"]["institutionCustomer"]["email"].should == "bob@site.com"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "maps #email_header_image_url to ['displayOptions']['emailHeaderImageUrl']" do
|
82
|
+
json["displayOptions"]["emailHeaderImageUrl"].should == "http://site.com/email.png"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "maps #email_marketing_image_url to ['displayOptions']['emailMarketingImageUrl']" do
|
86
|
+
json["displayOptions"]["emailMarketingImageUrl"].should == "http://site.com/marketing.png"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "maps #header_image_url to ['displayOptions']['headerImageUrl']" do
|
90
|
+
json["displayOptions"]["headerImageUrl"].should == "http://site.com/header.png"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "maps #shipping_address_id to ['shippingAddressId']" do
|
94
|
+
json["shippingAddressId"].should == "addr123"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "maps #require_shipping_address_selection? to ['senderOptions']['requireShippingAddressSelection']" do
|
98
|
+
json["senderOptions"]["requireShippingAddressSelection"].should be_true
|
99
|
+
end
|
100
|
+
|
101
|
+
it "maps #receiver_options.first.description to ['receiverOptions'][0]['description']" do
|
102
|
+
json["receiverOptions"][0]["description"].should == "Primary receiver"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "maps #receiver_options.first.custom_id to ['receiverOptions'][0]['customId']" do
|
106
|
+
json["receiverOptions"][0]["customId"].should == "cust123"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "maps #receiver_options.first.invoice_data.total_tax to ['receiverOptions'][0]['invoiceData']['totalTax']" do
|
110
|
+
json["receiverOptions"][0]["invoiceData"]["totalTax"].should == "2.00"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "maps #receiver_options.first.invoice_data.total_shipping to ['receiverOptions'][0]['invoiceData']['totalShipping']" do
|
114
|
+
json["receiverOptions"][0]["invoiceData"]["totalShipping"].should == "0.00"
|
115
|
+
end
|
116
|
+
|
117
|
+
it "maps #receiver_options.first.invoice_data.items.first.name to ['receiverOptions'][0]['invoiceData']['item'][0]['name']" do
|
118
|
+
json["receiverOptions"][0]["invoiceData"]["item"][0]["name"].should == "Video Game"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "maps #receiver_options.first.invoice_data.items.first.identifier to ['receiverOptions'][0]['invoiceData']['item'][0]['identifier']" do
|
122
|
+
json["receiverOptions"][0]["invoiceData"]["item"][0]["identifier"].should == "ident123"
|
123
|
+
end
|
124
|
+
|
125
|
+
it "maps #receiver_options.first.invoice_data.items.first.price to ['receiverOptions'][0]['invoiceData']['item'][0]['price']" do
|
126
|
+
json["receiverOptions"][0]["invoiceData"]["item"][0]["price"].should == "20.00"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "maps #receiver_options.first.invoice_data.items.first.item_price to ['receiverOptions'][0]['invoiceData']['item'][0]['itemPrice']" do
|
130
|
+
json["receiverOptions"][0]["invoiceData"]["item"][0]["itemPrice"].should == "10.00"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "maps #receiver_options.first.invoice_data.items.first.item_count to ['receiverOptions'][0]['invoiceData']['item'][0]['itemCount']" do
|
134
|
+
json["receiverOptions"][0]["invoiceData"]["item"][0]["itemCount"].should == 2
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
shared_examples "a FaultMessage" do
|
4
|
+
let(:response) do
|
5
|
+
described_class.from_json(
|
6
|
+
{
|
7
|
+
:error => [
|
8
|
+
{
|
9
|
+
:errorId => 1234,
|
10
|
+
:domain => "PLATFORM",
|
11
|
+
:subdomain => "Application",
|
12
|
+
:severity => "Error",
|
13
|
+
:category => "Application",
|
14
|
+
:message => "An error message",
|
15
|
+
:parameter => ["X-HEADER-FIELD", "X-OTHER-FIELD"]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
:errorId => 2345
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}.to_json
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "maps ['error'][0]['errorId'] to #error_id" do
|
26
|
+
response.error_id.should == 1234
|
27
|
+
end
|
28
|
+
|
29
|
+
it "maps ['error'][0]['domain'] to #error_domain" do
|
30
|
+
response.error_domain.should == "PLATFORM"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "maps ['error'][0]['subdomain'] to #error_subdomain" do
|
34
|
+
response.error_subdomain.should == "Application"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "maps ['error'][0]['severity'] to #error_severity" do
|
38
|
+
response.error_severity.should == "Error"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "maps ['error'][0]['category'] to #error_category" do
|
42
|
+
response.error_category.should == "Application"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "maps ['error'][0]['message'] to #error_message" do
|
46
|
+
response.error_message.should == "An error message"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "maps ['error'][0]['parameter'][0] to #error_parameters.first" do
|
50
|
+
response.error_parameters.first.should == "X-HEADER-FIELD"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "maps ['error'][0]['parameter'][1] to #error_parameters.last" do
|
54
|
+
response.error_parameters.last.should == "X-OTHER-FIELD"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "allows access to additional errors via #errors" do
|
58
|
+
response.errors.last.id.should == 2345
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
shared_examples "a RequestEnvelope" do
|
4
|
+
let(:request) { described_class.new(:detail_level => "ReturnAll") }
|
5
|
+
let(:json) { JSON.parse(request.to_json) }
|
6
|
+
|
7
|
+
it "maps #detail_level to ['requestEnvelope']['detailLevel']" do
|
8
|
+
json["requestEnvelope"]["detailLevel"].should == "ReturnAll"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "includes 'en_US' as the ['errorLanguage']" do
|
12
|
+
json["requestEnvelope"]["errorLanguage"].should == "en_US"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
shared_examples "a ResponseEnvelope" do
|
4
|
+
let(:response) do
|
5
|
+
described_class.from_json(
|
6
|
+
{
|
7
|
+
:responseEnvelope => {
|
8
|
+
:ack => "Success",
|
9
|
+
:build => "123456",
|
10
|
+
:timestamp => "2011-09-21T00:00:00+00:00",
|
11
|
+
:correlationId => "1234"
|
12
|
+
}
|
13
|
+
}.to_json
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "maps ['responseEnvelope']['ack'] to #ack_code" do #
|
18
|
+
response.ack_code.should == "Success"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "maps ['responseEnvelope']['build'] to #build" do
|
22
|
+
response.build.should == "123456"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "maps ['responseEnvelope']['timestamp'] to #time" do
|
26
|
+
response.time.should == DateTime.new(2011, 9, 21)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "maps ['responseEnvelope']['correlationId'] to #correlation_id" do
|
30
|
+
response.correlation_id.should == "1234"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "provides predicate methods for the ack code" do
|
34
|
+
response.success?.should be_true
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pp-adaptive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- d11wtq
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &70143741610300 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70143741610300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: virtus
|
27
|
+
requirement: &70143741609800 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.0.9
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70143741609800
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: &70143741609380 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70143741609380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &70143741608840 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70143741608840
|
58
|
+
description: Currently provides just a subset of PayPal's API, for setting up preapproval
|
59
|
+
agreements and taking payments
|
60
|
+
email:
|
61
|
+
- chris@w3style.co.uk
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- .rspec
|
68
|
+
- Gemfile
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/pp-adaptive.rb
|
72
|
+
- lib/pp-adaptive/abstract_request.rb
|
73
|
+
- lib/pp-adaptive/abstract_response.rb
|
74
|
+
- lib/pp-adaptive/cancel_preapproval_request.rb
|
75
|
+
- lib/pp-adaptive/cancel_preapproval_response.rb
|
76
|
+
- lib/pp-adaptive/client.rb
|
77
|
+
- lib/pp-adaptive/convert_currency_request.rb
|
78
|
+
- lib/pp-adaptive/convert_currency_response.rb
|
79
|
+
- lib/pp-adaptive/execute_payment_request.rb
|
80
|
+
- lib/pp-adaptive/execute_payment_response.rb
|
81
|
+
- lib/pp-adaptive/get_payment_options_request.rb
|
82
|
+
- lib/pp-adaptive/get_payment_options_response.rb
|
83
|
+
- lib/pp-adaptive/pay_request.rb
|
84
|
+
- lib/pp-adaptive/pay_response.rb
|
85
|
+
- lib/pp-adaptive/payment_details_request.rb
|
86
|
+
- lib/pp-adaptive/payment_details_response.rb
|
87
|
+
- lib/pp-adaptive/preapproval_details_request.rb
|
88
|
+
- lib/pp-adaptive/preapproval_details_response.rb
|
89
|
+
- lib/pp-adaptive/preapproval_request.rb
|
90
|
+
- lib/pp-adaptive/preapproval_response.rb
|
91
|
+
- lib/pp-adaptive/refund_request.rb
|
92
|
+
- lib/pp-adaptive/refund_response.rb
|
93
|
+
- lib/pp-adaptive/set_payment_options_request.rb
|
94
|
+
- lib/pp-adaptive/set_payment_options_response.rb
|
95
|
+
- lib/pp-adaptive/support/aliases.rb
|
96
|
+
- lib/pp-adaptive/support/coerced_array.rb
|
97
|
+
- lib/pp-adaptive/support/json_model.rb
|
98
|
+
- lib/pp-adaptive/support/node.rb
|
99
|
+
- lib/pp-adaptive/support/node_list.rb
|
100
|
+
- lib/pp-adaptive/types/account_identifier.rb
|
101
|
+
- lib/pp-adaptive/types/address.rb
|
102
|
+
- lib/pp-adaptive/types/address_list.rb
|
103
|
+
- lib/pp-adaptive/types/aliases/receiver_aliases.rb
|
104
|
+
- lib/pp-adaptive/types/aliases/receiver_list_aliases.rb
|
105
|
+
- lib/pp-adaptive/types/base_address.rb
|
106
|
+
- lib/pp-adaptive/types/client_details_type.rb
|
107
|
+
- lib/pp-adaptive/types/currency_code.rb
|
108
|
+
- lib/pp-adaptive/types/currency_conversion.rb
|
109
|
+
- lib/pp-adaptive/types/currency_conversion_list.rb
|
110
|
+
- lib/pp-adaptive/types/currency_conversion_table.rb
|
111
|
+
- lib/pp-adaptive/types/currency_list.rb
|
112
|
+
- lib/pp-adaptive/types/currency_type.rb
|
113
|
+
- lib/pp-adaptive/types/display_options.rb
|
114
|
+
- lib/pp-adaptive/types/error_data.rb
|
115
|
+
- lib/pp-adaptive/types/error_list.rb
|
116
|
+
- lib/pp-adaptive/types/fault_message.rb
|
117
|
+
- lib/pp-adaptive/types/funding_constraint.rb
|
118
|
+
- lib/pp-adaptive/types/funding_plan.rb
|
119
|
+
- lib/pp-adaptive/types/funding_plan_charge.rb
|
120
|
+
- lib/pp-adaptive/types/funding_source.rb
|
121
|
+
- lib/pp-adaptive/types/funding_type_info.rb
|
122
|
+
- lib/pp-adaptive/types/funding_type_list.rb
|
123
|
+
- lib/pp-adaptive/types/initiating_entity.rb
|
124
|
+
- lib/pp-adaptive/types/institution_customer.rb
|
125
|
+
- lib/pp-adaptive/types/invoice_data.rb
|
126
|
+
- lib/pp-adaptive/types/invoice_item.rb
|
127
|
+
- lib/pp-adaptive/types/pay_error.rb
|
128
|
+
- lib/pp-adaptive/types/pay_error_list.rb
|
129
|
+
- lib/pp-adaptive/types/payment_info.rb
|
130
|
+
- lib/pp-adaptive/types/payment_info_list.rb
|
131
|
+
- lib/pp-adaptive/types/phone_number_type.rb
|
132
|
+
- lib/pp-adaptive/types/receiver.rb
|
133
|
+
- lib/pp-adaptive/types/receiver_identifier.rb
|
134
|
+
- lib/pp-adaptive/types/receiver_list.rb
|
135
|
+
- lib/pp-adaptive/types/receiver_options.rb
|
136
|
+
- lib/pp-adaptive/types/refund_info.rb
|
137
|
+
- lib/pp-adaptive/types/refund_info_list.rb
|
138
|
+
- lib/pp-adaptive/types/request_envelope.rb
|
139
|
+
- lib/pp-adaptive/types/response_envelope.rb
|
140
|
+
- lib/pp-adaptive/types/sender_identifier.rb
|
141
|
+
- lib/pp-adaptive/types/sender_options.rb
|
142
|
+
- lib/pp-adaptive/version.rb
|
143
|
+
- pp-adaptive.gemspec
|
144
|
+
- spec/public/cancel_preapproval_request_spec.rb
|
145
|
+
- spec/public/cancel_preapproval_response_spec.rb
|
146
|
+
- spec/public/client_spec.rb
|
147
|
+
- spec/public/convert_currency_request_spec.rb
|
148
|
+
- spec/public/convert_currency_response_spec.rb
|
149
|
+
- spec/public/execute_payment_request_spec.rb
|
150
|
+
- spec/public/execute_payment_response_spec.rb
|
151
|
+
- spec/public/get_payment_options_request_spec.rb
|
152
|
+
- spec/public/get_payment_options_response_spec.rb
|
153
|
+
- spec/public/json_model_spec.rb
|
154
|
+
- spec/public/node_list_spec.rb
|
155
|
+
- spec/public/node_spec.rb
|
156
|
+
- spec/public/pay_request_spec.rb
|
157
|
+
- spec/public/pay_response_spec.rb
|
158
|
+
- spec/public/payment_details_request_spec.rb
|
159
|
+
- spec/public/payment_details_response_spec.rb
|
160
|
+
- spec/public/preapproval_details_request_spec.rb
|
161
|
+
- spec/public/preapproval_details_response_spec.rb
|
162
|
+
- spec/public/preapproval_request_spec.rb
|
163
|
+
- spec/public/preapproval_response_spec.rb
|
164
|
+
- spec/public/refund_request_spec.rb
|
165
|
+
- spec/public/refund_response_spec.rb
|
166
|
+
- spec/public/set_payment_options_request_spec.rb
|
167
|
+
- spec/public/set_payment_options_response_spec.rb
|
168
|
+
- spec/shared/a_fault_message.rb
|
169
|
+
- spec/shared/a_request_envelope.rb
|
170
|
+
- spec/shared/a_response_envelope.rb
|
171
|
+
- spec/spec_helper.rb
|
172
|
+
homepage: https://github.com/
|
173
|
+
licenses: []
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - ! '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
requirements: []
|
191
|
+
rubyforge_project: pp-adaptive
|
192
|
+
rubygems_version: 1.8.11
|
193
|
+
signing_key:
|
194
|
+
specification_version: 3
|
195
|
+
summary: Rubygem for working with PayPal's Adaptive Payments API
|
196
|
+
test_files:
|
197
|
+
- spec/public/cancel_preapproval_request_spec.rb
|
198
|
+
- spec/public/cancel_preapproval_response_spec.rb
|
199
|
+
- spec/public/client_spec.rb
|
200
|
+
- spec/public/convert_currency_request_spec.rb
|
201
|
+
- spec/public/convert_currency_response_spec.rb
|
202
|
+
- spec/public/execute_payment_request_spec.rb
|
203
|
+
- spec/public/execute_payment_response_spec.rb
|
204
|
+
- spec/public/get_payment_options_request_spec.rb
|
205
|
+
- spec/public/get_payment_options_response_spec.rb
|
206
|
+
- spec/public/json_model_spec.rb
|
207
|
+
- spec/public/node_list_spec.rb
|
208
|
+
- spec/public/node_spec.rb
|
209
|
+
- spec/public/pay_request_spec.rb
|
210
|
+
- spec/public/pay_response_spec.rb
|
211
|
+
- spec/public/payment_details_request_spec.rb
|
212
|
+
- spec/public/payment_details_response_spec.rb
|
213
|
+
- spec/public/preapproval_details_request_spec.rb
|
214
|
+
- spec/public/preapproval_details_response_spec.rb
|
215
|
+
- spec/public/preapproval_request_spec.rb
|
216
|
+
- spec/public/preapproval_response_spec.rb
|
217
|
+
- spec/public/refund_request_spec.rb
|
218
|
+
- spec/public/refund_response_spec.rb
|
219
|
+
- spec/public/set_payment_options_request_spec.rb
|
220
|
+
- spec/public/set_payment_options_response_spec.rb
|
221
|
+
- spec/shared/a_fault_message.rb
|
222
|
+
- spec/shared/a_request_envelope.rb
|
223
|
+
- spec/shared/a_response_envelope.rb
|
224
|
+
- spec/spec_helper.rb
|
225
|
+
has_rdoc:
|