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,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PaymentDetailsRequest do
|
4
|
+
it_behaves_like "a RequestEnvelope"
|
5
|
+
|
6
|
+
subject { AdaptivePayments::PaymentDetailsRequest }
|
7
|
+
its(:operation) { should == :PaymentDetails }
|
8
|
+
|
9
|
+
let(:request) do
|
10
|
+
AdaptivePayments::PaymentDetailsRequest.new(
|
11
|
+
:pay_key => "ABCDEFG-1234",
|
12
|
+
:transaction_id => "PPX-123ABC",
|
13
|
+
:tracking_id => "personal.id"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:json) { JSON.parse(request.to_json) }
|
18
|
+
|
19
|
+
it "maps #pay_key to ['payKey']" do
|
20
|
+
json["payKey"].should == "ABCDEFG-1234"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "maps #transaction_id to ['transactionId']" do
|
24
|
+
json["transactionId"].should == "PPX-123ABC"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "maps #tracking_id to ['trackingId']" do
|
28
|
+
json["trackingId"].should == "personal.id"
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PaymentDetailsResponse do
|
4
|
+
it_behaves_like "a ResponseEnvelope"
|
5
|
+
it_behaves_like "a FaultMessage"
|
6
|
+
|
7
|
+
let(:response) do
|
8
|
+
AdaptivePayments::PaymentDetailsResponse.from_json(
|
9
|
+
{
|
10
|
+
:cancelUrl => "http://site.com/cancelled",
|
11
|
+
:returnUrl => "http://site.com/success",
|
12
|
+
:ipnNotificationUrl => "http://site.com/ipn",
|
13
|
+
:memo => "a note to self",
|
14
|
+
:currencyCode => "AUD",
|
15
|
+
:paymentInfoList => {
|
16
|
+
:paymentInfo => [
|
17
|
+
{
|
18
|
+
:transactionId => "ABC123",
|
19
|
+
:transactionStatus => "Completed",
|
20
|
+
:receiver => {
|
21
|
+
:email => "bob@site.com",
|
22
|
+
:amount => "20.00",
|
23
|
+
:paymentType => "DIGITALGOODS",
|
24
|
+
:paymentSubType => "SOFTWARE",
|
25
|
+
:invoiceId => "77"
|
26
|
+
},
|
27
|
+
:refundedAmount => "0.00",
|
28
|
+
:pendingRefund => true,
|
29
|
+
:senderTransactionId => "66",
|
30
|
+
:senderTransactionStatus => "Completed",
|
31
|
+
:pendingReason => "none"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
:transactionId => "ABC456",
|
35
|
+
:transactionStatus => "Pending",
|
36
|
+
:receiver => {
|
37
|
+
:email => "another@site.com",
|
38
|
+
:amount => "10.00",
|
39
|
+
},
|
40
|
+
:pendingReason => "anything"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
},
|
44
|
+
:status => "Completed",
|
45
|
+
:trackingId => "tracking123",
|
46
|
+
:payKey => "pay123",
|
47
|
+
:actionType => "PAY",
|
48
|
+
:feesPayer => "SENDER",
|
49
|
+
:reverseAllParallelPaymentsOnError => true,
|
50
|
+
:preapprovalKey => "PREAPP123",
|
51
|
+
:fundingConstraint => {
|
52
|
+
:allowedFundingType => {
|
53
|
+
:fundingTypeInfo => [
|
54
|
+
{
|
55
|
+
:fundingType => "CREDITCARD"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
:fundingType => "BALANCE"
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}
|
62
|
+
},
|
63
|
+
:sender => {
|
64
|
+
:email => "sender@site.com",
|
65
|
+
:useCredentials => false,
|
66
|
+
:phone => {
|
67
|
+
:countryCode => "1",
|
68
|
+
:phoneNumber => "456789123",
|
69
|
+
:extension => "444"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}.to_json
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "maps ['cancelUrl'] to #cancel_url" do
|
77
|
+
response.cancel_url.should == "http://site.com/cancelled"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "maps ['returnUrl'] to #return_url" do
|
81
|
+
response.return_url.should == "http://site.com/success"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "maps ['ipnNotificationUrl'] to #ipn_notification_url" do
|
85
|
+
response.ipn_notification_url.should == "http://site.com/ipn"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "maps ['memo'] to #memo" do
|
89
|
+
response.memo.should == "a note to self"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "maps ['currencyCode'] to #currencyCode" do
|
93
|
+
response.currency_code.should == "AUD"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['transactionId'] to #payments.first.transaction_id" do
|
97
|
+
response.payments.first.transaction_id.should == "ABC123"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['transactionStatus'] to #payments.first.transaction_status" do
|
101
|
+
response.payments.first.transaction_status.should == "Completed"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['receiver']['email'] to #payments.first.receiver_email" do
|
105
|
+
response.payments.first.receiver_email.should == "bob@site.com"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['receiver']['amount'] to #payments.first.receiver_amount" do
|
109
|
+
response.payments.first.receiver_amount.should == BigDecimal("20.00")
|
110
|
+
end
|
111
|
+
|
112
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['receiver']['paymentType'] to #payments.first.payment_type" do
|
113
|
+
response.payments.first.payment_type.should == "DIGITALGOODS"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['receiver']['paymentSubType'] to #payments.first.payment_subtype" do
|
117
|
+
response.payments.first.payment_subtype.should == "SOFTWARE"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['receiver']['invoiceId'] to #payments.first.invoice_id" do
|
121
|
+
response.payments.first.invoice_id.should == "77"
|
122
|
+
end
|
123
|
+
|
124
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['refundedAmount'] to #payments.first.refunded_amount" do
|
125
|
+
response.payments.first.refunded_amount.should == BigDecimal("0.00")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['pendingRefund'] to #payments.first.pending_refund? " do
|
129
|
+
response.payments.first.should be_pending_refund
|
130
|
+
end
|
131
|
+
|
132
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['senderTransactionId'] to #payments.first.sender_transaction_id" do
|
133
|
+
response.payments.first.sender_transaction_id.should == "66"
|
134
|
+
end
|
135
|
+
|
136
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['senderTransactionStatus'] to #payments.first.sender_transaction_status" do
|
137
|
+
response.payments.first.sender_transaction_status.should == "Completed"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "maps ['paymentInfoList']['paymentInfo'][0]['pendingReason'] to #payments.first.pending_reason" do
|
141
|
+
response.payments.first.pending_reason.should == "none"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "maps ['paymentInfoList']['paymentInfo'][1]['transactionId'] to #payments.last.transaction_id" do
|
145
|
+
response.payments.last.transaction_id.should == "ABC456"
|
146
|
+
end
|
147
|
+
|
148
|
+
it "maps ['paymentInfoList']['paymentInfo'][1]['transactionStatus'] to #payments.last.transaction_status" do
|
149
|
+
response.payments.last.transaction_status.should == "Pending"
|
150
|
+
end
|
151
|
+
|
152
|
+
it "maps ['paymentInfoList']['paymentInfo'][1]['receiver']['email'] to #payments.last.receiver_email" do
|
153
|
+
response.payments.last.receiver_email.should == "another@site.com"
|
154
|
+
end
|
155
|
+
|
156
|
+
it "maps ['status'] to #status" do
|
157
|
+
response.status.should == "Completed"
|
158
|
+
end
|
159
|
+
|
160
|
+
it "maps ['trackingId'] to #tracking_id" do
|
161
|
+
response.tracking_id.should == "tracking123"
|
162
|
+
end
|
163
|
+
|
164
|
+
it "maps ['payKey'] to #pay_key" do
|
165
|
+
response.pay_key.should == "pay123"
|
166
|
+
end
|
167
|
+
|
168
|
+
it "maps ['actionType'] to #actionType" do
|
169
|
+
response.action_type.should == "PAY"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "maps ['feesPayer'] to #fees_payer" do
|
173
|
+
response.fees_payer.should == "SENDER"
|
174
|
+
end
|
175
|
+
|
176
|
+
it "maps ['reverseAllParallelPaymentsOnError'] to #reverse_parallel_payments_on_error? " do
|
177
|
+
response.reverse_parallel_payments_on_error?.should be_true
|
178
|
+
end
|
179
|
+
|
180
|
+
it "maps ['preapprovalKey'] to #preapproval_key" do
|
181
|
+
response.preapproval_key.should == "PREAPP123"
|
182
|
+
end
|
183
|
+
|
184
|
+
it "maps ['fundingConstraint']['allowedFundingType']['fundingTypeInfo'][0]['fundingType'] to #allowed_funding_types.first" do
|
185
|
+
response.allowed_funding_types.first.should == "CREDITCARD"
|
186
|
+
end
|
187
|
+
|
188
|
+
it "maps ['fundingConstraint']['allowedFundingType']['fundingTypeInfo'][1]['fundingType'] to #allowed_funding_types.last" do
|
189
|
+
response.allowed_funding_types.last.should == "BALANCE"
|
190
|
+
end
|
191
|
+
|
192
|
+
it "maps ['sender']['email'] to #sender_email" do
|
193
|
+
response.sender_email.should == "sender@site.com"
|
194
|
+
end
|
195
|
+
|
196
|
+
it "maps ['sender']['useCredentials'] to #use_sender_credentials? " do
|
197
|
+
response.use_sender_credentials?.should be_false
|
198
|
+
end
|
199
|
+
|
200
|
+
it "maps ['sender']['phone']['countryCode'] to #sender_phone_country_code" do
|
201
|
+
response.sender_phone_country_code.should == "1"
|
202
|
+
end
|
203
|
+
|
204
|
+
it "maps ['sender']['phone']['phoneNumber'] to #sender_phone_number" do
|
205
|
+
response.sender_phone_number.should == "456789123"
|
206
|
+
end
|
207
|
+
|
208
|
+
it "maps ['sender']['phone']['extension'] to #sender_phone_extension" do
|
209
|
+
response.sender_phone_extension.should == "444"
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PreapprovalDetailsRequest do
|
4
|
+
it_behaves_like "a RequestEnvelope"
|
5
|
+
|
6
|
+
subject { AdaptivePayments::PreapprovalDetailsRequest }
|
7
|
+
its(:operation) { should == :PreapprovalDetails }
|
8
|
+
|
9
|
+
let(:request) do
|
10
|
+
AdaptivePayments::PreapprovalDetailsRequest.new(
|
11
|
+
:preapproval_key => "ABCDEFG-1234",
|
12
|
+
:get_billing_address => true
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:json) { JSON.parse(request.to_json) }
|
17
|
+
|
18
|
+
it "maps #preapproval_key to ['preapprovalKey']" do
|
19
|
+
json["preapprovalKey"].should == "ABCDEFG-1234"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "maps #get_billing_address to ['getBillingAddress']" do
|
23
|
+
json["getBillingAddress"].should == true
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PreapprovalDetailsResponse do
|
4
|
+
it_behaves_like "a ResponseEnvelope"
|
5
|
+
it_behaves_like "a FaultMessage"
|
6
|
+
|
7
|
+
let(:response) do
|
8
|
+
AdaptivePayments::PreapprovalDetailsResponse.from_json(
|
9
|
+
{
|
10
|
+
:approved => false,
|
11
|
+
:cancelUrl => "http://site.com/cancelled",
|
12
|
+
:returnUrl => "http://site.com/success",
|
13
|
+
:ipnNotificationUrl => "http://site.com/ipn",
|
14
|
+
:currencyCode => "USD",
|
15
|
+
:maxTotalAmountOfAllPayments => "680.00",
|
16
|
+
:startingDate => "2011-09-22T12:37:07+00:00",
|
17
|
+
:endingDate => "2012-09-22T12:37:07+00:00",
|
18
|
+
:maxAmountPerPayment => "60.00",
|
19
|
+
:paymentPeriod => "MONTHLY",
|
20
|
+
:curPayments => 2,
|
21
|
+
:curPaymentsAmount => "100.00",
|
22
|
+
:curPeriodAttempts => 1,
|
23
|
+
:curPeriodEndingDate => "2011-09-30T12:37:07+00:00",
|
24
|
+
:dateOfMonth => 15,
|
25
|
+
:dayOfWeek => "FRIDAY",
|
26
|
+
:pinType => "NOT_REQUIRED",
|
27
|
+
:senderEmail => "bob@gmail.com",
|
28
|
+
:memo => "some memo",
|
29
|
+
:status => "ACTIVE",
|
30
|
+
:feesPayer => "SENDER",
|
31
|
+
:displayMaxTotalAmount => true,
|
32
|
+
:addressList => {
|
33
|
+
:address => [
|
34
|
+
{
|
35
|
+
:addressId => "abc123",
|
36
|
+
:addressee_name => "Bob Cat",
|
37
|
+
:base_address => {
|
38
|
+
:line1 => "56 Bobcat St",
|
39
|
+
:line2 => "Some estate",
|
40
|
+
:city => "Bobcaton",
|
41
|
+
:state => "BCT",
|
42
|
+
:postal_code => "BC1 BC2",
|
43
|
+
:country_code => "BC",
|
44
|
+
:type => "Home"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
{
|
48
|
+
:addressId => "abc456",
|
49
|
+
:addressee_name => "Pete Mouse",
|
50
|
+
:base_address => {
|
51
|
+
:line1 => "2 Le Hole",
|
52
|
+
:city => "Cheese City",
|
53
|
+
:state => "MCT",
|
54
|
+
:postal_code => "3000",
|
55
|
+
:country_code => "MM",
|
56
|
+
:type => "Business"
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
}.to_json
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "maps ['approved'] to #approved" do
|
66
|
+
response.approved.should be_false
|
67
|
+
end
|
68
|
+
|
69
|
+
it "maps ['cancelUrl'] to #cancel_url" do
|
70
|
+
response.cancel_url.should == "http://site.com/cancelled"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "maps ['returnUrl'] to #return_url" do
|
74
|
+
response.return_url.should == "http://site.com/success"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "maps ['ipnNotificationUrl'] to #ipn_notification_url" do
|
78
|
+
response.ipn_notification_url.should == "http://site.com/ipn"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "maps ['currencyCode'] to #currency_code" do
|
82
|
+
response.currency_code.should == "USD"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "maps ['maxTotalAmountOfAllPayments'] to #max_total_amount" do
|
86
|
+
response.max_total_amount.should == BigDecimal('680.00')
|
87
|
+
end
|
88
|
+
|
89
|
+
it "maps ['startingDate'] to #starting_date" do
|
90
|
+
response.starting_date.should == DateTime.new(2011, 9, 22, 12, 37, 7)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "maps ['endingDate'] to #ending_date" do
|
94
|
+
response.ending_date.should == DateTime.new(2012, 9, 22, 12, 37, 7)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "maps ['maxAmountPerPayment'] to #max_amount_per_payment" do
|
98
|
+
response.max_amount_per_payment.should == BigDecimal('60.00')
|
99
|
+
end
|
100
|
+
|
101
|
+
it "maps ['paymentPeriod'] to #payment_period" do
|
102
|
+
response.payment_period.should == "MONTHLY"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "maps ['curPayments'] to #current_payments" do
|
106
|
+
response.current_payments.should == 2
|
107
|
+
end
|
108
|
+
|
109
|
+
it "maps ['curPaymentsAmount'] to #current_payments_amount" do
|
110
|
+
response.current_payments_amount.should == BigDecimal('100.00')
|
111
|
+
end
|
112
|
+
|
113
|
+
it "maps ['curPeriodAttempts'] to #current_period_attempts" do
|
114
|
+
response.current_period_attempts.should == 1
|
115
|
+
end
|
116
|
+
|
117
|
+
it "maps ['curPeriodEndingDate'] to #current_period_ending_date" do
|
118
|
+
response.current_period_ending_date.should == DateTime.new(2011, 9, 30, 12, 37, 7)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "maps ['dateOfMonth'] to #date_of_month" do
|
122
|
+
response.date_of_month.should == 15
|
123
|
+
end
|
124
|
+
|
125
|
+
it "maps ['dayOfWeek'] to #day_of_week" do
|
126
|
+
response.day_of_week.should == "FRIDAY"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "maps ['pinType'] to #pin_type" do
|
130
|
+
response.pin_type.should == "NOT_REQUIRED"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "maps ['senderEmail'] to #sender_email" do
|
134
|
+
response.sender_email.should == "bob@gmail.com"
|
135
|
+
end
|
136
|
+
|
137
|
+
it "maps ['memo'] to #memo" do
|
138
|
+
response.memo.should == "some memo"
|
139
|
+
end
|
140
|
+
|
141
|
+
it "maps ['status'] to #status" do
|
142
|
+
response.status.should == "ACTIVE"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "maps ['feesPayer'] to #fees_payer" do
|
146
|
+
response.fees_payer.should == "SENDER"
|
147
|
+
end
|
148
|
+
|
149
|
+
it "maps ['displayMaxTotalAmount'] to #display_max_total_amount? " do
|
150
|
+
response.display_max_total_amount.should be_true
|
151
|
+
end
|
152
|
+
|
153
|
+
it "maps ['addressList']['address'][0]['addressId'] to #addresses.first.id" do
|
154
|
+
response.addresses.first.id.should == "abc123"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "maps ['addressList']['address'][0]['addresseeName'] to #addresses.first.addressee_name" do
|
158
|
+
response.addresses.first.addressee_name.should == "Bob Cat"
|
159
|
+
end
|
160
|
+
|
161
|
+
it "maps ['addressList']['address'][0]['baseAddress']['line1'] to #addresses.first.line1" do
|
162
|
+
response.addresses.first.line1.should == "56 Bobcat St"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "maps ['addressList']['address'][0]['baseAddress']['line2'] to #addresses.first.line2" do
|
166
|
+
response.addresses.first.line2.should == "Some estate"
|
167
|
+
end
|
168
|
+
|
169
|
+
it "maps ['addressList']['address'][0]['baseAddress']['city'] to #addresses.first.city" do
|
170
|
+
response.addresses.first.city.should == "Bobcaton"
|
171
|
+
end
|
172
|
+
|
173
|
+
it "maps ['addressList']['address'][0]['baseAddress']['state'] to #addresses.first.state" do
|
174
|
+
response.addresses.first.state.should == "BCT"
|
175
|
+
end
|
176
|
+
|
177
|
+
it "maps ['addressList']['address'][0]['baseAddress']['postalCode'] to #addresses.first.postal_code" do
|
178
|
+
response.addresses.first.postal_code.should == "BC1 BC2"
|
179
|
+
end
|
180
|
+
|
181
|
+
it "maps ['addressList']['address'][0]['baseAddress']['countryCode'] to #addresses.first.country_code" do
|
182
|
+
response.addresses.first.country_code.should == "BC"
|
183
|
+
end
|
184
|
+
|
185
|
+
it "maps ['addressList']['address'][0]['baseAddress']['type'] to #addresses.first.type" do
|
186
|
+
response.addresses.first.type.should == "Home"
|
187
|
+
end
|
188
|
+
|
189
|
+
it "maps ['addressList']['address'][1]['addressId'] to #addresses.last.id" do
|
190
|
+
response.addresses.last.id.should == "abc456"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "maps ['addressList']['address'][1]['addresseeName'] to #addresses.last.addressee_name" do
|
194
|
+
response.addresses.last.addressee_name.should == "Pete Mouse"
|
195
|
+
end
|
196
|
+
|
197
|
+
it "maps ['addressList']['address'][1]['baseAddress']['line1'] to #addresses.last.line1" do
|
198
|
+
response.addresses.last.line1.should == "2 Le Hole"
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PreapprovalRequest do
|
4
|
+
it_behaves_like "a RequestEnvelope"
|
5
|
+
|
6
|
+
subject { AdaptivePayments::PreapprovalRequest }
|
7
|
+
its(:operation) { should == :Preapproval }
|
8
|
+
|
9
|
+
let(:request) do
|
10
|
+
AdaptivePayments::PreapprovalRequest.new(
|
11
|
+
:ending_date => DateTime.new(2011, 9, 20, 7, 57, 2, Rational(10, 24)),
|
12
|
+
:starting_date => DateTime.new(2011, 9, 20, 7, 49, 2, Rational(5, 24)),
|
13
|
+
:max_total_amount => 720,
|
14
|
+
:currency_code => "USD",
|
15
|
+
:cancel_url => "http://site.com/cancelled",
|
16
|
+
:return_url => "http://site.com/succeeded",
|
17
|
+
:ipn_notification_url => "http://site.com/ipn",
|
18
|
+
:date_of_month => 15,
|
19
|
+
:day_of_week => "friday",
|
20
|
+
:max_amount_per_payment => 60,
|
21
|
+
:max_payments => 12,
|
22
|
+
:max_payments_per_period => 1,
|
23
|
+
:payment_period => "monthly",
|
24
|
+
:memo => "some memo",
|
25
|
+
:sender_email => "sender@site.com",
|
26
|
+
:pin_type => "required",
|
27
|
+
:fees_payer => "sender",
|
28
|
+
:display_max_total_amount => false
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:json) { JSON.parse(request.to_json) }
|
33
|
+
|
34
|
+
it "maps #ending_date to ['endingDate']" do
|
35
|
+
json["endingDate"].should == "2011-09-20T07:57:02+10:00"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "maps #starting_date to ['startingDate']" do
|
39
|
+
json["startingDate"].should == "2011-09-20T07:49:02+05:00"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "maps #max_total_amount to ['maxTotalAmountOfAllPayments']" do
|
43
|
+
json["maxTotalAmountOfAllPayments"].should == "720.00"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "maps #currency_code to ['currencyCode']" do
|
47
|
+
json["currencyCode"].should == "USD"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "maps #cancel_url to ['cancelUrl']" do
|
51
|
+
json["cancelUrl"].should == "http://site.com/cancelled"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "maps #return_url to ['returnUrl']" do
|
55
|
+
json["returnUrl"].should == "http://site.com/succeeded"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "maps #ipn_notification_url to ['ipnNotificationUrl']" do
|
59
|
+
json["ipnNotificationUrl"].should == "http://site.com/ipn"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "maps #date_of_month to ['dateOfMonth']" do
|
63
|
+
json["dateOfMonth"].should == 15
|
64
|
+
end
|
65
|
+
|
66
|
+
it "maps #day_of_week to ['dayOfWeek']" do
|
67
|
+
json["dayOfWeek"].should == "friday"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "maps #max_amount_per_payment to ['maxAmountPerPayment']" do
|
71
|
+
json["maxAmountPerPayment"].should == "60.00"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "maps #max_payments to ['maxNumberOfPayments']" do
|
75
|
+
json["maxNumberOfPayments"].should == 12
|
76
|
+
end
|
77
|
+
|
78
|
+
it "maps #max_payments_per_period to ['maxNumberOfPaymentsPerPeriod']" do
|
79
|
+
json["maxNumberOfPaymentsPerPeriod"].should == 1
|
80
|
+
end
|
81
|
+
|
82
|
+
it "maps #payment_period to ['paymentPeriod']" do
|
83
|
+
json["paymentPeriod"].should == "monthly"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "maps #memo to ['memo']" do
|
87
|
+
json["memo"].should == "some memo"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "maps #sender_email to ['senderEmail']" do
|
91
|
+
json["senderEmail"].should == "sender@site.com"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "maps #pin_type to ['pinType']" do
|
95
|
+
json["pinType"].should == "required"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "maps #fees_payer to ['feesPayer']" do
|
99
|
+
json["feesPayer"].should == "sender"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "maps #display_max_total_amount to ['displayMaxTotalAmount']" do
|
103
|
+
json["displayMaxTotalAmount"].should == false
|
104
|
+
end
|
105
|
+
|
106
|
+
it "does not include omitted parameters" do
|
107
|
+
request.max_amount_per_payment = nil
|
108
|
+
json.should_not have_key("maxAmountPerPayment")
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::PreapprovalResponse do
|
4
|
+
it_behaves_like "a ResponseEnvelope"
|
5
|
+
it_behaves_like "a FaultMessage"
|
6
|
+
|
7
|
+
let(:response) do
|
8
|
+
AdaptivePayments::PreapprovalResponse.from_json('{"preapprovalKey":"SOME-KEY"}')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "maps ['preapprovalKey'] to #preapproval_key" do
|
12
|
+
response.preapproval_key.should == "SOME-KEY"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe AdaptivePayments::RefundRequest do
|
4
|
+
it_behaves_like "a RequestEnvelope"
|
5
|
+
|
6
|
+
subject { AdaptivePayments::RefundRequest }
|
7
|
+
its(:operation) { should == :Refund }
|
8
|
+
|
9
|
+
let(:request) do
|
10
|
+
AdaptivePayments::RefundRequest.new(
|
11
|
+
:currency_code => "USD",
|
12
|
+
:pay_key => "ABCD-1234",
|
13
|
+
:tracking_id => "some.id",
|
14
|
+
:transaction_id => "trans123",
|
15
|
+
:ipn_notification_url => "http://site.com/ipn",
|
16
|
+
:receivers => [{ :email => "first@site.com", :amount => 10 }, { :email => "other@site.com", :amount => 2 }]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:json) { JSON.parse(request.to_json) }
|
21
|
+
|
22
|
+
it "maps #currency_code to ['currencyCode']" do
|
23
|
+
json["currencyCode"].should == "USD"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "maps #pay_key to ['payKey']" do
|
27
|
+
json["payKey"].should == "ABCD-1234"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "maps #tracking_id to ['trackingId']" do
|
31
|
+
json["trackingId"].should == "some.id"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "maps #transaction_id to ['transactionId']" do
|
35
|
+
json["transactionId"].should == "trans123"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "maps #ipn_notification_url to ['ipnNotificationUrl']" do
|
39
|
+
json["ipnNotificationUrl"].should == "http://site.com/ipn"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "maps #receivers.first.email to ['receiverList']['receiver'][0]['email']" do
|
43
|
+
json["receiverList"]["receiver"][0]["email"].should == "first@site.com"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "maps #receivers.first.amount to ['receiverList']['receiver'][0]['amount']" do
|
47
|
+
json["receiverList"]["receiver"][0]["amount"].should == "10.00"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "maps #receivers.last.email to ['receiverList']['receiver'][1]['email']" do
|
51
|
+
json["receiverList"]["receiver"][1]["email"].should == "other@site.com"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "maps #receivers.last.amount to ['receiverList']['receiver'][1]['amount']" do
|
55
|
+
json["receiverList"]["receiver"][1]["amount"].should == "2.00"
|
56
|
+
end
|
57
|
+
end
|