activemerchant-nsp 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/CHANGELOG +952 -0
  2. data/CONTRIBUTORS +347 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +204 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +9 -0
  8. data/lib/active_merchant/billing/avs_result.rb +98 -0
  9. data/lib/active_merchant/billing/base.rb +56 -0
  10. data/lib/active_merchant/billing/check.rb +68 -0
  11. data/lib/active_merchant/billing/credit_card.rb +274 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  15. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  16. data/lib/active_merchant/billing/gateway.rb +176 -0
  17. data/lib/active_merchant/billing/gateways.rb +18 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
  21. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
  22. data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
  23. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
  24. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
  26. data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
  27. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  28. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
  30. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  31. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  32. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
  35. data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
  36. data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
  37. data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
  38. data/lib/active_merchant/billing/gateways/epay.rb +276 -0
  39. data/lib/active_merchant/billing/gateways/eway.rb +287 -0
  40. data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
  41. data/lib/active_merchant/billing/gateways/exact.rb +227 -0
  42. data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
  43. data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
  44. data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
  45. data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
  46. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
  47. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  48. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  49. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
  50. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  51. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  52. data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
  53. data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
  54. data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
  55. data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
  56. data/lib/active_merchant/billing/gateways/litle.rb +290 -0
  57. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
  58. data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
  59. data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
  60. data/lib/active_merchant/billing/gateways/migs.rb +263 -0
  61. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  62. data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
  63. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  64. data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
  65. data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
  66. data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
  67. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  68. data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
  69. data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
  71. data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
  72. data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
  73. data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
  74. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
  75. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
  76. data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
  77. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  78. data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
  79. data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
  80. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
  81. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  82. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  83. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  84. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  85. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  86. data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
  87. data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
  88. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
  89. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
  91. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
  94. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  95. data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
  96. data/lib/active_merchant/billing/gateways/payway.rb +214 -0
  97. data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
  98. data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
  99. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  100. data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
  101. data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
  102. data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
  103. data/lib/active_merchant/billing/gateways/realex.rb +313 -0
  104. data/lib/active_merchant/billing/gateways/sage.rb +148 -0
  105. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  106. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  108. data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
  109. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  110. data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
  111. data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
  112. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  113. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
  114. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  115. data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
  116. data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
  117. data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
  118. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  119. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  120. data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
  121. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  122. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
  123. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
  124. data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
  125. data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
  126. data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
  127. data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
  128. data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
  129. data/lib/active_merchant/billing/integrations.rb +17 -0
  130. data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
  131. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
  132. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
  133. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
  134. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  135. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  136. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  137. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  138. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  139. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  140. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  141. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  142. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  143. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
  144. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  145. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  146. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  147. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  148. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  149. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  150. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  151. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  152. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  153. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  154. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  155. data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
  156. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
  157. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
  158. data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
  159. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
  160. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
  161. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
  162. data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
  163. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
  164. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
  165. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
  166. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  167. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  168. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  169. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  170. data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
  171. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  172. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  173. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  174. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  175. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  176. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  177. data/lib/active_merchant/billing/integrations/helper.rb +117 -0
  178. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  179. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  180. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  181. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  182. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  183. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  184. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  185. data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
  186. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
  187. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
  188. data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
  189. data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
  190. data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
  191. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  192. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  193. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  194. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  195. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  196. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  197. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  198. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  199. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  200. data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
  201. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
  202. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
  203. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  204. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  205. data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
  206. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  207. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
  208. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
  209. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  210. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
  211. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  212. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  213. data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
  214. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
  215. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  216. data/lib/active_merchant/billing/integrations/return.rb +42 -0
  217. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  218. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  219. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  220. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  221. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  222. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  223. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  224. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
  225. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
  226. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
  227. data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
  228. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
  229. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
  230. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  231. data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
  232. data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
  233. data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
  234. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
  235. data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
  236. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  237. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
  238. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  239. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  240. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  241. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  242. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  243. data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
  244. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
  245. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
  246. data/lib/active_merchant/billing/response.rb +64 -0
  247. data/lib/active_merchant/version.rb +3 -0
  248. data/lib/activemerchant.rb +1 -0
  249. data/lib/support/gateway_support.rb +65 -0
  250. data/lib/support/outbound_hosts.rb +25 -0
  251. data/lib/support/ssl_verify.rb +93 -0
  252. metadata +482 -0
