paypal-payment 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/.gitignore +19 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +18 -0
  4. data/Guardfile +24 -0
  5. data/README.rdoc +107 -0
  6. data/Rakefile +5 -0
  7. data/docs/AdaptivePayments.rdoc +84 -0
  8. data/docs/PP_NVPAPI_DeveloperGuide.pdf +0 -0
  9. data/docs/PP_WPP_IntegrationGuide.pdf +0 -0
  10. data/docs/adaptive_payments.md +55 -0
  11. data/docs/api.txt +67 -0
  12. data/docs/design.txt +38 -0
  13. data/docs/express_checkout.md +172 -0
  14. data/docs/requirements.txt +32 -0
  15. data/lib/paypal-payment.rb +10 -0
  16. data/lib/paypal/adaptive_payments.rb +31 -0
  17. data/lib/paypal/adaptive_payments/api.rb +51 -0
  18. data/lib/paypal/adaptive_payments/base.rb +11 -0
  19. data/lib/paypal/adaptive_payments/client_details.rb +14 -0
  20. data/lib/paypal/adaptive_payments/display_options.rb +10 -0
  21. data/lib/paypal/adaptive_payments/funding_constraint.rb +11 -0
  22. data/lib/paypal/adaptive_payments/funding_type_info.rb +8 -0
  23. data/lib/paypal/adaptive_payments/funding_type_list.rb +11 -0
  24. data/lib/paypal/adaptive_payments/initiating_entity.rb +11 -0
  25. data/lib/paypal/adaptive_payments/institution_customer.rb +13 -0
  26. data/lib/paypal/adaptive_payments/invoice_data.rb +13 -0
  27. data/lib/paypal/adaptive_payments/invoice_item.rb +11 -0
  28. data/lib/paypal/adaptive_payments/payment.rb +105 -0
  29. data/lib/paypal/adaptive_payments/payment_info.rb +18 -0
  30. data/lib/paypal/adaptive_payments/payment_info_list.rb +11 -0
  31. data/lib/paypal/adaptive_payments/payment_options.rb +39 -0
  32. data/lib/paypal/adaptive_payments/phone.rb +9 -0
  33. data/lib/paypal/adaptive_payments/preapproval.rb +52 -0
  34. data/lib/paypal/adaptive_payments/receiver.rb +17 -0
  35. data/lib/paypal/adaptive_payments/receiver_list.rb +49 -0
  36. data/lib/paypal/adaptive_payments/receiver_options.rb +19 -0
  37. data/lib/paypal/adaptive_payments/request.rb +51 -0
  38. data/lib/paypal/adaptive_payments/response.rb +38 -0
  39. data/lib/paypal/adaptive_payments/response/address.rb +13 -0
  40. data/lib/paypal/adaptive_payments/response/address_list.rb +11 -0
  41. data/lib/paypal/adaptive_payments/response/base_address.rb +13 -0
  42. data/lib/paypal/adaptive_payments/response/details.rb +19 -0
  43. data/lib/paypal/adaptive_payments/response/error_list.rb +15 -0
  44. data/lib/paypal/adaptive_payments/response/pay.rb +31 -0
  45. data/lib/paypal/adaptive_payments/response/pay_error.rb +16 -0
  46. data/lib/paypal/adaptive_payments/response/pay_error_list.rb +15 -0
  47. data/lib/paypal/adaptive_payments/response/pay_options.rb +7 -0
  48. data/lib/paypal/adaptive_payments/response/preapproval.rb +47 -0
  49. data/lib/paypal/adaptive_payments/response/refund.rb +16 -0
  50. data/lib/paypal/adaptive_payments/response/refund_info.rb +24 -0
  51. data/lib/paypal/adaptive_payments/response/refund_info_list.rb +11 -0
  52. data/lib/paypal/adaptive_payments/response/shipping_address.rb +11 -0
  53. data/lib/paypal/adaptive_payments/sender_identifier.rb +7 -0
  54. data/lib/paypal/adaptive_payments/sender_options.rb +8 -0
  55. data/lib/paypal/api.rb +94 -0
  56. data/lib/paypal/cacert.pem +3987 -0
  57. data/lib/paypal/common.rb +11 -0
  58. data/lib/paypal/common/base.rb +83 -0
  59. data/lib/paypal/common/error_data.rb +15 -0
  60. data/lib/paypal/common/request.rb +45 -0
  61. data/lib/paypal/common/request_envelope.rb +13 -0
  62. data/lib/paypal/common/response.rb +34 -0
  63. data/lib/paypal/common/response_envelope.rb +19 -0
  64. data/lib/paypal/express_checkout.rb +19 -0
  65. data/lib/paypal/express_checkout/account.rb +16 -0
  66. data/lib/paypal/express_checkout/api.rb +43 -0
  67. data/lib/paypal/express_checkout/base.rb +37 -0
  68. data/lib/paypal/express_checkout/billing.rb +7 -0
  69. data/lib/paypal/express_checkout/callback.rb +17 -0
  70. data/lib/paypal/express_checkout/checkout.rb +144 -0
  71. data/lib/paypal/express_checkout/fields.rb +449 -0
  72. data/lib/paypal/express_checkout/fmf.rb +7 -0
  73. data/lib/paypal/express_checkout/payment.rb +76 -0
  74. data/lib/paypal/express_checkout/payment_item.rb +7 -0
  75. data/lib/paypal/express_checkout/recurring.rb +131 -0
  76. data/lib/paypal/express_checkout/request.rb +212 -0
  77. data/lib/paypal/express_checkout/response.rb +52 -0
  78. data/lib/paypal/express_checkout/response/account.rb +30 -0
  79. data/lib/paypal/express_checkout/response/address.rb +29 -0
  80. data/lib/paypal/express_checkout/response/authorization.rb +25 -0
  81. data/lib/paypal/express_checkout/response/base.rb +125 -0
  82. data/lib/paypal/express_checkout/response/callback_request.rb +10 -0
  83. data/lib/paypal/express_checkout/response/callback_response.rb +8 -0
  84. data/lib/paypal/express_checkout/response/capture.rb +14 -0
  85. data/lib/paypal/express_checkout/response/checkout.rb +11 -0
  86. data/lib/paypal/express_checkout/response/details.rb +35 -0
  87. data/lib/paypal/express_checkout/response/manage_profile.rb +9 -0
  88. data/lib/paypal/express_checkout/response/notification.rb +85 -0
  89. data/lib/paypal/express_checkout/response/payment.rb +24 -0
  90. data/lib/paypal/express_checkout/response/profile.rb +58 -0
  91. data/lib/paypal/express_checkout/response/reference.rb +11 -0
  92. data/lib/paypal/express_checkout/response/refund.rb +13 -0
  93. data/lib/paypal/express_checkout/response/search.rb +33 -0
  94. data/lib/paypal/express_checkout/response/transaction_details.rb +11 -0
  95. data/lib/paypal/express_checkout/shipping_option.rb +7 -0
  96. data/lib/paypal/express_checkout/utils.rb +26 -0
  97. data/lib/paypal/express_checkout/version.rb +10 -0
  98. data/lib/paypal/invoice.rb +22 -0
  99. data/lib/paypal/invoice/api.rb +51 -0
  100. data/lib/paypal/invoice/base.rb +11 -0
  101. data/lib/paypal/invoice/base_address.rb +11 -0
  102. data/lib/paypal/invoice/business_info.rb +17 -0
  103. data/lib/paypal/invoice/date_range.rb +8 -0
  104. data/lib/paypal/invoice/invoice.rb +117 -0
  105. data/lib/paypal/invoice/invoice_details.rb +38 -0
  106. data/lib/paypal/invoice/invoice_item.rb +13 -0
  107. data/lib/paypal/invoice/invoice_item_list.rb +10 -0
  108. data/lib/paypal/invoice/invoice_summary.rb +22 -0
  109. data/lib/paypal/invoice/invoice_summary_list.rb +10 -0
  110. data/lib/paypal/invoice/other_payment_details.rb +13 -0
  111. data/lib/paypal/invoice/payment_details.rb +16 -0
  112. data/lib/paypal/invoice/paypal_payment_details.rb +11 -0
  113. data/lib/paypal/invoice/request.rb +43 -0
  114. data/lib/paypal/invoice/response.rb +27 -0
  115. data/lib/paypal/invoice/response/details.rb +23 -0
  116. data/lib/paypal/invoice/response/invoice.rb +10 -0
  117. data/lib/paypal/invoice/response/search.rb +15 -0
  118. data/lib/paypal/invoice/search.rb +19 -0
  119. data/lib/paypal/invoice/search_parameters.rb +20 -0
  120. data/lib/paypal/permissions.rb +12 -0
  121. data/lib/paypal/permissions/api.rb +60 -0
  122. data/lib/paypal/permissions/base.rb +11 -0
  123. data/lib/paypal/permissions/permission.rb +33 -0
  124. data/lib/paypal/permissions/personal_data.rb +17 -0
  125. data/lib/paypal/permissions/request.rb +52 -0
  126. data/lib/paypal/permissions/response.rb +24 -0
  127. data/lib/paypal/permissions/response/permission.rb +14 -0
  128. data/lib/paypal/permissions/response/personal_data.rb +8 -0
  129. data/lib/paypal/permissions/response/token.rb +10 -0
  130. data/lib/paypal/permissions/token.rb +13 -0
  131. data/lib/paypal/recurring.rb +110 -0
  132. data/lib/paypal/request.rb +82 -0
  133. data/lib/paypal/version.rb +8 -0
  134. data/paypal-payment.gemspec +30 -0
  135. data/spec/fixtures/adaptive_payments/payment/create/failure.yml +62 -0
  136. data/spec/fixtures/adaptive_payments/payment/create/success.yml +58 -0
  137. data/spec/fixtures/adaptive_payments/payment/details/success.yml +113 -0
  138. data/spec/fixtures/adaptive_payments/payment/pay/failure.yml +62 -0
  139. data/spec/fixtures/adaptive_payments/payment/pay/preapproval.yml +58 -0
  140. data/spec/fixtures/adaptive_payments/payment/pay/success.yml +58 -0
  141. data/spec/fixtures/adaptive_payments/payment/pay/with_pay_key.yml +58 -0
  142. data/spec/fixtures/adaptive_payments/payment/refund/failure.yml +62 -0
  143. data/spec/fixtures/adaptive_payments/payment/refund/success.yml +58 -0
  144. data/spec/fixtures/adaptive_payments/payment/shipping_addresses/success.yml +113 -0
  145. data/spec/fixtures/adaptive_payments/payment_options/get/success.yml +174 -0
  146. data/spec/fixtures/adaptive_payments/payment_options/set/success.yml +113 -0
  147. data/spec/fixtures/adaptive_payments/preapproval/create/success.yml +58 -0
  148. data/spec/fixtures/adaptive_payments/preapproval/details/success.yml +168 -0
  149. data/spec/fixtures/express_checkout/account/balance/success.yml +32 -0
  150. data/spec/fixtures/express_checkout/account/pal_details/success.yml +32 -0
  151. data/spec/fixtures/express_checkout/checkout/checkout/sales/success.yml +61 -0
  152. data/spec/fixtures/express_checkout/checkout/checkout/success.yml +32 -0
  153. data/spec/fixtures/express_checkout/checkout/details/failure.yml +32 -0
  154. data/spec/fixtures/express_checkout/checkout/details/success.yml +61 -0
  155. data/spec/fixtures/express_checkout/checkout/pay/sales/success.yml +61 -0
  156. data/spec/fixtures/express_checkout/checkout/pay/success.yml +61 -0
  157. data/spec/fixtures/express_checkout/payment/details/failure.yml +32 -0
  158. data/spec/fixtures/express_checkout/payment/details/success.yml +32 -0
  159. data/spec/fixtures/express_checkout/payment/refund/failure.yml +32 -0
  160. data/spec/fixtures/express_checkout/payment/refund/success.yml +32 -0
  161. data/spec/fixtures/express_checkout/payment/search/success.yml +32 -0
  162. data/spec/fixtures/express_checkout/recurring/cancel/failure.yml +32 -0
  163. data/spec/fixtures/express_checkout/recurring/cancel/success.yml +32 -0
  164. data/spec/fixtures/express_checkout/recurring/checkout/success.yml +32 -0
  165. data/spec/fixtures/express_checkout/recurring/create_profile/failure.yml +32 -0
  166. data/spec/fixtures/express_checkout/recurring/create_profile/success.yml +61 -0
  167. data/spec/fixtures/express_checkout/recurring/profile/failure.yml +32 -0
  168. data/spec/fixtures/express_checkout/recurring/profile/success.yml +32 -0
  169. data/spec/fixtures/express_checkout/recurring/reactivate/failure.yml +32 -0
  170. data/spec/fixtures/express_checkout/recurring/reactivate/success.yml +32 -0
  171. data/spec/fixtures/express_checkout/recurring/suspend/failure.yml +32 -0
  172. data/spec/fixtures/express_checkout/recurring/suspend/success.yml +32 -0
  173. data/spec/fixtures/express_checkout/recurring/update_profile/failure.yml +32 -0
  174. data/spec/fixtures/express_checkout/recurring/update_profile/profile.yml +32 -0
  175. data/spec/fixtures/express_checkout/recurring/update_profile/success.yml +32 -0
  176. data/spec/fixtures/invoice/cancel/success.yml +174 -0
  177. data/spec/fixtures/invoice/create/failure.yml +62 -0
  178. data/spec/fixtures/invoice/create/success.yml +60 -0
  179. data/spec/fixtures/invoice/create_and_send/failure.yml +62 -0
  180. data/spec/fixtures/invoice/create_and_send/success.yml +60 -0
  181. data/spec/fixtures/invoice/details/success.yml +117 -0
  182. data/spec/fixtures/invoice/mark_as_paid/failure.yml +180 -0
  183. data/spec/fixtures/invoice/mark_as_paid/success.yml +174 -0
  184. data/spec/fixtures/invoice/mark_as_refunded/success.yml +174 -0
  185. data/spec/fixtures/invoice/mark_as_unpaid/success.yml +231 -0
  186. data/spec/fixtures/invoice/search/success.yml +174 -0
  187. data/spec/fixtures/invoice/send/success.yml +117 -0
  188. data/spec/fixtures/invoice/update/failure.yml +119 -0
  189. data/spec/fixtures/invoice/update/success.yml +117 -0
  190. data/spec/fixtures/ipn/express_checkout.json +35 -0
  191. data/spec/fixtures/ipn/recurring_payment.json +44 -0
  192. data/spec/fixtures/ipn/recurring_payment_profile_created.json +31 -0
  193. data/spec/fixtures/ipn/recurring_payment_profile_created_with_initial_amount.json +33 -0
  194. data/spec/fixtures/ipn/recurring_payment_skipped.json +30 -0
  195. data/spec/fixtures/ipn/recurring_payment_with_initial_amount.json +44 -0
  196. data/spec/fixtures/notification/failure.yml +50 -0
  197. data/spec/fixtures/notification/success.yml +50 -0
  198. data/spec/paypal/adaptive_payments/api_spec.rb +20 -0
  199. data/spec/paypal/adaptive_payments/payment/base_spec.rb +28 -0
  200. data/spec/paypal/adaptive_payments/payment/create_spec.rb +63 -0
  201. data/spec/paypal/adaptive_payments/payment/details_spec.rb +34 -0
  202. data/spec/paypal/adaptive_payments/payment/pay_spec.rb +97 -0
  203. data/spec/paypal/adaptive_payments/payment/refund_spec.rb +49 -0
  204. data/spec/paypal/adaptive_payments/payment/shipping_addresses_spec.rb +30 -0
  205. data/spec/paypal/adaptive_payments/payment_options/get_spec.rb +33 -0
  206. data/spec/paypal/adaptive_payments/payment_options/set_spec.rb +66 -0
  207. data/spec/paypal/adaptive_payments/preapproval/cancel_spec.rb +34 -0
  208. data/spec/paypal/adaptive_payments/preapproval/create_spec.rb +39 -0
  209. data/spec/paypal/adaptive_payments/preapproval/details_spec.rb +34 -0
  210. data/spec/paypal/adaptive_payments/request_spec.rb +48 -0
  211. data/spec/paypal/api_spec.rb +78 -0
  212. data/spec/paypal/common/base_spec.rb +157 -0
  213. data/spec/paypal/common/error_data_spec.rb +0 -0
  214. data/spec/paypal/common/request_envelope_spec.rb +6 -0
  215. data/spec/paypal/common/response_spec.rb +0 -0
  216. data/spec/paypal/express_checkout/account/balance_spec.rb +25 -0
  217. data/spec/paypal/express_checkout/account/pal_details_spec.rb +20 -0
  218. data/spec/paypal/express_checkout/checkout/checkout_spec.rb +73 -0
  219. data/spec/paypal/express_checkout/checkout/details_spec.rb +70 -0
  220. data/spec/paypal/express_checkout/checkout/pay_spec.rb +68 -0
  221. data/spec/paypal/express_checkout/fields_spec.rb +138 -0
  222. data/spec/paypal/express_checkout/payment/refund_spec.rb +34 -0
  223. data/spec/paypal/express_checkout/payment/search_spec.rb +24 -0
  224. data/spec/paypal/express_checkout/payment/transaction_details_spec.rb +30 -0
  225. data/spec/paypal/express_checkout/payment_spec.rb +13 -0
  226. data/spec/paypal/express_checkout/recurring/create_profile_spec.rb +50 -0
  227. data/spec/paypal/express_checkout/recurring/manage_profile_spec.rb +62 -0
  228. data/spec/paypal/express_checkout/recurring/profile_spec.rb +44 -0
  229. data/spec/paypal/express_checkout/recurring/update_profile_spec.rb +50 -0
  230. data/spec/paypal/express_checkout/request_spec.rb +221 -0
  231. data/spec/paypal/express_checkout/response/account_spec.rb +33 -0
  232. data/spec/paypal/express_checkout/response/base_spec.rb +253 -0
  233. data/spec/paypal/invoice/cancel_spec.rb +38 -0
  234. data/spec/paypal/invoice/create_and_send_spec.rb +58 -0
  235. data/spec/paypal/invoice/create_spec.rb +58 -0
  236. data/spec/paypal/invoice/details_spec.rb +39 -0
  237. data/spec/paypal/invoice/mark_as_paid_spec.rb +75 -0
  238. data/spec/paypal/invoice/mark_as_refunded_spec.rb +47 -0
  239. data/spec/paypal/invoice/mark_as_unpaid_spec.rb +43 -0
  240. data/spec/paypal/invoice/search_spec.rb +70 -0
  241. data/spec/paypal/invoice/send_spec.rb +48 -0
  242. data/spec/paypal/invoice/update_spec.rb +72 -0
  243. data/spec/paypal/request_spec.rb +45 -0
  244. data/spec/spec_helper.rb +35 -0
  245. metadata +546 -0
