ianfleeton-paypal-express 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +22 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +11 -0
  6. data/Gemfile +11 -0
  7. data/LICENSE +20 -0
  8. data/README.rdoc +43 -0
  9. data/Rakefile +19 -0
  10. data/VERSION +1 -0
  11. data/ianfleeton-paypal-express.gemspec +24 -0
  12. data/lib/paypal.rb +86 -0
  13. data/lib/paypal/base.rb +19 -0
  14. data/lib/paypal/exception.rb +4 -0
  15. data/lib/paypal/exception/api_error.rb +94 -0
  16. data/lib/paypal/exception/http_error.rb +12 -0
  17. data/lib/paypal/express.rb +1 -0
  18. data/lib/paypal/express/request.rb +186 -0
  19. data/lib/paypal/express/response.rb +35 -0
  20. data/lib/paypal/ipn.rb +23 -0
  21. data/lib/paypal/nvp/request.rb +66 -0
  22. data/lib/paypal/nvp/response.rb +237 -0
  23. data/lib/paypal/payment/common/amount.rb +13 -0
  24. data/lib/paypal/payment/recurring.rb +43 -0
  25. data/lib/paypal/payment/recurring/activation.rb +14 -0
  26. data/lib/paypal/payment/recurring/billing.rb +39 -0
  27. data/lib/paypal/payment/recurring/summary.rb +11 -0
  28. data/lib/paypal/payment/request.rb +67 -0
  29. data/lib/paypal/payment/request/item.rb +26 -0
  30. data/lib/paypal/payment/response.rb +75 -0
  31. data/lib/paypal/payment/response/address.rb +7 -0
  32. data/lib/paypal/payment/response/info.rb +45 -0
  33. data/lib/paypal/payment/response/item.rb +41 -0
  34. data/lib/paypal/payment/response/payee_info.rb +7 -0
  35. data/lib/paypal/payment/response/payer.rb +7 -0
  36. data/lib/paypal/payment/response/reference.rb +23 -0
  37. data/lib/paypal/payment/response/refund.rb +17 -0
  38. data/lib/paypal/payment/response/refund_info.rb +7 -0
  39. data/lib/paypal/util.rb +27 -0
  40. data/spec/fake_response/BillAgreementUpdate/fetch.txt +1 -0
  41. data/spec/fake_response/BillAgreementUpdate/revoke.txt +1 -0
  42. data/spec/fake_response/CreateBillingAgreement/success.txt +1 -0
  43. data/spec/fake_response/CreateRecurringPaymentsProfile/failure.txt +1 -0
  44. data/spec/fake_response/CreateRecurringPaymentsProfile/success.txt +1 -0
  45. data/spec/fake_response/DoCapture/failure.txt +1 -0
  46. data/spec/fake_response/DoCapture/success.txt +1 -0
  47. data/spec/fake_response/DoExpressCheckoutPayment/failure.txt +1 -0
  48. data/spec/fake_response/DoExpressCheckoutPayment/success.txt +1 -0
  49. data/spec/fake_response/DoExpressCheckoutPayment/success_with_billing_agreement.txt +1 -0
  50. data/spec/fake_response/DoExpressCheckoutPayment/success_with_many_items.txt +1 -0
  51. data/spec/fake_response/DoReferenceTransaction/failure.txt +1 -0
  52. data/spec/fake_response/DoReferenceTransaction/success.txt +1 -0
  53. data/spec/fake_response/DoVoid/success.txt +1 -0
  54. data/spec/fake_response/GetExpressCheckoutDetails/failure.txt +1 -0
  55. data/spec/fake_response/GetExpressCheckoutDetails/success.txt +1 -0
  56. data/spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt +1 -0
  57. data/spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt +1 -0
  58. data/spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt +1 -0
  59. data/spec/fake_response/GetTransactionDetails/failure.txt +1 -0
  60. data/spec/fake_response/GetTransactionDetails/success.txt +1 -0
  61. data/spec/fake_response/IPN/invalid.txt +1 -0
  62. data/spec/fake_response/IPN/valid.txt +1 -0
  63. data/spec/fake_response/ManageRecurringPaymentsProfileStatus/failure.txt +1 -0
  64. data/spec/fake_response/ManageRecurringPaymentsProfileStatus/success.txt +1 -0
  65. data/spec/fake_response/RefundTransaction/full.txt +1 -0
  66. data/spec/fake_response/SetExpressCheckout/failure.txt +1 -0
  67. data/spec/fake_response/SetExpressCheckout/success.txt +1 -0
  68. data/spec/helpers/fake_response_helper.rb +29 -0
  69. data/spec/paypal/exception/api_error_spec.rb +105 -0
  70. data/spec/paypal/exception/http_error_spec.rb +20 -0
  71. data/spec/paypal/express/request_spec.rb +578 -0
  72. data/spec/paypal/express/response_spec.rb +89 -0
  73. data/spec/paypal/ipn_spec.rb +19 -0
  74. data/spec/paypal/nvp/request_spec.rb +113 -0
  75. data/spec/paypal/nvp/response_spec.rb +175 -0
  76. data/spec/paypal/payment/common/amount_spec.rb +36 -0
  77. data/spec/paypal/payment/recurring/activation_spec.rb +19 -0
  78. data/spec/paypal/payment/recurring_spec.rb +170 -0
  79. data/spec/paypal/payment/request/item_spec.rb +27 -0
  80. data/spec/paypal/payment/request_spec.rb +136 -0
  81. data/spec/paypal/payment/response/address_spec.rb +26 -0
  82. data/spec/paypal/payment/response/info_spec.rb +93 -0
  83. data/spec/paypal/payment/response/item_spec.rb +78 -0
  84. data/spec/paypal/payment/response/payee_info_spec.rb +24 -0
  85. data/spec/paypal/payment/response/payer_spec.rb +26 -0
  86. data/spec/paypal/payment/response/reference_info_spec.rb +36 -0
  87. data/spec/paypal/payment/response/refund_info_spec.rb +18 -0
  88. data/spec/paypal/payment/response/refund_spec.rb +28 -0
  89. data/spec/paypal/payment/response_spec.rb +29 -0
  90. data/spec/paypal/util_spec.rb +32 -0
  91. data/spec/spec_helper.rb +25 -0
  92. metadata +319 -0