@@ -0,0 +1,49 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PaypalExpressResponse < Response
4
+ def email
5
+ info['Payer']
6
+ end
7
+
8
+ def info
9
+ (@params['PayerInfo']||{})
10
+ end
11
+
12
+ def name
13
+ payer = (info['PayerName']||{})
14
+ [payer['FirstName'], payer['MiddleName'], payer['LastName']].compact.join(' ')
15
+ end
16
+
17
+ def token
18
+ @params['Token']
19
+ end
20
+
21
+ def payer_id
22
+ info['PayerID']
23
+ end
24
+
25
+ def payer_country
26
+ info['PayerCountry']
27
+ end
28
+
29
+ # PayPal returns a contact telephone number only if your Merchant account profile settings require that the buyer enter one.
30
+ def contact_phone
31
+ @params['ContactPhone']
32
+ end
33
+
34
+ def address
35
+ address = (@params['PaymentDetails']||{})['ShipToAddress']
36
+ { 'name' => address['Name'],
37
+ 'company' => info['PayerBusiness'],
38
+ 'address1' => address['Street1'],
39
+ 'address2' => address['Street2'],
40
+ 'city' => address['CityName'],
41
+ 'state' => address['StateOrProvince'],
42
+ 'country' => address['Country'],
43
+ 'zip' => address['PostalCode'],
44
+ 'phone' => (contact_phone || address['Phone'])
45
+ }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,245 @@
1
+ require File.dirname(__FILE__) + '/paypal_common_api'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # This module is included in both PaypalGateway and PaypalExpressGateway
6
+ module PaypalRecurringApi
7
+ PAYPAL_NAMESPACE = ActiveMerchant::Billing::PaypalCommonAPI::PAYPAL_NAMESPACE
8
+ API_VERSION = ActiveMerchant::Billing::PaypalCommonAPI::API_VERSION
9
+ EBAY_NAMESPACE = ActiveMerchant::Billing::PaypalCommonAPI::EBAY_NAMESPACE
10
+ # Create a recurring payment.
11
+ #
12
+ # This transaction creates a recurring payment profile
13
+ # ==== Parameters
14
+ #
15
+ # * <tt>money</tt> -- The amount to be charged to the customer at each interval as an Integer value in cents.
16
+ # * <tt>credit_card</tt> -- The CreditCard details for the transaction.
17
+ # * <tt>options</tt> -- A hash of parameters.
18
+ #
19
+ # ==== Options
20
+ #
21
+ # * <tt>:period</tt> -- [Day, Week, SemiMonth, Month, Year] default: Month
22
+ # * <tt>:frequency</tt> -- a number
23
+ # * <tt>:cycles</tt> -- Limit to certain # of cycles (OPTIONAL)
24
+ # * <tt>:start_date</tt> -- When does the charging starts (REQUIRED)
25
+ # * <tt>:description</tt> -- The description to appear in the profile (REQUIRED)
26
+
27
+ def recurring(amount, credit_card, options = {})
28
+ options[:credit_card] = credit_card
29
+ options[:amount] = amount
30
+ requires!(options, :description, :start_date, :period, :frequency, :amount)
31
+ commit 'CreateRecurringPaymentsProfile', build_create_profile_request(options)
32
+ end
33
+
34
+ # Update a recurring payment's details.
35
+ #
36
+ # This transaction updates an existing Recurring Billing Profile
37
+ # and the subscription must have already been created previously
38
+ # by calling +recurring()+. The ability to change certain
39
+ # details about a recurring payment is dependent on transaction history
40
+ # and the type of plan you're subscribed with paypal. Web Payment Pro
41
+ # seems to have the ability to update the most field.
42
+ #
43
+ # ==== Parameters
44
+ #
45
+ # * <tt>options</tt> -- A hash of parameters.
46
+ #
47
+ # ==== Options
48
+ #
49
+ # * <tt>:profile_id</tt> -- A string containing the <tt>:profile_id</tt>
50
+ # of the recurring payment already in place for a given credit card. (REQUIRED)
51
+ def update_recurring(options={})
52
+ requires!(options, :profile_id)
53
+ opts = options.dup
54
+ commit 'UpdateRecurringPaymentsProfile', build_change_profile_request(opts.delete(:profile_id), opts)
55
+ end
56
+
57
+ # Cancel a recurring payment.
58
+ #
59
+ # This transaction cancels an existing recurring billing profile. Your account must have recurring billing enabled
60
+ # and the subscription must have already been created previously by calling recurring()
61
+ #
62
+ # ==== Parameters
63
+ #
64
+ # * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
65
+ # recurring payment already in place for a given credit card. (REQUIRED)
66
+ # * <tt>options</tt> -- A hash with extra info ('note' for ex.)
67
+ def cancel_recurring(profile_id, options = {})
68
+ raise_error_if_blank('profile_id', profile_id)
69
+ commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Cancel', options)
70
+ end
71
+
72
+ # Get Subscription Status of a recurring payment profile.
73
+ #
74
+ # ==== Parameters
75
+ #
76
+ # * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
77
+ # recurring payment already in place for a given credit card. (REQUIRED)
78
+ def status_recurring(profile_id)
79
+ raise_error_if_blank('profile_id', profile_id)
80
+ commit 'GetRecurringPaymentsProfileDetails', build_get_profile_details_request(profile_id)
81
+ end
82
+
83
+ # Suspends a recurring payment profile.
84
+ #
85
+ # ==== Parameters
86
+ #
87
+ # * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
88
+ # recurring payment already in place for a given credit card. (REQUIRED)
89
+ def suspend_recurring(profile_id, options = {})
90
+ raise_error_if_blank('profile_id', profile_id)
91
+ commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Suspend', options)
92
+ end
93
+
94
+ # Reactivates a suspended recurring payment profile.
95
+ #
96
+ # ==== Parameters
97
+ #
98
+ # * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
99
+ # recurring payment already in place for a given credit card. (REQUIRED)
100
+ def reactivate_recurring(profile_id, options = {})
101
+ raise_error_if_blank('profile_id', profile_id)
102
+ commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(profile_id, 'Reactivate', options)
103
+ end
104
+
105
+ # Bills outstanding amount to a recurring payment profile.
106
+ #
107
+ # ==== Parameters
108
+ #
109
+ # * <tt>profile_id</tt> -- A string containing the +profile_id+ of the
110
+ # recurring payment already in place for a given credit card. (REQUIRED)
111
+ def bill_outstanding_amount(profile_id, options = {})
112
+ raise_error_if_blank('profile_id', profile_id)
113
+ commit 'BillOutstandingAmount', build_bill_outstanding_amount(profile_id, options)
114
+ end
115
+
116
+ private
117
+ def raise_error_if_blank(field_name, field)
118
+ raise ArgumentError.new("Missing required parameter: #{field_name}") if field.blank?
119
+ end
120
+ def build_create_profile_request(options)
121
+ xml = Builder::XmlMarkup.new :indent => 2
122
+ xml.tag! 'CreateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
123
+ xml.tag! 'CreateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
124
+ xml.tag! 'n2:Version', API_VERSION
125
+ xml.tag! 'n2:CreateRecurringPaymentsProfileRequestDetails' do
126
+ xml.tag! 'Token', options[:token] unless options[:token].blank?
127
+ if options[:credit_card]
128
+ add_credit_card(xml, options[:credit_card], (options[:billing_address] || options[:address]), options)
129
+ end
130
+ xml.tag! 'n2:RecurringPaymentsProfileDetails' do
131
+ xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
132
+ xml.tag! 'n2:ProfileReference', options[:profile_reference] unless options[:profile_reference].blank?
133
+ end
134
+ xml.tag! 'n2:ScheduleDetails' do
135
+ xml.tag! 'n2:Description', options[:description]
136
+ xml.tag! 'n2:PaymentPeriod' do
137
+ xml.tag! 'n2:BillingPeriod', options[:period] || 'Month'
138
+ xml.tag! 'n2:BillingFrequency', options[:frequency]
139
+ xml.tag! 'n2:TotalBillingCycles', options[:total_billing_cycles] unless options[:total_billing_cycles].blank?
140
+ xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
141
+ xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:tax_amount].blank?
142
+ xml.tag! 'n2:ShippingAmount', amount(options[:shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:shipping_amount].blank?
143
+ end
144
+ if !options[:trial_amount].blank?
145
+ xml.tag! 'n2:TrialPeriod' do
146
+ xml.tag! 'n2:BillingPeriod', options[:trial_period] || 'Month'
147
+ xml.tag! 'n2:BillingFrequency', options[:trial_frequency]
148
+ xml.tag! 'n2:TotalBillingCycles', options[:trial_cycles] || 1
149
+ xml.tag! 'n2:Amount', amount(options[:trial_amount]), 'currencyID' => options[:currency] || 'USD'
150
+ xml.tag! 'n2:TaxAmount', amount(options[:trial_tax_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_tax_amount].blank?
151
+ xml.tag! 'n2:ShippingAmount', amount(options[:trial_shipping_amount] || 0), 'currencyID' => options[:currency] || 'USD' unless options[:trial_shipping_amount].blank?
152
+ end
153
+ end
154
+ if !options[:initial_amount].blank?
155
+ xml.tag! 'n2:ActivationDetails' do
156
+ xml.tag! 'n2:InitialAmount', amount(options[:initial_amount]), 'currencyID' => options[:currency] || 'USD'
157
+ xml.tag! 'n2:FailedInitialAmountAction', options[:continue_on_failure] ? 'ContinueOnFailure' : 'CancelOnFailure'
158
+ end
159
+ end
160
+ xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
161
+ xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
162
+ end
163
+ end
164
+ end
165
+ end
166
+ xml.target!
167
+ end
168
+
169
+ def build_get_profile_details_request(profile_id)
170
+ xml = Builder::XmlMarkup.new :indent => 2
171
+ xml.tag! 'GetRecurringPaymentsProfileDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
172
+ xml.tag! 'GetRecurringPaymentsProfileDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
173
+ xml.tag! 'n2:Version', API_VERSION
174
+ xml.tag! 'ProfileID', profile_id
175
+ end
176
+ end
177
+ xml.target!
178
+ end
179
+
180
+ def build_change_profile_request(profile_id, options)
181
+ xml = Builder::XmlMarkup.new :indent => 2
182
+ xml.tag! 'UpdateRecurringPaymentsProfileReq', 'xmlns' => PAYPAL_NAMESPACE do
183
+ xml.tag! 'UpdateRecurringPaymentsProfileRequest', 'xmlns:n2' => EBAY_NAMESPACE do
184
+ xml.tag! 'n2:Version', API_VERSION
185
+ xml.tag! 'n2:UpdateRecurringPaymentsProfileRequestDetails' do
186
+ xml.tag! 'ProfileID', profile_id
187
+ if options[:credit_card]
188
+ add_credit_card(xml, options[:credit_card], options[:address], options)
189
+ end
190
+ xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
191
+ xml.tag! 'n2:Description', options[:description] unless options[:description].blank?
192
+ xml.tag! 'n2:ProfileReference', options[:reference] unless options[:reference].blank?
193
+ xml.tag! 'n2:AdditionalBillingCycles', options[:additional_billing_cycles] unless options[:additional_billing_cycles].blank?
194
+ xml.tag! 'n2:MaxFailedPayments', options[:max_failed_payments] unless options[:max_failed_payments].blank?
195
+ xml.tag! 'n2:AutoBillOutstandingAmount', options[:auto_bill_outstanding] ? 'AddToNextBilling' : 'NoAutoBill'
196
+ if options.has_key?(:amount)
197
+ xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
198
+ end
199
+ if options.has_key?(:tax_amount)
200
+ xml.tag! 'n2:TaxAmount', amount(options[:tax_amount] || 0), 'currencyID' => options[:currency] || 'USD'
201
+ end
202
+ if options.has_key?(:start_date)
203
+ xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
204
+ end
205
+ end
206
+ end
207
+ end
208
+ xml.target!
209
+ end
210
+
211
+ def build_manage_profile_request(profile_id, action, options)
212
+ xml = Builder::XmlMarkup.new :indent => 2
213
+ xml.tag! 'ManageRecurringPaymentsProfileStatusReq', 'xmlns' => PAYPAL_NAMESPACE do
214
+ xml.tag! 'ManageRecurringPaymentsProfileStatusRequest', 'xmlns:n2' => EBAY_NAMESPACE do
215
+ xml.tag! 'n2:Version', API_VERSION
216
+ xml.tag! 'n2:ManageRecurringPaymentsProfileStatusRequestDetails' do
217
+ xml.tag! 'ProfileID', profile_id
218
+ xml.tag! 'n2:Action', action
219
+ xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
220
+ end
221
+ end
222
+ end
223
+ xml.target!
224
+ end
225
+
226
+ def build_bill_outstanding_amount(profile_id, options)
227
+ xml = Builder::XmlMarkup.new :indent => 2
228
+ xml.tag! 'BillOutstandingAmountReq', 'xmlns' => PAYPAL_NAMESPACE do
229
+ xml.tag! 'BillOutstandingAmountRequest', 'xmlns:n2' => EBAY_NAMESPACE do
230
+ xml.tag! 'n2:Version', API_VERSION
231
+ xml.tag! 'n2:BillOutstandingAmountRequestDetails' do
232
+ xml.tag! 'ProfileID', profile_id
233
+ if options.has_key?(:amount)
234
+ xml.tag! 'n2:Amount', amount(options[:amount]), 'currencyID' => options[:currency] || 'USD'
235
+ end
236
+ xml.tag! 'n2:Note', options[:note] unless options[:note].blank?
237
+ end
238
+ end
239
+ end
240
+ xml.target!
241
+ end
242
+
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/paypal'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # The PayPal gateway for PayPal Website Payments Pro Canada only supports Visa and MasterCard
6
+ class PaypalCaGateway < PaypalGateway
7
+ self.supported_cardtypes = [:visa, :master]
8
+ self.supported_countries = ['CA']
9
+ self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside'
10
+ self.display_name = 'PayPal Website Payments Pro (CA)'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/paypal/paypal_common_api'
2
+ require File.dirname(__FILE__) + '/paypal/paypal_express_response'
3
+ require File.dirname(__FILE__) + '/paypal_express_common'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ class PaypalDigitalGoodsGateway < PaypalExpressGateway
8
+ self.test_redirect_url = 'https://www.sandbox.paypal.com/incontext'
9
+ self.live_redirect_url = 'https://www.paypal.com/incontext'
10
+
11
+ self.supported_countries = %w(AU CA CN FI GB ID IN IT MY NO NZ PH PL SE SG TH VN)
12
+ self.homepage_url = 'https://www.x.com/community/ppx/xspaces/digital_goods'
13
+ self.display_name = 'PayPal Express Checkout for Digital Goods'
14
+
15
+ def redirect_url_for(token, options = {})
16
+ "#{redirect_url}?token=#{token}&useraction=commit"
17
+ end
18
+
19
+ # GATEWAY.setup_purchase(100,
20
+ # :ip => "127.0.0.1",
21
+ # :description => "Test Title",
22
+ # :return_url => "http://return.url",
23
+ # :cancel_return_url => "http://cancel.url",
24
+ # :items => [ { :name => "Charge",
25
+ # :number => "1",
26
+ # :quantity => "1",
27
+ # :amount => 100,
28
+ # :description => "Description",
29
+ # :category => "Digital" } ] )
30
+ def build_setup_request(action, money, options)
31
+ requires!(options, :items)
32
+ raise ArgumentError, "Must include at least 1 Item" unless options[:items].length > 0
33
+ options[:items].each do |item|
34
+ requires!(item, :name, :number, :quantity, :amount, :description, :category)
35
+ raise ArgumentError, "Each of the items must have the category 'Digital'" unless item[:category] == 'Digital'
36
+ end
37
+
38
+ super
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,178 @@
1
+ require File.dirname(__FILE__) + '/paypal/paypal_common_api'
2
+ require File.dirname(__FILE__) + '/paypal/paypal_express_response'
3
+ require File.dirname(__FILE__) + '/paypal_express_common'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ class PaypalExpressGateway < Gateway
8
+ include PaypalCommonAPI
9
+ include PaypalExpressCommon
10
+
11
+ self.test_redirect_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'
12
+ self.supported_countries = ['US']
13
+ self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside'
14
+ self.display_name = 'PayPal Express Checkout'
15
+
16
+ def setup_authorization(money, options = {})
17
+ requires!(options, :return_url, :cancel_return_url)
18
+
19
+ commit 'SetExpressCheckout', build_setup_request('Authorization', money, options)
20
+ end
21
+
22
+ def setup_purchase(money, options = {})
23
+ requires!(options, :return_url, :cancel_return_url)
24
+
25
+ commit 'SetExpressCheckout', build_setup_request('Sale', money, options)
26
+ end
27
+
28
+ def details_for(token)
29
+ commit 'GetExpressCheckoutDetails', build_get_details_request(token)
30
+ end
31
+
32
+ def authorize(money, options = {})
33
+ requires!(options, :token, :payer_id)
34
+
35
+ commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Authorization', money, options)
36
+ end
37
+
38
+ def purchase(money, options = {})
39
+ requires!(options, :token, :payer_id)
40
+
41
+ commit 'DoExpressCheckoutPayment', build_sale_or_authorization_request('Sale', money, options)
42
+ end
43
+
44
+ def reference_transaction(money, options = {})
45
+ requires!(options, :reference_id, :payment_type, :invoice_id, :description, :ip)
46
+
47
+ commit 'DoReferenceTransaction', build_reference_transaction_request('Sale', money, options)
48
+ end
49
+
50
+ private
51
+ def build_get_details_request(token)
52
+ xml = Builder::XmlMarkup.new :indent => 2
53
+ xml.tag! 'GetExpressCheckoutDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
54
+ xml.tag! 'GetExpressCheckoutDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
55
+ xml.tag! 'n2:Version', API_VERSION
56
+ xml.tag! 'Token', token
57
+ end
58
+ end
59
+
60
+ xml.target!
61
+ end
62
+
63
+ def build_sale_or_authorization_request(action, money, options)
64
+ currency_code = options[:currency] || currency(money)
65
+
66
+ xml = Builder::XmlMarkup.new :indent => 2
67
+ xml.tag! 'DoExpressCheckoutPaymentReq', 'xmlns' => PAYPAL_NAMESPACE do
68
+ xml.tag! 'DoExpressCheckoutPaymentRequest', 'xmlns:n2' => EBAY_NAMESPACE do
69
+ xml.tag! 'n2:Version', API_VERSION
70
+ xml.tag! 'n2:DoExpressCheckoutPaymentRequestDetails' do
71
+ xml.tag! 'n2:PaymentAction', action
72
+ xml.tag! 'n2:Token', options[:token]
73
+ xml.tag! 'n2:PayerID', options[:payer_id]
74
+ add_payment_details(xml, money, currency_code, options)
75
+ end
76
+ end
77
+ end
78
+
79
+ xml.target!
80
+ end
81
+
82
+ def build_setup_request(action, money, options)
83
+ currency_code = options[:currency] || currency(money)
84
+ options[:payment_action] = action
85
+ options[:express_request] = true
86
+ options[:shipping_address] ||= options[:address]
87
+
88
+ xml = Builder::XmlMarkup.new :indent => 2
89
+ xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
90
+ xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
91
+ xml.tag! 'n2:Version', API_VERSION
92
+ xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
93
+ xml.tag! 'n2:ReturnURL', options[:return_url]
94
+ xml.tag! 'n2:CancelURL', options[:cancel_return_url]
95
+ if options[:max_amount]
96
+ xml.tag! 'n2:MaxAmount', localized_amount(options[:max_amount], currency_code), 'currencyID' => currency_code
97
+ end
98
+ xml.tag! 'n2:NoShipping', options[:no_shipping] ? '1' : '0'
99
+ xml.tag! 'n2:AddressOverride', options[:address_override] ? '1' : '0'
100
+ xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
101
+ xml.tag! 'n2:BrandName', options[:brand_name] unless options[:brand_name].blank?
102
+ # Customization of the payment page
103
+ xml.tag! 'n2:PageStyle', options[:page_style] unless options[:page_style].blank?
104
+ xml.tag! 'n2:cpp-header-image', options[:header_image] unless options[:header_image].blank?
105
+ xml.tag! 'n2:cpp-header-border-color', options[:header_border_color] unless options[:header_border_color].blank?
106
+ xml.tag! 'n2:cpp-header-back-color', options[:header_background_color] unless options[:header_background_color].blank?
107
+ xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
108
+ if options[:allow_guest_checkout]
109
+ xml.tag! 'n2:SolutionType', 'Sole'
110
+ xml.tag! 'n2:LandingPage', options[:landing_page] || 'Billing'
111
+ end
112
+ xml.tag! 'n2:BuyerEmail', options[:email] unless options[:email].blank?
113
+
114
+ if options[:billing_agreement]
115
+ xml.tag! 'n2:BillingAgreementDetails' do
116
+ xml.tag! 'n2:BillingType', options[:billing_agreement][:type]
117
+ xml.tag! 'n2:BillingAgreementDescription', options[:billing_agreement][:description]
118
+ xml.tag! 'n2:PaymentType', options[:billing_agreement][:payment_type] || 'InstantOnly'
119
+ end
120
+ end
121
+
122
+ if !options[:allow_note].nil?
123
+ xml.tag! 'n2:AllowNote', options[:allow_note] ? '1' : '0'
124
+ end
125
+ xml.tag! 'n2:CallbackURL', options[:callback_url] unless options[:callback_url].blank?
126
+
127
+ add_payment_details(xml, with_money_default(money), currency_code, options)
128
+ if options[:shipping_options]
129
+ options[:shipping_options].each do |shipping_option|
130
+ xml.tag! 'n2:FlatRateShippingOptions' do
131
+ xml.tag! 'n2:ShippingOptionIsDefault', shipping_option[:default]
132
+ xml.tag! 'n2:ShippingOptionAmount', localized_amount(shipping_option[:amount], currency_code), 'currencyID' => currency_code
133
+ xml.tag! 'n2:ShippingOptionName', shipping_option[:name]
134
+ end
135
+ end
136
+ end
137
+
138
+ xml.tag! 'n2:CallbackTimeout', options[:callback_timeout] unless options[:callback_timeout].blank?
139
+ xml.tag! 'n2:CallbackVersion', options[:callback_version] unless options[:callback_version].blank?
140
+ end
141
+ end
142
+ end
143
+
144
+ xml.target!
145
+ end
146
+
147
+ def build_reference_transaction_request(action, money, options)
148
+ currency_code = options[:currency] || currency(money)
149
+
150
+ # I am not sure why it's set like this for express gateway
151
+ # but I don't want to break the existing behavior
152
+ xml = Builder::XmlMarkup.new :indent => 2
153
+ xml.tag! 'DoReferenceTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
154
+ xml.tag! 'DoReferenceTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
155
+ xml.tag! 'n2:Version', API_VERSION
156
+ xml.tag! 'n2:DoReferenceTransactionRequestDetails' do
157
+ xml.tag! 'n2:ReferenceID', options[:reference_id]
158
+ xml.tag! 'n2:PaymentAction', action
159
+ xml.tag! 'n2:PaymentType', options[:payment_type] || 'Any'
160
+ add_payment_details(xml, with_money_default(money), currency_code, options)
161
+ xml.tag! 'n2:IPAddress', options[:ip]
162
+ end
163
+ end
164
+ end
165
+
166
+ xml.target!
167
+ end
168
+
169
+ def build_response(success, message, response, options = {})
170
+ PaypalExpressResponse.new(success, message, response, options)
171
+ end
172
+
173
+ def with_money_default(money)
174
+ amount(money).to_f.zero? ? 100 : money
175
+ end
176
+ end
177
+ end
178
+ end