@@ -0,0 +1,33 @@
1
+ {
2
+ "payment_cycle":"Daily",
3
+ "txn_type":"recurring_payment_profile_created",
4
+ "last_name":"User",
5
+ "initial_payment_status":"Completed",
6
+ "next_payment_date":"03:00:00 Jul 05, 2011 PDT",
7
+ "residence_country":"US",
8
+ "initial_payment_amount":"9.00",
9
+ "rp_invoice_id":"1234",
10
+ "currency_code":"USD",
11
+ "time_created":"05:40:02 Jul 05, 2011 PDT",
12
+ "verify_sign":"AhkQm37iumIaDqpU.GmMvkOH76DtA5R4Y1kgjo4B5u43tAt9yNOaY9H5",
13
+ "period_type":" Regular",
14
+ "payer_status":"verified",
15
+ "test_ipn":"1",
16
+ "tax":"0.00",
17
+ "payer_email":"buyer_1309779460_per@simplesideias.com.br",
18
+ "first_name":"Test",
19
+ "receiver_email":"seller_1309778833_biz@simplesideias.com.br",
20
+ "payer_id":"6KAQNBYBZ6KAC",
21
+ "product_type":"1",
22
+ "initial_payment_txn_id":"13V89154YA849712L",
23
+ "shipping":"0.00",
24
+ "amount_per_cycle":"9.00",
25
+ "profile_status":"Active",
26
+ "charset":"windows-1252",
27
+ "notify_version":"3.1",
28
+ "amount":"9.00",
29
+ "outstanding_balance":"0.00",
30
+ "recurring_payment_id":"I-NYWX42K14ES6",
31
+ "product_name":"Awesome - Monthly Subscription",
32
+ "ipn_track_id":"mLafq7gjIItS.n58DnlbIg"
33
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "payment_cycle": "Monthly",
3
+ "txn_type": "recurring_payment_skipped",
4
+ "last_name": "User",
5
+ "next_payment_date": "03:00:00 Oct 24, 2011 PDT",
6
+ "residence_country": "US",
7
+ "initial_payment_amount": "0.00",
8
+ "rp_invoice_id": "1234",
9
+ "currency_code": "USD",
10
+ "time_created": "05:56:05 Aug 15, 2011 PDT",
11
+ "verify_sign": "AzZjNXz176XLeyqj-36Txu9zkwePA21GR.T0rcMbqoEJe4L5v4.6d4F1",
12
+ "period_type": " Regular",
13
+ "payer_status": "verified",
14
+ "tax": "0.00",
15
+ "payer_email": "buyer_1309779460_per@simplesideias.com.br",
16
+ "first_name": "Test",
17
+ "receiver_email": "seller_1309778833_biz@simplesideias.com.br",
18
+ "payer_id": "BVK8Y2KBNGLOS",
19
+ "product_type": "1",
20
+ "shipping": "0.00",
21
+ "amount_per_cycle": "9.00",
22
+ "profile_status": "Active",
23
+ "charset": "UTF-8",
24
+ "notify_version": "3.4",
25
+ "amount": "9.00",
26
+ "outstanding_balance": "0.00",
27
+ "recurring_payment_id": "I-NYWX42K14ES6",
28
+ "product_name": "Awesome - Monthly Subscription",
29
+ "ipn_track_id": "kmiVwXjypSUWUOeF0F1URA"
30
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "mc_gross":"9.00",
3
+ "period_type":" Regular",
4
+ "outstanding_balance":"0.00",
5
+ "next_payment_date":"03:00:00 Jul 06, 2011 PDT",
6
+ "protection_eligibility":"Ineligible",
7
+ "payment_cycle":"Daily",
8
+ "tax":"0.00",
9
+ "payer_id":"6KAQNBYBZ6KAC",
10
+ "payment_date":"05:40:47 Jul 05, 2011 PDT",
11
+ "payment_status":"Completed",
12
+ "product_name":"Awesome - Monthly Subscription",
13
+ "charset":"windows-1252",
14
+ "rp_invoice_id":"1234",
15
+ "recurring_payment_id":"I-NYWX42K14ES6",
16
+ "first_name":"Test",
17
+ "mc_fee":"0.56",
18
+ "notify_version":"3.1",
19
+ "amount_per_cycle":"9.00",
20
+ "payer_status":"verified",
21
+ "currency_code":"USD",
22
+ "business":"seller_1309778833_biz@simplesideias.com.br",
23
+ "verify_sign":"AY-Nybk0IAfkhZd8.NnjoCJhyPXTAMk10-hj23D6C6FuZpclLam-uxRI",
24
+ "payer_email":"buyer_1309779460_per@simplesideias.com.br",
25
+ "initial_payment_amount":"9.00",
26
+ "profile_status":"Active",
27
+ "amount":"9.00",
28
+ "txn_id":"8C0558302N704203M",
29
+ "payment_type":"instant",
30
+ "last_name":"User",
31
+ "receiver_email":"seller_1309778833_biz@simplesideias.com.br",
32
+ "payment_fee":"0.56",
33
+ "receiver_id":"GSZCRUB62BL5L",
34
+ "txn_type":"recurring_payment",
35
+ "mc_currency":"USD",
36
+ "residence_country":"US",
37
+ "test_ipn":"1",
38
+ "transaction_subject":"",
39
+ "payment_gross":"9.00",
40
+ "shipping":"0.00",
41
+ "product_type":"1",
42
+ "time_created":"05:40:02 Jul 05, 2011 PDT",
43
+ "ipn_track_id":"kmiVwXjypSUWUOeF0F1URA"
44
+ }
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate
6
+ body:
7
+ encoding: US-ASCII
8
+ string: cmd=_notify-validate
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - PayPal::Recurring/0.1.8
14
+ content-type:
15
+ - application/x-www-form-urlencoded
16
+ connection:
17
+ - close
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ date:
24
+ - Mon, 23 Apr 2012 03:00:03 GMT
25
+ server:
26
+ - Apache
27
+ x-frame-options:
28
+ - SAMEORIGIN
29
+ set-cookie:
30
+ - c9MWDuvPtT9GIMyPc3jwol1VSlO=phiV3ZAWvCkZSenfDn1tp5SJRGYAY1V1oXZXt-oQMLjTRqt68RVoOxNBcZgxuINkTESymvIqEmaapr8-2zon9XoeH-ehyhlJbZX6JoYeFdJUbu4h9hvZmOqepdkOaZWfGkQYTG%7cdgcesLmy-LDirS8qpI0_SY5acTNGUmVqz9USdhYSfIaD4vAyicZW0hiNfDsS5RMEO4KAaG%7cfG9ex3VMD0NUmpCKlPC1URU9q7KZPbJyYkc897cvk-DO4OD7pMRo0Jn412SUgu6ZYWH8Nm%7c1335150004;
31
+ domain=.paypal.com; path=/; Secure; HttpOnly
32
+ - cookie_check=yes; expires=Thu, 21-Apr-2022 03:00:04 GMT; domain=.paypal.com;
33
+ path=/; Secure; HttpOnly
34
+ - navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
35
+ - navlns=0.0; expires=Sun, 18-Apr-2032 03:00:04 GMT; domain=.paypal.com; path=/;
36
+ Secure; HttpOnly
37
+ - Apache=10.72.109.11.1335150003601166; path=/; expires=Wed, 16-Apr-42 03:00:03
38
+ GMT
39
+ connection:
40
+ - close
41
+ transfer-encoding:
42
+ - chunked
43
+ content-type:
44
+ - text/html; charset=UTF-8
45
+ body:
46
+ encoding: US-ASCII
47
+ string: INVALID
48
+ http_version: '1.1'
49
+ recorded_at: Mon, 23 Apr 2012 03:00:04 GMT
50
+ recorded_with: VCR 2.1.0
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate
6
+ body:
7
+ encoding: US-ASCII
8
+ string: test_ipn=1&payment_type=echeck&payment_date=06%3A16%3A11+Jun+27%2C+2011+PDT&payment_status=Completed&pending_reason=echeck&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&txn_type=web_accept&txn_id=116271316&notify_version=2.1&custom=xyz123&invoice=abc1234&charset=windows-1252&verify_sign=A12AYqq6LElPcpXaQx48GiroLHnMAoQPnK0Z7aRwXUOpg1GfDaE15mFN&cmd=_notify-validate
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - PayPal::Recurring/0.1.8
14
+ content-type:
15
+ - application/x-www-form-urlencoded
16
+ connection:
17
+ - close
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ date:
24
+ - Mon, 23 Apr 2012 02:59:59 GMT
25
+ server:
26
+ - Apache
27
+ x-frame-options:
28
+ - SAMEORIGIN
29
+ set-cookie:
30
+ - c9MWDuvPtT9GIMyPc3jwol1VSlO=00kAPbDwhPKB9nwR_1IoAiXiS87HGgqlFvdD2H0t93cicF_W5MervrhdJQqaf1kmA7MF8BJaF7X3smTuIkqh3Y6VbVGWndlE8loQQzpxoYfn3Wum0buzOtrzmQ0RIPpg5ubZj0%7c-nsDtRpfNurTlYfejKp-xDy8K7FIu2hCS5-BntoBTMoIthvpiZ9_z58Ai9WW3VWdWnRnFW%7cn_p4wTyrizXlrl93-Uw168RpfgURCSDTpHPgDfK__M6BS2TLwtwHfWUfM_ZWhgl4eaGm5W%7c1335150000;
31
+ domain=.paypal.com; path=/; Secure; HttpOnly
32
+ - cookie_check=yes; expires=Thu, 21-Apr-2022 03:00:00 GMT; domain=.paypal.com;
33
+ path=/; Secure; HttpOnly
34
+ - navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
35
+ - navlns=0.0; expires=Sun, 18-Apr-2032 03:00:00 GMT; domain=.paypal.com; path=/;
36
+ Secure; HttpOnly
37
+ - Apache=10.72.109.11.1335149999304854; path=/; expires=Wed, 16-Apr-42 02:59:59
38
+ GMT
39
+ connection:
40
+ - close
41
+ transfer-encoding:
42
+ - chunked
43
+ content-type:
44
+ - text/html; charset=UTF-8
45
+ body:
46
+ encoding: US-ASCII
47
+ string: VERIFIED
48
+ http_version: '1.1'
49
+ recorded_at: Mon, 23 Apr 2012 03:00:00 GMT
50
+ recorded_with: VCR 2.1.0
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe PayPal::AdaptivePayments::Api do
4
+ let(:api) { PayPal::Api }
5
+ let(:endpoints) { PayPal::AdaptivePayments::Api::API_ENDPOINTS }
6
+
7
+ describe ".api_endpoints" do
8
+ subject { PayPal::AdaptivePayments::Api.api_endpoint }
9
+
10
+ context "when sandbox" do
11
+ before { api.sandbox = true }
12
+ it { should eql(endpoints[:sandbox]) }
13
+ end
14
+
15
+ context "when production" do
16
+ before { api.sandbox = false }
17
+ it { should eql(endpoints[:production]) }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ include PayPal::AdaptivePayments
4
+
5
+ describe PayPal::AdaptivePayments::Payment do
6
+ let(:receiver_email) { 'chardy_1345003248_per@gmail.com' }
7
+ let(:receiver) { Receiver.new(:email => receiver_email, :amount => 10.0) }
8
+ let(:receiver_list) { ReceiverList.new(:receivers => [receiver]) }
9
+
10
+ describe "#receiver=" do
11
+
12
+ it "add receiver to receiver_list" do
13
+ subject.receiver = receiver
14
+ subject.receiver_list.receivers.should have(1).item
15
+ subject.receiver_list.first.should eql(receiver)
16
+ end
17
+ end
18
+
19
+ describe "#receiver" do
20
+ let(:receiver) { Receiver.new(:email => receiver_email) }
21
+
22
+ before { subject.receiver_list = receiver_list }
23
+
24
+ it "returns the first receiver" do
25
+ subject.receiver.should eql(receiver)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ require "spec_helper"
2
+
3
+ include PayPal::AdaptivePayments
4
+
5
+ describe PayPal::AdaptivePayments::Payment do
6
+ let(:preapproval_key) { 'PA-89578182UL033944H' }
7
+ let(:receiver_email) { 'chardy_1345003248_per@gmail.com' }
8
+ let(:receiver) { Receiver.new(:email => receiver_email, :amount => 10.0) }
9
+ let(:receiver_list) { ReceiverList.new(:receivers => [receiver]) }
10
+
11
+ describe "#create" do
12
+ context "when successful" do
13
+ use_vcr_cassette "adaptive_payments/payment/create/success"#, :record => :all
14
+
15
+ let(:payment) {
16
+ PayPal::AdaptivePayments::Payment.new(
17
+ :receiver => receiver,
18
+ :preapproval_key => preapproval_key,
19
+ :currency_code => 'USD',
20
+ :cancel_url => 'http://example.com/cancel',
21
+ :return_url => 'http://example.com/thank_you'
22
+ )
23
+ }
24
+
25
+ subject { payment.create }
26
+
27
+ before { subject }
28
+
29
+ it "sets action_type to :create" do
30
+ payment.action_type.should eql('CREATE')
31
+ end
32
+
33
+ it "sets the pay_key" do
34
+ payment.pay_key.should_not be_nil
35
+ end
36
+
37
+ its(:success?) { should be_true }
38
+ its(:valid?) { should be_true }
39
+ its(:payment_url) { should eql("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=#{payment.pay_key}") }
40
+ end
41
+
42
+ context "when failure" do
43
+ use_vcr_cassette "adaptive_payments/payment/create/failure"#, :record => :all
44
+
45
+ let(:payment) {
46
+ PayPal::AdaptivePayments::Payment.new(
47
+ :receiver => receiver,
48
+ :currency_code => 'USD',
49
+ :cancel_url => 'example.com/cancel',
50
+ :return_url => 'http://example.com/thank_you'
51
+ )
52
+ }
53
+
54
+ subject { payment.create }
55
+
56
+ before { subject }
57
+
58
+ its(:success?) { should be_false }
59
+ its(:valid?) { should be_false }
60
+ its(:errors) { should have(1).item }
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+
3
+ include PayPal::AdaptivePayments
4
+
5
+ describe PayPal::AdaptivePayments::Payment do
6
+ let(:receiver_email) { 'chardy_1345003248_per@gmail.com' }
7
+ let(:receiver) { Receiver.new(:email => receiver_email, :amount => 10.0) }
8
+ let(:receiver_list) { ReceiverList.new(:receivers => [receiver]) }
9
+ let(:payment) {
10
+ PayPal::AdaptivePayments::Payment.new(
11
+ :receiver => receiver,
12
+ :currency_code => 'USD',
13
+ :cancel_url => 'http://example.com/cancel',
14
+ :return_url => 'http://example.com/thank_you'
15
+ )
16
+ }
17
+ let(:pay_key) { payment.pay_key }
18
+ let(:details) { payment.details }
19
+
20
+ describe "#details" do
21
+ context "when successful" do
22
+ use_vcr_cassette "adaptive_payments/payment/details/success"#, :record => :all
23
+
24
+ subject { details }
25
+
26
+ before { payment.create }
27
+
28
+ its(:success?) { should be_true }
29
+ its(:valid?) { should be_true }
30
+ its(:payment_info) { should eq(details.payment_info_list.payment_info) }
31
+ its(:receiver) { should eq(details.payment_info_list.payment_info.first.receiver) }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,97 @@
1
+ require "spec_helper"
2
+
3
+ include PayPal::AdaptivePayments
4
+
5
+ describe PayPal::AdaptivePayments::Payment do
6
+ let(:preapproval_key) { 'PA-89578182UL033944H' }
7
+ let(:receiver_email) { 'chardy_1345003248_per@gmail.com' }
8
+ let(:receiver) { Receiver.new(:email => receiver_email, :amount => 10.0) }
9
+ let(:receiver_list) { ReceiverList.new(:receivers => [receiver]) }
10
+
11
+ describe "#pay" do
12
+ context "when successful" do
13
+ use_vcr_cassette "adaptive_payments/payment/pay/success"#, :record => :all
14
+
15
+ let(:payment) {
16
+ PayPal::AdaptivePayments::Payment.new(
17
+ :receiver => receiver,
18
+ :currency_code => 'USD',
19
+ :cancel_url => 'http://example.com/cancel',
20
+ :return_url => 'http://example.com/thank_you'
21
+ )
22
+ }
23
+
24
+ subject { payment.pay }
25
+
26
+ before { subject }
27
+
28
+ it "sets action_type to :pay" do
29
+ payment.action_type.should eql('PAY')
30
+ end
31
+
32
+ it "sets the pay_key" do
33
+ payment.pay_key.should_not be_nil
34
+ end
35
+
36
+ its(:success?) { should be_true }
37
+ its(:valid?) { should be_true }
38
+ its(:payment_url) { should eql("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=#{payment.pay_key}") }
39
+ end
40
+
41
+ context "when pay_key is set" do
42
+ use_vcr_cassette "adaptive_payments/payment/pay/with_pay_key"#, :record => :all
43
+
44
+ let(:pay_key) { 'AP-5C085958M3074971R' }
45
+ let(:payment) { PayPal::AdaptivePayments::Payment.new(:pay_key => pay_key) }
46
+
47
+ subject { payment.pay }
48
+
49
+ it "run execute command" do
50
+ payment.should_receive(:run_execute)
51
+ subject
52
+ end
53
+
54
+ its(:success?) { should be_true }
55
+ end
56
+
57
+ context "when preapproval_key is set" do
58
+ use_vcr_cassette "adaptive_payments/payment/pay/preapproval"#, :record => :all
59
+
60
+ let(:payment) {
61
+ PayPal::AdaptivePayments::Payment.new(
62
+ :preapproval_key => preapproval_key,
63
+ :receiver => receiver,
64
+ :currency_code => 'USD',
65
+ :cancel_url => 'http://example.com/cancel',
66
+ :return_url => 'http://example.com/thank_you'
67
+ )
68
+ }
69
+
70
+ subject { payment.pay }
71
+
72
+ its(:success?) { should be_true }
73
+ its(:payment_exec_status) { should eql('COMPLETED') }
74
+ end
75
+
76
+ context "when failure" do
77
+ use_vcr_cassette "adaptive_payments/payment/pay/failure"#, :record => :all
78
+
79
+ let(:payment) {
80
+ PayPal::AdaptivePayments::Payment.new(
81
+ :receiver => { :email => receiver_email, :amount => 10.0 },
82
+ :currency_code => 'USD',
83
+ :cancel_url => 'example.com/cancel',
84
+ :return_url => 'http://example.com/thank_you'
85
+ )
86
+ }
87
+
88
+ subject { payment.pay }
89
+
90
+ before { subject }
91
+
92
+ its(:success?) { should be_false }
93
+ its(:valid?) { should be_false }
94
+ its(:errors) { should have(1).item }
95
+ end
96
+ end
97
+ end