@@ -0,0 +1,170 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Paypal::Payment::Recurring do
4
+ let :keys do
5
+ Paypal::Payment::Recurring.optional_attributes
6
+ end
7
+
8
+ let :trial_attributes do
9
+ {}
10
+ end
11
+
12
+ let :attributes do
13
+ {
14
+ :identifier => '12345',
15
+ :description => 'Subscription Payment Profile',
16
+ :status => 'Active',
17
+ :start_date => '2011-02-03T15:00:00Z',
18
+ :name => 'Nov Matake',
19
+ :auto_bill => 'NoAutoBill',
20
+ :max_fails => '0',
21
+ :aggregate_amount => '1000',
22
+ :aggregate_optional_amount => '0',
23
+ :final_payment_date => '1970-01-01T00:00:00Z',
24
+ :billing => {
25
+ :amount => Paypal::Payment::Common::Amount.new(
26
+ :total => '1000',
27
+ :shipping => '0',
28
+ :tax => '0'
29
+ ),
30
+ :currency_code => 'JPY',
31
+ :period => 'Month',
32
+ :frequency => '1',
33
+ :total_cycles => '0',
34
+ :trial => trial_attributes
35
+ },
36
+ :regular_billing => {
37
+ :amount => '1000',
38
+ :shipping_amount => '0',
39
+ :tax_amount => '0',
40
+ :currency_code => 'JPY',
41
+ :period => 'Month',
42
+ :frequency => '1',
43
+ :total_cycles => '0',
44
+ :paid => '1000'
45
+ },
46
+ :summary => {
47
+ :next_billing_date => '2011-03-04T10:00:00Z',
48
+ :cycles_completed => '1',
49
+ :cycles_remaining => '18446744073709551615',
50
+ :outstanding_balance => '0',
51
+ :failed_count => '0',
52
+ :last_payment_date => '2011-02-04T10:50:56Z',
53
+ :last_payment_amount => '1000'
54
+ }
55
+ }
56
+ end
57
+
58
+ let :instance do
59
+ Paypal::Payment::Recurring.new attributes
60
+ end
61
+
62
+ describe '.new' do
63
+ it 'should accept all supported attributes' do
64
+ expect(instance.identifier).to eq('12345')
65
+ expect(instance.description).to eq('Subscription Payment Profile')
66
+ expect(instance.status).to eq('Active')
67
+ expect(instance.start_date).to eq('2011-02-03T15:00:00Z')
68
+ expect(instance.billing.trial).to be_nil
69
+ end
70
+
71
+ context 'when optional trial info given' do
72
+ let :trial_attributes do
73
+ {
74
+ :period => 'Month',
75
+ :frequency => '1',
76
+ :total_cycles => '0',
77
+ :currency_code => 'JPY',
78
+ :amount => '1000',
79
+ :shipping_amount => '0',
80
+ :tax_amount => '0'
81
+ }
82
+ end
83
+ it 'should setup trial billing info' do
84
+ expect(instance.billing.trial).to eq(Paypal::Payment::Recurring::Billing.new(trial_attributes))
85
+ end
86
+ end
87
+ end
88
+
89
+ describe '#to_params' do
90
+ it 'should handle Recurring Profile parameters' do
91
+ expect(instance.to_params).to eq({
92
+ :AUTOBILLOUTAMT => 'NoAutoBill',
93
+ :BILLINGFREQUENCY => 1,
94
+ :SHIPPINGAMT => '0.00',
95
+ :DESC => 'Subscription Payment Profile',
96
+ :SUBSCRIBERNAME => 'Nov Matake',
97
+ :BILLINGPERIOD => 'Month',
98
+ :AMT => '1000.00',
99
+ :MAXFAILEDPAYMENTS => 0,
100
+ :TOTALBILLINGCYCLES => 0,
101
+ :TAXAMT => '0.00',
102
+ :PROFILESTARTDATE => '2011-02-03T15:00:00Z',
103
+ :CURRENCYCODE => 'JPY'
104
+ })
105
+ end
106
+
107
+ context 'when start_date is Time' do
108
+ it 'should be stringfy' do
109
+ instance = Paypal::Payment::Recurring.new attributes.merge(
110
+ :start_date => Time.utc(2011, 2, 8, 15, 0, 0)
111
+ )
112
+ expect(instance.start_date).to be_instance_of(Time)
113
+ expect(instance.to_params[:PROFILESTARTDATE]).to eq('2011-02-08 15:00:00')
114
+ end
115
+ end
116
+
117
+ context 'when optional trial setting given' do
118
+ let :trial_attributes do
119
+ {
120
+ :period => 'Month',
121
+ :frequency => '1',
122
+ :total_cycles => '0',
123
+ :currency_code => 'JPY',
124
+ :amount => '1000',
125
+ :shipping_amount => '0',
126
+ :tax_amount => '0'
127
+ }
128
+ end
129
+ it 'should setup trial billing info' do
130
+ expect(instance.to_params).to eq({
131
+ :TRIALBILLINGPERIOD => "Month",
132
+ :TRIALBILLINGFREQUENCY => 1,
133
+ :TRIALTOTALBILLINGCYCLES => 0,
134
+ :TRIALAMT => "1000.00",
135
+ :TRIALCURRENCYCODE => "JPY",
136
+ :TRIALSHIPPINGAMT => "0.00",
137
+ :TRIALTAXAMT => "0.00",
138
+ :BILLINGPERIOD => "Month",
139
+ :BILLINGFREQUENCY => 1,
140
+ :TOTALBILLINGCYCLES => 0,
141
+ :AMT => "1000.00",
142
+ :CURRENCYCODE => "JPY",
143
+ :SHIPPINGAMT => "0.00",
144
+ :TAXAMT => "0.00",
145
+ :DESC => "Subscription Payment Profile",
146
+ :MAXFAILEDPAYMENTS => 0,
147
+ :AUTOBILLOUTAMT => "NoAutoBill",
148
+ :PROFILESTARTDATE => "2011-02-03T15:00:00Z",
149
+ :SUBSCRIBERNAME => "Nov Matake"
150
+ })
151
+ end
152
+ end
153
+ end
154
+
155
+ describe '#numeric_attribute?' do
156
+ let :numeric_attributes do
157
+ [:aggregate_amount, :aggregate_optional_amount, :max_fails, :failed_count]
158
+ end
159
+
160
+ it 'should detect numeric attributes' do
161
+ numeric_attributes.each do |key|
162
+ expect(instance.numeric_attribute?(key)).to be_truthy
163
+ end
164
+ non_numeric_keys = keys - numeric_attributes
165
+ non_numeric_keys.each do |key|
166
+ expect(instance.numeric_attribute?(key)).to be_falsey
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Paypal::Payment::Request::Item do
4
+ let :instance do
5
+ Paypal::Payment::Request::Item.new(
6
+ :name => 'Name',
7
+ :description => 'Description',
8
+ :amount => 10,
9
+ :quantity => 5,
10
+ :category => :Digital,
11
+ :number => '1'
12
+ )
13
+ end
14
+
15
+ describe '#to_params' do
16
+ it 'should handle Recurring Profile activation parameters' do
17
+ expect(instance.to_params(1)).to eq({
18
+ :L_PAYMENTREQUEST_1_NAME0 => 'Name',
19
+ :L_PAYMENTREQUEST_1_DESC0 => 'Description',
20
+ :L_PAYMENTREQUEST_1_AMT0 => '10.00',
21
+ :L_PAYMENTREQUEST_1_QTY0 => 5,
22
+ :L_PAYMENTREQUEST_1_ITEMCATEGORY0 => :Digital,
23
+ :L_PAYMENTREQUEST_1_NUMBER0 => '1'
24
+ })
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,136 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Paypal::Payment::Request do
4
+ let :instant_request do
5
+ Paypal::Payment::Request.new(
6
+ :amount => 25.7,
7
+ :tax_amount => 0.4,
8
+ :shipping_amount => 1.5,
9
+ :currency_code => :JPY,
10
+ :description => 'Instant Payment Request',
11
+ :notify_url => 'http://merchant.example.com/notify',
12
+ :invoice_number => 'ABC123',
13
+ :custom => 'Custom',
14
+ :items => [{
15
+ :quantity => 2,
16
+ :name => 'Item1',
17
+ :description => 'Awesome Item 1!',
18
+ :amount => 10.25
19
+ }, {
20
+ :quantity => 3,
21
+ :name => 'Item2',
22
+ :description => 'Awesome Item 2!',
23
+ :amount => 1.1
24
+ }],
25
+ :custom_fields => {
26
+ "l_surveychoice{n}" => 'abcd' # The '{n}' will be replaced with the index
27
+ }
28
+ )
29
+ end
30
+
31
+ let :recurring_request do
32
+ Paypal::Payment::Request.new(
33
+ :currency_code => :JPY,
34
+ :billing_type => :RecurringPayments,
35
+ :billing_agreement_description => 'Recurring Payment Request'
36
+ )
37
+ end
38
+
39
+ let :reference_transaction_request do
40
+ Paypal::Payment::Request.new(
41
+ :currency_code => :JPY,
42
+ :billing_type => :MerchantInitiatedBillingSingleAgreement,
43
+ :billing_agreement_description => 'Reference Transaction Request'
44
+ )
45
+ end
46
+
47
+ describe '.new' do
48
+ it 'should handle Instant Payment parameters' do
49
+ expect(instant_request.amount.total).to eq(25.7)
50
+ expect(instant_request.amount.tax).to eq(0.4)
51
+ expect(instant_request.amount.shipping).to eq(1.5)
52
+ expect(instant_request.currency_code).to eq(:JPY)
53
+ expect(instant_request.description).to eq('Instant Payment Request')
54
+ expect(instant_request.notify_url).to eq('http://merchant.example.com/notify')
55
+ end
56
+
57
+ it 'should handle Recurring Payment parameters' do
58
+ expect(recurring_request.currency_code).to eq(:JPY)
59
+ expect(recurring_request.billing_type).to eq(:RecurringPayments)
60
+ expect(recurring_request.billing_agreement_description).to eq('Recurring Payment Request')
61
+ end
62
+
63
+ it 'should handle Recurring Payment parameters' do
64
+ expect(reference_transaction_request.currency_code).to eq(:JPY)
65
+ expect(reference_transaction_request.billing_type).to eq(:MerchantInitiatedBillingSingleAgreement)
66
+ expect(reference_transaction_request.billing_agreement_description).to eq('Reference Transaction Request')
67
+ end
68
+ end
69
+
70
+ describe '#to_params' do
71
+ it 'should handle Instant Payment parameters' do
72
+ expect(instant_request.to_params).to eq({
73
+ :PAYMENTREQUEST_0_AMT => "25.70",
74
+ :PAYMENTREQUEST_0_TAXAMT => "0.40",
75
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "1.50",
76
+ :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
77
+ :PAYMENTREQUEST_0_DESC => "Instant Payment Request",
78
+ :PAYMENTREQUEST_0_NOTIFYURL => "http://merchant.example.com/notify",
79
+ :PAYMENTREQUEST_0_ITEMAMT => "23.80",
80
+ :PAYMENTREQUEST_0_INVNUM => "ABC123",
81
+ :PAYMENTREQUEST_0_CUSTOM => "Custom",
82
+ :L_PAYMENTREQUEST_0_NAME0 => "Item1",
83
+ :L_PAYMENTREQUEST_0_DESC0 => "Awesome Item 1!",
84
+ :L_PAYMENTREQUEST_0_AMT0 => "10.25",
85
+ :L_PAYMENTREQUEST_0_QTY0 => 2,
86
+ :L_PAYMENTREQUEST_0_NAME1 => "Item2",
87
+ :L_PAYMENTREQUEST_0_DESC1 => "Awesome Item 2!",
88
+ :L_PAYMENTREQUEST_0_AMT1 => "1.10",
89
+ :L_PAYMENTREQUEST_0_QTY1 => 3,
90
+ :L_SURVEYCHOICE0 => 'abcd' # Note the 'n' was replaced by the index
91
+ })
92
+ end
93
+
94
+ it 'should handle Recurring Payment parameters' do
95
+ expect(recurring_request.to_params).to eq({
96
+ :PAYMENTREQUEST_0_AMT => "0.00",
97
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
98
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
99
+ :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
100
+ :L_BILLINGTYPE0 => :RecurringPayments,
101
+ :L_BILLINGAGREEMENTDESCRIPTION0 => "Recurring Payment Request"
102
+ })
103
+ end
104
+
105
+ it 'should handle Reference Transactions parameters' do
106
+ expect(reference_transaction_request.to_params).to eq({
107
+ :PAYMENTREQUEST_0_AMT => "0.00",
108
+ :PAYMENTREQUEST_0_TAXAMT => "0.00",
109
+ :PAYMENTREQUEST_0_SHIPPINGAMT => "0.00",
110
+ :PAYMENTREQUEST_0_CURRENCYCODE => :JPY,
111
+ :L_BILLINGTYPE0 => :MerchantInitiatedBillingSingleAgreement,
112
+ :L_BILLINGAGREEMENTDESCRIPTION0 => "Reference Transaction Request"
113
+ })
114
+ end
115
+ end
116
+
117
+ describe '#items_amount' do
118
+ context 'when BigDecimal'
119
+ let(:instance) do
120
+ Paypal::Payment::Request.new(
121
+ :items => [{
122
+ :quantity => 3,
123
+ :name => 'Item1',
124
+ :description => 'Awesome Item 1!',
125
+ :amount => 130.45
126
+ }]
127
+ )
128
+ end
129
+
130
+ # NOTE:
131
+ # 130.45 * 3 => 391.34999999999997 (in ruby 1.9)
132
+ it 'should calculate total amount correctly' do
133
+ expect(instance.items_amount).to eq(391.35)
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Paypal::Payment::Response::Address do
4
+ let :keys do
5
+ Paypal::Payment::Response::Address.optional_attributes
6
+ end
7
+
8
+ describe '.new' do
9
+ it 'should allow nil for attributes' do
10
+ payer = Paypal::Payment::Response::Address.new
11
+ keys.each do |key|
12
+ expect(payer.send(key)).to be_nil
13
+ end
14
+ end
15
+
16
+ it 'should treat all attributes as String' do
17
+ attributes = keys.inject({}) do |attributes, key|
18
+ attributes.merge!(key => "xyz")
19
+ end
20
+ payer = Paypal::Payment::Response::Address.new attributes
21
+ keys.each do |key|
22
+ expect(payer.send(key)).to eq("xyz")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Paypal::Payment::Response::Info do
4
+ let :attribute_mapping do
5
+ Paypal::Payment::Response::Info.attribute_mapping
6
+ end
7
+
8
+ let :attributes do
9
+ {
10
+ :ACK => 'Success',
11
+ :CURRENCYCODE => 'JPY',
12
+ :ERRORCODE => 0,
13
+ :ORDERTIME => '2011-02-08T03:23:54Z',
14
+ :PAYMENTSTATUS => 'Completed',
15
+ :PAYMENTTYPE => 'instant',
16
+ :PENDINGREASON => 'None',
17
+ :PROTECTIONELIGIBILITY => 'Ineligible',
18
+ :PROTECTIONELIGIBILITYTYPE => 'None',
19
+ :REASONCODE => 'None',
20
+ :TRANSACTIONID => '8NC65222871997739',
21
+ :TRANSACTIONTYPE => 'expresscheckout',
22
+ :AMT => '14.00',
23
+ :FEEAMT => '0.85',
24
+ :TAXAMT => '0.00',
25
+ :RECEIPTID => '12345',
26
+ :SECUREMERCHANTACCOUNTID => '123456789',
27
+ :PAYMENTREQUESTID => '12345',
28
+ :SELLERPAYPALACCOUNTID => 'seller@shop.example.com',
29
+ :EXCHANGERATE => '0.811965'
30
+ }
31
+ end
32
+
33
+ describe '.new' do
34
+ context 'when attribute keys are uppercase Symbol' do
35
+ it 'should accept all without any warning' do
36
+ expect(Paypal.logger).not_to receive(:warn)
37
+ from_symbol_uppercase = Paypal::Payment::Response::Info.new attributes
38
+ attribute_mapping.values.each do |key|
39
+ expect(from_symbol_uppercase.send(key)).not_to be_nil
40
+ end
41
+ expect(from_symbol_uppercase.amount).to eq(Paypal::Payment::Common::Amount.new(
42
+ :total => 14,
43
+ :fee => 0.85
44
+ ))
45
+ end
46
+ end
47
+
48
+ context 'when attribute keys are lowercase Symbol' do
49
+ it 'should ignore them and warn' do
50
+ _attrs_ = attributes.inject({}) do |_attrs_, (k, v)|
51
+ _attrs_.merge!(k.to_s.downcase.to_sym => v)
52
+ end
53
+ _attrs_.each do |key, value|
54
+ expect(Paypal.logger).to receive(:warn).with(
55
+ "Ignored Parameter (Paypal::Payment::Response::Info): #{key}=#{value}"
56
+ )
57
+ end
58
+ from_symbol_lowercase = Paypal::Payment::Response::Info.new _attrs_
59
+ attribute_mapping.values.each do |key|
60
+ expect(from_symbol_lowercase.send(key)).to be_nil
61
+ end
62
+ expect(from_symbol_lowercase.amount).to eq(Paypal::Payment::Common::Amount.new)
63
+ end
64
+ end
65
+
66
+ context 'when attribute keys are String' do
67
+ it 'should ignore them and warn' do
68
+ attributes.stringify_keys.each do |key, value|
69
+ expect(Paypal.logger).to receive(:warn).with(
70
+ "Ignored Parameter (Paypal::Payment::Response::Info): #{key}=#{value}"
71
+ )
72
+ end
73
+ from_string = Paypal::Payment::Response::Info.new attributes.stringify_keys
74
+ attribute_mapping.values.each do |key|
75
+ expect(from_string.send(key)).to be_nil
76
+ end
77
+ expect(from_string.amount).to eq(Paypal::Payment::Common::Amount.new)
78
+ end
79
+ end
80
+
81
+ context 'when non-supported attributes are given' do
82
+ it 'should ignore them and warn' do
83
+ _attr_ = attributes.merge(
84
+ :ignored => 'Ignore me!'
85
+ )
86
+ expect(Paypal.logger).to receive(:warn).with(
87
+ "Ignored Parameter (Paypal::Payment::Response::Info): ignored=Ignore me!"
88
+ )
89
+ Paypal::Payment::Response::Info.new _attr_
90
+ end
91
+ end
92
+ end
93
+ end