active_paypal_adaptive_payment 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0 0.3.12 (2012-05-02)
2
+
3
+ - Add displayOptions and receiverOptions support to
4
+ SetPaymentOptionsRequest (Niels Ganser) 597ecad
5
+
1
6
  ## 0 0.3.11 (2012-04-28)
2
7
 
3
8
  - Added option :action_type to build_adaptive_payment_pay_request to enable delayed chained payments (3df6948) by eldoy
data/README.md CHANGED
@@ -9,7 +9,7 @@ This library is meant to interface with PayPal's Adaptive Payment Gateway.
9
9
  ## Supported
10
10
 
11
11
  * Payments
12
- * Peapprovals
12
+ * Preapprovals
13
13
  * Refunds
14
14
  * Currency conversions
15
15
  * getting/setting payment options
@@ -37,7 +37,7 @@ See [iAuction: An Adaptive Payments Tutorial Featuring Parallel Payments](https:
37
37
  :signature => "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
38
38
  :appid => "APP-80W284485P519543T" )
39
39
 
40
- ### Pre-approved paymen
40
+ ### Pre-approved payment
41
41
 
42
42
  gateway.preapprove_payment (
43
43
  :return_url => "returnURL",
@@ -91,6 +91,54 @@ end
91
91
  ActiveMerchant::Billing::Base.mode = :test
92
92
  ```
93
93
 
94
+ ### Setting advanced payment and invoice options
95
+
96
+ To be able to set additional payment and invoice options, such as item names,
97
+ shipping costs, custom logos, etc., you must first create a payment, then set
98
+ the options and then direct the user to the payment page:
99
+
100
+ ```ruby
101
+ purchase = gateway.setup_purchase(
102
+ :action_type => "CREATE", # This is in contrast to the default PAY action
103
+ … # as above
104
+ )
105
+
106
+ gateway.set_payment_options(
107
+ :display_options => {
108
+ :business_name => "Your Business",
109
+ :header_image_url => "http://cdn.yourbusiness.com/logo-for-paypal.png"
110
+ },
111
+ :pay_key => purchase["payKey"],
112
+ :receiver_options => [
113
+ {
114
+ :description => "Your purchase of XYZ",
115
+ :invoice_data => {
116
+ :item => [
117
+ { :name => "Item #1", :item_count => 1, :item_price => 100, :price => 100 },
118
+ { :name => "Item #2", :item_count => 2, :item_price => 10, :price => 20 }
119
+ ],
120
+ :total_shipping => 5,
121
+ :total_tax => 10
122
+ },
123
+ :receiver => { :email => "receiver1@example.com" }
124
+ },
125
+ {
126
+ :description => "XYZ Processing fee",
127
+ :invoice_data => {
128
+ :item => [{ :name => "Fee", :item_count => 1, :item_price => 10, :price => 10 }]
129
+ },
130
+ :receiver => { :email => "receiver2@example.com" }
131
+ }
132
+ ]
133
+ )
134
+
135
+ redirect_to(gateway.redirect_url_for(purchase["payKey"]))
136
+ ```
137
+
138
+ See the implementation of ActiveMerchant::Billing::PaypalAdaptivePayment#build_adaptive_set_payment_options_request
139
+ for all available options and [Operation SetPaymentOptions API](https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_AdaptivePayments.pdf)
140
+ for a description of them.
141
+
94
142
  ## Testing
95
143
 
96
144
  First modify the `test/fixtures.yml` to fit your app credentials (You
@@ -132,6 +180,7 @@ xml request, raw json response and the URL of the endpoint.
132
180
  * Mike Pence (<https://github.com/mikepence>)
133
181
  * Nicola Junior Vitto (<https://github.com/njvitto>)
134
182
  * Vidar Eldøy (https://github.com/eldoy)
183
+ * Niels Ganser (https://github.com/Nielsomat)
135
184
 
136
185
  ## Other previous contributors where some code was taken from.
137
186
 
@@ -207,6 +207,46 @@ module ActiveMerchant
207
207
  x.requireShippingAddressSelection opts[:sender][:require_shipping_address_selection] if opts[:sender][:require_shipping_address_selection]
208
208
  x.referrerCode opts[:sender][:referrerCode] if opts[:sender][:referrerCode]
209
209
  end
210
+ unless opts[:display_options].blank?
211
+ x.displayOptions do |x|
212
+ x.emailHeaderImageUrl opts[:display_options][:email_header_image_url] if opts[:display_options][:email_header_image_url]
213
+ x.emailMarketingImageUrl opts[:display_options][:email_marketing_image_url] if opts[:display_options][:email_marketing_image_url]
214
+ x.headerImageUrl opts[:display_options][:header_image_url] if opts[:display_options][:header_image_url]
215
+ x.businessName opts[:display_options][:business_name] if opts[:display_options][:business_name]
216
+ end
217
+ end
218
+ opts[:receiver_options].try(:each) do |receiver_options|
219
+ x.receiverOptions do |x|
220
+ x.description receiver_options[:description] if receiver_options[:description]
221
+ x.customId receiver_options[:custom_id] if receiver_options[:custom_id]
222
+ unless receiver_options[:invoice_data].blank?
223
+ x.invoiceData do |x|
224
+ receiver_options[:invoice_data][:item].try(:each) do |item|
225
+ x.item do |x|
226
+ x.name item[:name] if item[:name]
227
+ x.identifier item[:identifier] if item[:identifier]
228
+ x.price item[:price] if item[:price]
229
+ x.itemPrice item[:item_price] if item[:item_price]
230
+ x.itemCount item[:item_count] if item[:item_count]
231
+ end
232
+ end
233
+ x.totalTax receiver_options[:invoice_data][:total_tax] if receiver_options[:invoice_data][:total_tax]
234
+ x.totalShipping receiver_options[:invoice_data][:total_shipping] if receiver_options[:invoice_data][:total_shipping]
235
+ end
236
+ end
237
+ x.receiver do |x|
238
+ x.email receiver_options[:receiver][:email] if receiver_options[:receiver][:email]
239
+ unless receiver_options[:receiver][:phone].blank?
240
+ x.phone do |x|
241
+ x.countryCode receiver_options[:receiver][:phone][:country_code]
242
+ x.phoneNumber receiver_options[:receiver][:phone][:phone_number]
243
+ x.extension receiver_options[:receiver][:phone][:extension] if receiver_options[:receiver][:phone][:extension]
244
+ end
245
+ end
246
+ end
247
+ x.referrerCode receiver_options[:referrer_code] if receiver_options[:referrer_code]
248
+ end
249
+ end
210
250
  x.payKey opts[:pay_key]
211
251
  end
212
252
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_paypal_adaptive_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-28 00:00:00.000000000 Z
12
+ date: 2012-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemerchant
16
- requirement: &89014680 !ruby/object:Gem::Requirement
16
+ requirement: &90760330 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.5.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *89014680
24
+ version_requirements: *90760330
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: multi_json
27
- requirement: &89030830 !ruby/object:Gem::Requirement
27
+ requirement: &90760090 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *89030830
35
+ version_requirements: *90760090
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hashie
38
- requirement: &89030590 !ruby/object:Gem::Requirement
38
+ requirement: &90759850 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *89030590
46
+ version_requirements: *90759850
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: money
49
- requirement: &89030350 !ruby/object:Gem::Requirement
49
+ requirement: &90759610 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.6.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *89030350
57
+ version_requirements: *90759610
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &89030110 !ruby/object:Gem::Requirement
60
+ requirement: &90775770 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.10.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *89030110
68
+ version_requirements: *90775770
69
69
  description: ! ' This library is meant to interface with PayPal''s Adaptive Payment
70
70
  Gateway.
71
71