spree_mercado_pago_payment_method 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (358) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/javascripts/{admin → spree/admin}/spree_mercado_pago_payment_method.js +0 -0
  3. data/app/assets/javascripts/spree/frontend/spree_mercado_pago_payment_method.js +25 -0
  4. data/app/controllers/spree/mercado_pago_controller.rb +53 -31
  5. data/app/models/mercado_pago/client.rb +63 -0
  6. data/app/models/mercado_pago/client/api.rb +43 -0
  7. data/app/models/mercado_pago/client/authentication.rb +36 -0
  8. data/app/models/mercado_pago/client/preferences.rb +20 -0
  9. data/app/models/mercado_pago/notification.rb +8 -0
  10. data/app/models/mercado_pago/order_preferences_builder.rb +68 -0
  11. data/app/models/spree/payment_method/mercado_pago.rb +46 -0
  12. data/app/services/mercado_pago/handle_received_notification.rb +18 -0
  13. data/app/services/mercado_pago/process_notification.rb +54 -0
  14. data/app/views/spree/checkout/payment/_mercadopago.html.erb +15 -1
  15. data/config/locales/en.yml +3 -12
  16. data/config/locales/es.yml +3 -13
  17. data/config/routes.rb +5 -7
  18. data/lib/generators/spree_mercado_pago_payment_method/install/install_generator.rb +15 -10
  19. data/lib/spree_mercado_pago_payment_method.rb +1 -0
  20. data/lib/spree_mercado_pago_payment_method/engine.rb +1 -2
  21. data/lib/tasks/mercado_user.rake +0 -1
  22. data/spec/controllers/spree/mercado_pago_controller_spec.rb +18 -76
  23. data/spec/dummy/README.rdoc +15 -248
  24. data/spec/dummy/Rakefile +1 -2
  25. data/spec/dummy/app/assets/stylesheets/application.css +5 -3
  26. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  27. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  28. data/spec/dummy/bin/bundle +3 -0
  29. data/spec/dummy/bin/rails +4 -0
  30. data/spec/dummy/bin/rake +4 -0
  31. data/spec/dummy/config.ru +1 -1
  32. data/spec/dummy/config/application.rb +0 -36
  33. data/spec/dummy/config/database.yml +3 -5
  34. data/spec/dummy/config/environment.rb +3 -5
  35. data/spec/dummy/config/environments/development.rb +19 -19
  36. data/spec/dummy/config/environments/production.rb +41 -30
  37. data/spec/dummy/config/environments/test.rb +3 -6
  38. data/spec/dummy/config/initializers/assets.rb +8 -0
  39. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  40. data/spec/dummy/config/initializers/devise.rb +3 -0
  41. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  42. data/spec/dummy/config/initializers/inflections.rb +6 -5
  43. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  44. data/spec/dummy/config/initializers/session_store.rb +1 -6
  45. data/spec/dummy/config/initializers/spree.rb +4 -4
  46. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  47. data/spec/dummy/config/locales/en.yml +20 -2
  48. data/spec/dummy/config/routes.rb +8 -2
  49. data/spec/dummy/config/secrets.yml +22 -0
  50. data/spec/dummy/config/spree.yml +1 -1
  51. data/spec/dummy/db/migrate/20141112193407_spree_one_two.spree.rb +482 -0
  52. data/spec/dummy/db/migrate/20141112193408_spree_promo_one_two.spree.rb +46 -0
  53. data/spec/dummy/db/migrate/{20121121030242_add_tax_rate_label.spree.rb → 20141112193409_add_tax_rate_label.spree.rb} +0 -0
  54. data/spec/dummy/db/migrate/{20121121030243_add_toggle_tax_rate_display.spree.rb → 20141112193410_add_toggle_tax_rate_display.spree.rb} +0 -0
  55. data/spec/dummy/db/migrate/20141112193411_remove_unused_preference_columns.spree.rb +9 -0
  56. data/spec/dummy/db/migrate/{20121121030244_add_lock_version_to_variant.spree.rb → 20141112193412_add_lock_version_to_variant.spree.rb} +0 -0
  57. data/spec/dummy/db/migrate/20141112193413_add_states_required_to_countries.spree.rb +6 -0
  58. data/spec/dummy/db/migrate/20141112193414_add_on_demand_to_product_and_variant.spree.rb +7 -0
  59. data/spec/dummy/db/migrate/{20121121030245_remove_not_null_constraint_from_products_on_hand.spree.rb → 20141112193415_remove_not_null_constraint_from_products_on_hand.spree.rb} +0 -0
  60. data/spec/dummy/db/migrate/20141112193416_split_prices_from_variants.spree.rb +32 -0
  61. data/spec/dummy/db/migrate/20141112193417_remove_not_null_from_spree_prices_amount.spree.rb +10 -0
  62. data/spec/dummy/db/migrate/20141112193418_add_currency_to_line_items.spree.rb +6 -0
  63. data/spec/dummy/db/migrate/20141112193419_add_currency_to_orders.spree.rb +6 -0
  64. data/spec/dummy/db/migrate/20141112193420_add_cost_currency_to_variants.spree.rb +6 -0
  65. data/spec/dummy/db/migrate/20141112193421_remove_display_on_from_payment_methods.spree.rb +6 -0
  66. data/spec/dummy/db/migrate/20141112193422_add_position_to_taxonomies.spree.rb +6 -0
  67. data/spec/dummy/db/migrate/20141112193423_add_last_ip_to_spree_orders.spree.rb +6 -0
  68. data/spec/dummy/db/migrate/20141112193424_add_state_to_spree_adjustments.spree.rb +7 -0
  69. data/spec/dummy/db/migrate/20141112193425_add_display_on_to_spree_payment_methods.spree.rb +10 -0
  70. data/spec/dummy/db/migrate/20141112193426_add_position_to_product_properties.spree.rb +7 -0
  71. data/spec/dummy/db/migrate/20141112193427_add_identifier_to_spree_payments.spree.rb +6 -0
  72. data/spec/dummy/db/migrate/20141112193428_add_order_id_index_to_payments.spree.rb +10 -0
  73. data/spec/dummy/db/migrate/20141112193429_add_primary_to_spree_products_taxons.spree.rb +6 -0
  74. data/spec/dummy/db/migrate/20141112193430_create_spree_stock_items.spree.rb +15 -0
  75. data/spec/dummy/db/migrate/20141112193431_create_spree_stock_locations.spree.rb +12 -0
  76. data/spec/dummy/db/migrate/20141112193432_create_default_stock.spree.rb +31 -0
  77. data/spec/dummy/db/migrate/20141112193433_add_order_id_index_to_shipments.spree.rb +6 -0
  78. data/spec/dummy/db/migrate/20141112193434_change_meta_description_on_spree_products_to_text.spree.rb +6 -0
  79. data/spec/dummy/db/migrate/20141112193435_add_stock_location_id_to_spree_shipments.spree.rb +6 -0
  80. data/spec/dummy/db/migrate/20141112193436_add_pending_to_inventory_unit.spree.rb +7 -0
  81. data/spec/dummy/db/migrate/20141112193437_remove_on_demand_from_product_and_variant.spree.rb +7 -0
  82. data/spec/dummy/db/migrate/20141112193438_create_shipping_method_zone.spree.rb +23 -0
  83. data/spec/dummy/db/migrate/20141112193439_remove_shipping_category_id_from_shipping_method.spree.rb +6 -0
  84. data/spec/dummy/db/migrate/20141112193440_create_shipping_method_categories.spree.rb +14 -0
  85. data/spec/dummy/db/migrate/20141112193441_add_tracking_url_to_spree_shipping_methods.spree.rb +6 -0
  86. data/spec/dummy/db/migrate/20141112193442_create_spree_shipping_rates.spree.rb +25 -0
  87. data/spec/dummy/db/migrate/20141112193443_remove_category_match_attributes_from_shipping_method.spree.rb +8 -0
  88. data/spec/dummy/db/migrate/20141112193444_create_stock_movements.spree.rb +13 -0
  89. data/spec/dummy/db/migrate/20141112193445_add_address_fields_to_stock_location.spree.rb +23 -0
  90. data/spec/dummy/db/migrate/20141112193446_add_active_field_to_stock_locations.spree.rb +6 -0
  91. data/spec/dummy/db/migrate/20141112193447_add_backorderable_to_stock_item.spree.rb +6 -0
  92. data/spec/dummy/db/migrate/20141112193448_add_default_quantity_to_stock_movement.spree.rb +6 -0
  93. data/spec/dummy/db/migrate/20141112193449_add_source_and_destination_to_stock_movements.spree.rb +9 -0
  94. data/spec/dummy/db/migrate/20141112193450_change_orders_total_precision.spree.rb +9 -0
  95. data/spec/dummy/db/migrate/20141112193451_change_spree_payments_amount_precision.spree.rb +8 -0
  96. data/spec/dummy/db/migrate/20141112193452_change_spree_return_authorization_amount_precision.spree.rb +8 -0
  97. data/spec/dummy/db/migrate/20141112193453_change_adjustments_amount_precision.spree.rb +8 -0
  98. data/spec/dummy/db/migrate/20141112193454_add_originator_to_stock_movement.spree.rb +8 -0
  99. data/spec/dummy/db/migrate/20141112193455_drop_source_and_destination_from_stock_movement.spree.rb +16 -0
  100. data/spec/dummy/db/migrate/20141112193456_migrate_inventory_unit_sold_to_on_hand.spree.rb +10 -0
  101. data/spec/dummy/db/migrate/20141112193457_add_stock_location_to_rma.spree.rb +6 -0
  102. data/spec/dummy/db/migrate/20141112193458_update_shipment_state_for_canceled_orders.spree.rb +16 -0
  103. data/spec/dummy/db/migrate/20141112193459_add_seo_metas_to_taxons.spree.rb +10 -0
  104. data/spec/dummy/db/migrate/20141112193460_remove_stock_item_and_variant_lock.spree.rb +15 -0
  105. data/spec/dummy/db/migrate/20141112193461_add_name_to_spree_credit_cards.spree.rb +6 -0
  106. data/spec/dummy/db/migrate/20141112193462_update_name_fields_on_spree_credit_cards.spree.rb +14 -0
  107. data/spec/dummy/db/migrate/20141112193463_add_index_to_source_columns_on_adjustments.spree.rb +6 -0
  108. data/spec/dummy/db/migrate/20141112193464_update_adjustment_states.spree.rb +17 -0
  109. data/spec/dummy/db/migrate/20141112193465_add_shipping_rates_to_shipments.spree.rb +16 -0
  110. data/spec/dummy/db/migrate/20141112193466_create_spree_stock_transfers.spree.rb +15 -0
  111. data/spec/dummy/db/migrate/20141112193467_drop_products_count_on_hand.spree.rb +6 -0
  112. data/spec/dummy/db/migrate/20141112193468_set_default_shipping_rate_cost.spree.rb +6 -0
  113. data/spec/dummy/db/migrate/20141112193469_add_number_to_stock_transfer.spree.rb +24 -0
  114. data/spec/dummy/db/migrate/20141112193470_add_sku_index_to_spree_variants.spree.rb +6 -0
  115. data/spec/dummy/db/migrate/20141112193471_add_backorderable_default_to_spree_stock_location.spree.rb +6 -0
  116. data/spec/dummy/db/migrate/20141112193472_add_propage_all_variants_to_spree_stock_location.spree.rb +6 -0
  117. data/spec/dummy/db/migrate/20141112193473_rename_shipping_methods_zones_to_spree_shipping_methods_zones.spree.rb +11 -0
  118. data/spec/dummy/db/migrate/20141112193474_add_user_id_index_to_spree_orders.spree.rb +6 -0
  119. data/spec/dummy/db/migrate/20141112193475_add_updated_at_to_spree_countries.spree.rb +10 -0
  120. data/spec/dummy/db/migrate/20141112193476_add_updated_at_to_spree_states.spree.rb +10 -0
  121. data/spec/dummy/db/migrate/20141112193477_add_cvv_result_code_and_cvv_result_message_to_spree_payments.spree.rb +7 -0
  122. data/spec/dummy/db/migrate/20141112193478_add_unique_index_to_permalink_on_spree_products.spree.rb +6 -0
  123. data/spec/dummy/db/migrate/20141112193479_add_unique_index_to_orders_shipments_and_stock_transfers.spree.rb +8 -0
  124. data/spec/dummy/db/migrate/20141112193480_add_deleted_at_to_spree_tax_rates.spree.rb +6 -0
  125. data/spec/dummy/db/migrate/20141112193481_remove_lock_version_from_inventory_units.spree.rb +7 -0
  126. data/spec/dummy/db/migrate/20141112193482_add_cost_price_to_line_item.spree.rb +6 -0
  127. data/spec/dummy/db/migrate/20141112193483_set_backorderable_to_default_to_false.spree.rb +7 -0
  128. data/spec/dummy/db/migrate/20141112193484_add_created_by_id_to_spree_orders.spree.rb +6 -0
  129. data/spec/dummy/db/migrate/20141112193485_index_completed_at_on_spree_orders.spree.rb +6 -0
  130. data/spec/dummy/db/migrate/20141112193486_add_tax_category_id_to_spree_line_items.spree.rb +6 -0
  131. data/spec/dummy/db/migrate/20141112193487_migrate_tax_categories_to_line_items.spree.rb +11 -0
  132. data/spec/dummy/db/migrate/20141112193488_drop_spree_mail_methods.spree.rb +13 -0
  133. data/spec/dummy/db/migrate/20141112193489_set_default_stock_location_on_shipments.spree.rb +9 -0
  134. data/spec/dummy/db/migrate/20141112193490_upgrade_adjustments.spree.rb +40 -0
  135. data/spec/dummy/db/migrate/20141112193491_rename_adjustment_fields.spree.rb +15 -0
  136. data/spec/dummy/db/migrate/20141112193492_add_admin_name_column_to_spree_shipping_methods.spree.rb +6 -0
  137. data/spec/dummy/db/migrate/20141112193493_add_admin_name_column_to_spree_stock_locations.spree.rb +6 -0
  138. data/spec/dummy/db/migrate/20141112193494_add_shipment_total_to_spree_orders.spree.rb +6 -0
  139. data/spec/dummy/db/migrate/20141112193495_expand_order_number_size.spree.rb +10 -0
  140. data/spec/dummy/db/migrate/20141112193496_rename_activators_to_promotions.spree.rb +6 -0
  141. data/spec/dummy/db/migrate/20141112193497_add_adjustment_total_to_line_items.spree.rb +6 -0
  142. data/spec/dummy/db/migrate/20141112193498_add_adjustment_total_to_shipments.spree.rb +6 -0
  143. data/spec/dummy/db/migrate/20141112193499_add_depth_to_spree_taxons.spree.rb +17 -0
  144. data/spec/dummy/db/migrate/20141112193500_add_tax_total_to_line_items_shipments_and_orders.spree.rb +9 -0
  145. data/spec/dummy/db/migrate/20141112193501_add_shipping_category_to_shipping_methods_and_products.spree.rb +16 -0
  146. data/spec/dummy/db/migrate/20141112193502_migrate_old_shipping_calculators.spree.rb +20 -0
  147. data/spec/dummy/db/migrate/20141112193503_add_code_to_spree_promotion_rules.spree.rb +6 -0
  148. data/spec/dummy/db/migrate/20141112193504_change_states_required_for_countries.spree.rb +10 -0
  149. data/spec/dummy/db/migrate/20141112193505_add_deleted_at_to_spree_stock_items.spree.rb +6 -0
  150. data/spec/dummy/db/migrate/20141112193506_remove_promotions_event_name_field.spree.rb +6 -0
  151. data/spec/dummy/db/migrate/20141112193507_add_promo_total_to_line_items_and_shipments_and_orders.spree.rb +8 -0
  152. data/spec/dummy/db/migrate/20141112193508_remove_unused_credit_card_fields.spree.rb +17 -0
  153. data/spec/dummy/db/migrate/20141112193509_add_track_inventory_to_variant.spree.rb +6 -0
  154. data/spec/dummy/db/migrate/20141112193510_add_tax_category_to_variants.spree.rb +7 -0
  155. data/spec/dummy/db/migrate/20141112193511_add_channel_to_spree_orders.spree.rb +6 -0
  156. data/spec/dummy/db/migrate/20141112193512_add_included_to_adjustments.spree.rb +6 -0
  157. data/spec/dummy/db/migrate/20141112193513_rename_tax_total_fields.spree.rb +12 -0
  158. data/spec/dummy/db/migrate/20141112193514_add_line_item_id_to_spree_inventory_units.spree.rb +22 -0
  159. data/spec/dummy/db/migrate/20141112193515_add_updated_at_to_variants.spree.rb +6 -0
  160. data/spec/dummy/db/migrate/20141112193516_add_position_to_classifications.spree.rb +6 -0
  161. data/spec/dummy/db/migrate/20141112193517_create_spree_orders_promotions.spree.rb +9 -0
  162. data/spec/dummy/db/migrate/20141112193518_unique_shipping_method_categories.spree.rb +25 -0
  163. data/spec/dummy/db/migrate/20141112193519_add_item_count_to_spree_orders.spree.rb +6 -0
  164. data/spec/dummy/db/migrate/20141112193520_remove_value_type_from_spree_preferences.spree.rb +9 -0
  165. data/spec/dummy/db/migrate/20141112193521_rename_permalink_to_slug_for_products.spree.rb +6 -0
  166. data/spec/dummy/db/migrate/20141112193522_add_index_to_variant_id_and_currency_on_prices.spree.rb +6 -0
  167. data/spec/dummy/db/migrate/20141112193523_rename_activator_id_in_rules_and_actions_to_promotion_id.spree.rb +7 -0
  168. data/spec/dummy/db/migrate/20141112193524_add_deleted_at_to_spree_prices.spree.rb +6 -0
  169. data/spec/dummy/db/migrate/20141112193525_add_approver_id_and_approved_at_to_orders.spree.rb +7 -0
  170. data/spec/dummy/db/migrate/20141112193526_add_confirmation_delivered_to_spree_orders.spree.rb +6 -0
  171. data/spec/dummy/db/migrate/20141112193527_add_auto_capture_to_payment_methods.spree.rb +6 -0
  172. data/spec/dummy/db/migrate/20141112193528_create_spree_payment_capture_events.spree.rb +13 -0
  173. data/spec/dummy/db/migrate/20141112193529_add_uncaptured_amount_to_payments.spree.rb +6 -0
  174. data/spec/dummy/db/migrate/20141112193530_default_variant_weight_to_zero.spree.rb +12 -0
  175. data/spec/dummy/db/migrate/20141112193531_add_tax_category_id_to_shipping_methods.spree.rb +6 -0
  176. data/spec/dummy/db/migrate/20141112193532_add_tax_rate_id_to_shipping_rates.spree.rb +6 -0
  177. data/spec/dummy/db/migrate/20141112193533_add_pre_tax_amount_to_line_items_and_shipments.spree.rb +7 -0
  178. data/spec/dummy/db/migrate/20141112193534_add_more_indexes.spree.rb +14 -0
  179. data/spec/dummy/db/migrate/20141112193535_add_considered_risky_to_orders.spree.rb +6 -0
  180. data/spec/dummy/db/migrate/20141112193536_add_preference_store_to_everything.spree.rb +9 -0
  181. data/spec/dummy/db/migrate/20141112193537_add_user_id_to_spree_credit_cards.spree.rb +14 -0
  182. data/spec/dummy/db/migrate/20141112193538_migrate_old_preferences.spree.rb +24 -0
  183. data/spec/dummy/db/migrate/20141112193539_create_spree_stores.spree.rb +26 -0
  184. data/spec/dummy/db/migrate/20141112193540_create_store_from_preferences.spree.rb +31 -0
  185. data/spec/dummy/db/migrate/20141112193541_add_timestamps_to_spree_assets.spree.rb +7 -0
  186. data/spec/dummy/db/migrate/20141112193542_add_additional_store_fields.spree.rb +9 -0
  187. data/spec/dummy/db/migrate/20141112193543_add_many_missing_indexes.spree.rb +19 -0
  188. data/spec/dummy/db/migrate/20141112193544_correct_some_polymorphic_index_and_add_more_missing.spree.rb +67 -0
  189. data/spec/dummy/db/migrate/20141112193545_add_user_id_created_by_id_index_to_order.spree.rb +6 -0
  190. data/spec/dummy/db/migrate/20141112193546_change_spree_price_amount_precision.spree.rb +9 -0
  191. data/spec/dummy/db/migrate/20141112193547_add_token_to_spree_orders.spree.rb +6 -0
  192. data/spec/dummy/db/migrate/20141112193548_move_order_token_from_tokenized_permission.spree.rb +30 -0
  193. data/spec/dummy/db/migrate/20141112193549_set_shipment_total_for_users_upgrading.spree.rb +11 -0
  194. data/spec/dummy/db/migrate/20141112193550_drop_credit_card_first_name_and_last_name.spree.rb +7 -0
  195. data/spec/dummy/db/migrate/20141112193551_add_deleted_at_to_spree_promotion_actions.spree.rb +7 -0
  196. data/spec/dummy/db/migrate/20141112193552_remove_uncaptured_amount_from_spree_payments.spree.rb +6 -0
  197. data/spec/dummy/db/migrate/20141112193553_add_default_to_shipment_cost.spree.rb +11 -0
  198. data/spec/dummy/db/migrate/20141112193554_default_pre_tax_amount_should_be_zero.spree.rb +7 -0
  199. data/spec/dummy/db/migrate/20141112193555_add_state_lock_version_to_order.spree.rb +6 -0
  200. data/spec/dummy/db/migrate/20141112193556_fix_adjustment_order_presence.spree.rb +14 -0
  201. data/spec/dummy/db/migrate/20141112193557_update_classifications_positions.spree.rb +10 -0
  202. data/spec/dummy/db/migrate/20141112193558_add_api_key_to_spree_users.spree_api.rb +8 -0
  203. data/spec/dummy/db/migrate/20141112193559_resize_api_key_field.spree_api.rb +8 -0
  204. data/spec/dummy/db/migrate/20141112193560_rename_api_key_to_spree_api_key.spree_api.rb +8 -0
  205. data/spec/dummy/db/migrate/20141112193561_add_index_to_user_spree_api_key.spree_api.rb +8 -0
  206. data/spec/dummy/db/migrate/{20121121030246_create_users.spree_auth.rb → 20141112193562_create_users.spree_auth.rb} +0 -0
  207. data/spec/dummy/db/migrate/{20121121030247_rename_columns_for_devise.spree_auth.rb → 20141112193563_rename_columns_for_devise.spree_auth.rb} +0 -0
  208. data/spec/dummy/db/migrate/{20121121030248_convert_user_remember_field.spree_auth.rb → 20141112193564_convert_user_remember_field.spree_auth.rb} +0 -0
  209. data/spec/dummy/db/migrate/{20121121030249_add_reset_password_sent_at_to_spree_users.spree_auth.rb → 20141112193565_add_reset_password_sent_at_to_spree_users.spree_auth.rb} +0 -0
  210. data/spec/dummy/db/migrate/{20121121030250_make_users_email_index_unique.spree_auth.rb → 20141112193566_make_users_email_index_unique.spree_auth.rb} +0 -0
  211. data/spec/dummy/db/migrate/20141202172111_create_spree_mercado_pago_notifications.spree_mercado_pago_payment_method_engine.rb +10 -0
  212. data/spec/dummy/db/schema.rb +581 -260
  213. data/spec/dummy/db/seeds.rb +2 -2
  214. data/spec/dummy/db/spree_development.sqlite3 +0 -0
  215. data/spec/dummy/db/spree_test.sqlite3 +0 -0
  216. data/spec/dummy/log/development.log +27822 -1376
  217. data/spec/dummy/log/test.log +87064 -37048
  218. data/spec/dummy/public/404.html +54 -13
  219. data/spec/dummy/public/422.html +54 -13
  220. data/spec/dummy/public/500.html +53 -12
  221. data/spec/dummy/tmp/cache/17E/D61/spree%2Fapp_configuration%2Fdefault_seo_title +1 -0
  222. data/spec/dummy/tmp/cache/2CC/B21/spree%2Fapp_configuration%2Frequire_master_price +1 -0
  223. data/spec/dummy/tmp/cache/334/AA1/spree%2Fapp_configuration%2Fdefault_meta_keywords +1 -0
  224. data/spec/dummy/tmp/cache/397/F31/spree%2Fapp_configuration%2Fbinary_inventory_cache +1 -0
  225. data/spec/dummy/tmp/cache/39C/F91/spree%2Fapp_configuration%2Ftax_using_ship_address +1 -0
  226. data/spec/dummy/tmp/cache/3A7/4A1/spree%2Fapp_configuration%2Faddress_requires_state +1 -0
  227. data/spec/dummy/tmp/cache/3B7/CD1/spree%2Fapp_configuration%2Fredirect_https_to_http +1 -0
  228. data/spec/dummy/tmp/cache/3BE/851/spree%2Fapp_configuration%2Ftrack_inventory_levels +1 -0
  229. data/spec/dummy/tmp/cache/460/D81/spree%2Fapp_configuration%2Fdefault_meta_description +1 -0
  230. data/spec/dummy/tmp/cache/5AE/6A1/spree%2Fapp_configuration%2Falways_include_confirm_step +1 -0
  231. data/spec/dummy/tmp/cache/DD9/320/spree%2Fapp_configuration%2Fsite_url +1 -0
  232. data/spec/dummy/tmp/cache/DDD/2D0/spree%2Fapp_configuration%2Fcurrency +1 -0
  233. data/spec/dummy/tmp/cache/E27/320/spree%2Fapp_configuration%2Fsite_name +1 -0
  234. data/spec/dummy/tmp/cache/E9B/7F0/spree%2Fapp_configuration%2Fmails_from +1 -0
  235. data/spec/dummy/tmp/cache/F01/FD0/spree%2Ffrontend_configuration%2Flocale +1 -0
  236. data/spec/dummy/{app/assets/javascripts/admin → vendor/assets/javascripts/spree/backend}/all.js +2 -1
  237. data/spec/dummy/{app/assets/javascripts/store → vendor/assets/javascripts/spree/frontend}/all.js +2 -1
  238. data/spec/dummy/{app/assets/stylesheets/admin → vendor/assets/stylesheets/spree/backend}/all.css +2 -1
  239. data/spec/dummy/{app/assets/stylesheets/store → vendor/assets/stylesheets/spree/frontend}/all.css +2 -1
  240. data/spec/models/mercado_pago/client_spec.rb +138 -0
  241. data/spec/models/mercado_pago/notification_spec.rb +17 -0
  242. data/spec/models/mercado_pago/order_preferences_builder_spec.rb +66 -0
  243. data/spec/services/mercado_pago/process_notification_spec.rb +57 -0
  244. data/spec/spec_helper.rb +12 -53
  245. metadata +444 -328
  246. data/app/assets/javascripts/store/spree_mercado_pago_payment_method.js +0 -1
  247. data/app/controllers/spree/checkout_controller_decorator.rb +0 -29
  248. data/app/models/payment_method/mercado_pago.rb +0 -33
  249. data/app/models/spree_mercado_pago_client.rb +0 -102
  250. data/app/views/spree/mercado_pago/failure.html.erb +0 -1
  251. data/app/views/spree/mercado_pago/pending.html.erb +0 -1
  252. data/app/views/spree/mercado_pago/success.html.erb +0 -1
  253. data/spec/controllers/spree/checkout_controller_spec.rb +0 -57
  254. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  255. data/spec/dummy/db/migrate/20121121030140_spree_zero_nine_zero.spree.rb +0 -392
  256. data/spec/dummy/db/migrate/20121121030141_create_indexes_for_inventory_units.spree.rb +0 -7
  257. data/spec/dummy/db/migrate/20121121030142_add_count_on_hand_to_variants_and_products.spree.rb +0 -50
  258. data/spec/dummy/db/migrate/20121121030143_change_taxons_to_nested_set.spree.rb +0 -47
  259. data/spec/dummy/db/migrate/20121121030144_move_to_configurable_gateways.spree.rb +0 -55
  260. data/spec/dummy/db/migrate/20121121030145_add_open_id_authentication_tables.spree.rb +0 -16
  261. data/spec/dummy/db/migrate/20121121030146_add_openid_field_to_users.spree.rb +0 -27
  262. data/spec/dummy/db/migrate/20121121030147_change_preference_value_type.spree.rb +0 -11
  263. data/spec/dummy/db/migrate/20121121030148_create_billing_integrations.spree.rb +0 -13
  264. data/spec/dummy/db/migrate/20121121030149_charge_refactoring.spree.rb +0 -40
  265. data/spec/dummy/db/migrate/20121121030150_add_some_indexes.spree.rb +0 -12
  266. data/spec/dummy/db/migrate/20121121030151_checkout_state_machine.spree.rb +0 -6
  267. data/spec/dummy/db/migrate/20121121030152_state_for_shipments.spree.rb +0 -6
  268. data/spec/dummy/db/migrate/20121121030153_make_state_events_polymorphic.spree.rb +0 -13
  269. data/spec/dummy/db/migrate/20121121030154_ship_address_id_for_checkouts.spree.rb +0 -6
  270. data/spec/dummy/db/migrate/20121121030155_shipping_method_id_for_checkouts.spree.rb +0 -6
  271. data/spec/dummy/db/migrate/20121121030156_creditcard_last_four_digits.spree.rb +0 -15
  272. data/spec/dummy/db/migrate/20121121030157_populate_legacy_shipment_state.spree.rb +0 -16
  273. data/spec/dummy/db/migrate/20121121030158_add_cost_price.spree.rb +0 -6
  274. data/spec/dummy/db/migrate/20121121030159_shipment_id_for_inventory_units.spree.rb +0 -26
  275. data/spec/dummy/db/migrate/20121121030160_cim_fields_for_creditcards.spree.rb +0 -7
  276. data/spec/dummy/db/migrate/20121121030161_create_return_authorizations.spree.rb +0 -13
  277. data/spec/dummy/db/migrate/20121121030162_add_return_authorization_to_inventory_units.spree.rb +0 -6
  278. data/spec/dummy/db/migrate/20121121030163_create_trackers.spree.rb +0 -11
  279. data/spec/dummy/db/migrate/20121121030164_creditcard_id_for_creditcard_txns.spree.rb +0 -6
  280. data/spec/dummy/db/migrate/20121121030165_original_creditcard_txn_id_for_creditcard_txns.spree.rb +0 -6
  281. data/spec/dummy/db/migrate/20121121030166_add_test_mode_to_billing_integration.spree.rb +0 -7
  282. data/spec/dummy/db/migrate/20121121030167_create_payment_methods.spree.rb +0 -17
  283. data/spec/dummy/db/migrate/20121121030168_polymorphic_payments.spree.rb +0 -43
  284. data/spec/dummy/db/migrate/20121121030169_change_payments_payment_method_to_belongs_to.spree.rb +0 -12
  285. data/spec/dummy/db/migrate/20121121030170_assign_creditcard_txns_to_payment.spree.rb +0 -24
  286. data/spec/dummy/db/migrate/20121121030171_sti_for_transactions.spree.rb +0 -16
  287. data/spec/dummy/db/migrate/20121121030172_drop_billing_integrations.spree.rb +0 -17
  288. data/spec/dummy/db/migrate/20121121030173_deleted_at_for_payment_methods.spree.rb +0 -15
  289. data/spec/dummy/db/migrate/20121121030174_add_adjustments_index.spree.rb +0 -7
  290. data/spec/dummy/db/migrate/20121121030175_add_alt_text_to_images.spree.rb +0 -6
  291. data/spec/dummy/db/migrate/20121121030176_fix_existing_coupon_credits.spree.rb +0 -14
  292. data/spec/dummy/db/migrate/20121121030177_add_display_to_payment_methods.spree.rb +0 -6
  293. data/spec/dummy/db/migrate/20121121030178_add_addresses_checkouts_indexes.spree.rb +0 -9
  294. data/spec/dummy/db/migrate/20121121030179_add_icon_to_taxons.spree.rb +0 -18
  295. data/spec/dummy/db/migrate/20121121030180_add_description_to_taxons.spree.rb +0 -12
  296. data/spec/dummy/db/migrate/20121121030181_index_for_shipments_number.spree.rb +0 -6
  297. data/spec/dummy/db/migrate/20121121030182_add_index_on_users_persistence_token.spree.rb +0 -8
  298. data/spec/dummy/db/migrate/20121121030183_add_default_to_tax_categories.spree.rb +0 -6
  299. data/spec/dummy/db/migrate/20121121030184_add_display_to_shipping_methods.spree.rb +0 -6
  300. data/spec/dummy/db/migrate/20121121030185_rename_payment_method_display.spree.rb +0 -6
  301. data/spec/dummy/db/migrate/20121121030186_rename_preferences_field.spree.rb +0 -6
  302. data/spec/dummy/db/migrate/20121121030187_add_guest_flag.spree.rb +0 -8
  303. data/spec/dummy/db/migrate/20121121030188_drop_order_token.spree.rb +0 -10
  304. data/spec/dummy/db/migrate/20121121030189_payments_state_and_assigned_to_order_only.spree.rb +0 -15
  305. data/spec/dummy/db/migrate/20121121030190_create_address_keys_for_order.spree.rb +0 -7
  306. data/spec/dummy/db/migrate/20121121030191_payment_total_for_orders.spree.rb +0 -6
  307. data/spec/dummy/db/migrate/20121121030192_shipping_method_id_for_orders.spree.rb +0 -6
  308. data/spec/dummy/db/migrate/20121121030193_add_shipment_and_payment_state.spree.rb +0 -7
  309. data/spec/dummy/db/migrate/20121121030194_refactor_adjustments.spree.rb +0 -30
  310. data/spec/dummy/db/migrate/20121121030195_response_code_and_avs_response_for_payments.spree.rb +0 -7
  311. data/spec/dummy/db/migrate/20121121030196_change_guest_flag_to_anonymous.spree.rb +0 -8
  312. data/spec/dummy/db/migrate/20121121030197_email_for_orders.spree.rb +0 -6
  313. data/spec/dummy/db/migrate/20121121030198_create_mail_methods.spree.rb +0 -11
  314. data/spec/dummy/db/migrate/20121121030199_rename_frozen_to_locked.spree.rb +0 -6
  315. data/spec/dummy/db/migrate/20121121030200_move_special_instructions_to_orders.spree.rb +0 -11
  316. data/spec/dummy/db/migrate/20121121030201_create_log_entries.spree.rb +0 -12
  317. data/spec/dummy/db/migrate/20121121030202_migrate_transactions_to_payment_state.spree.rb +0 -99
  318. data/spec/dummy/db/migrate/20121121030203_delete_in_progress_orders.spree.rb +0 -20
  319. data/spec/dummy/db/migrate/20121121030204_migrate_checkout_to_orders.spree.rb +0 -24
  320. data/spec/dummy/db/migrate/20121121030205_remove_shipped_state.spree.rb +0 -13
  321. data/spec/dummy/db/migrate/20121121030206_prevent_nil_payment_total.spree.rb +0 -9
  322. data/spec/dummy/db/migrate/20121121030207_prevent_nil_email.spree.rb +0 -10
  323. data/spec/dummy/db/migrate/20121121030208_generate_anonymous_users.spree.rb +0 -21
  324. data/spec/dummy/db/migrate/20121121030209_update_order_state.spree.rb +0 -13
  325. data/spec/dummy/db/migrate/20121121030210_cleanup_legacy_tables.spree.rb +0 -12
  326. data/spec/dummy/db/migrate/20121121030211_remove_number_and_cvv_from_credicard.spree.rb +0 -12
  327. data/spec/dummy/db/migrate/20121121030212_drop_anonymous_field_for_user.spree.rb +0 -12
  328. data/spec/dummy/db/migrate/20121121030213_renamed_rma_cancelled_state.spree.rb +0 -10
  329. data/spec/dummy/db/migrate/20121121030214_fix_problematic_index_names.spree.rb +0 -14
  330. data/spec/dummy/db/migrate/20121121030215_add_position_to_variants.spree.rb +0 -6
  331. data/spec/dummy/db/migrate/20121121030216_add_next_state_to_state_events.spree.rb +0 -6
  332. data/spec/dummy/db/migrate/20121121030217_add_position_to_option_types.spree.rb +0 -6
  333. data/spec/dummy/db/migrate/20121121030218_remove_trailing_slashes_in_taxon_permalinks.spree.rb +0 -20
  334. data/spec/dummy/db/migrate/20121121030219_create_activators.spree.rb +0 -15
  335. data/spec/dummy/db/migrate/20121121030220_eligible_for_adjustments.spree.rb +0 -6
  336. data/spec/dummy/db/migrate/20121121030221_namespace_top_level_models.spree.rb +0 -67
  337. data/spec/dummy/db/migrate/20121121030222_migrate_namespaced_polymorphic_models.spree.rb +0 -53
  338. data/spec/dummy/db/migrate/20121121030223_make_adjustments_polymorphic.spree.rb +0 -10
  339. data/spec/dummy/db/migrate/20121121030224_add_company_to_addresses.spree.rb +0 -6
  340. data/spec/dummy/db/migrate/20121121030225_add_inc_tax_to_tax_rates.spree.rb +0 -6
  341. data/spec/dummy/db/migrate/20121121030226_rename_inc_price_attribute.spree.rb +0 -6
  342. data/spec/dummy/db/migrate/20121121030227_add_default_tax_zone.spree.rb +0 -6
  343. data/spec/dummy/db/migrate/20121121030228_associate_shipping_methods_and_shipping_categories.spree.rb +0 -8
  344. data/spec/dummy/db/migrate/20121121030229_add_match_rules_to_shipping_methods.spree.rb +0 -8
  345. data/spec/dummy/db/migrate/20121121030230_new_preferences.spree.rb +0 -49
  346. data/spec/dummy/db/migrate/20121121030231_rename_state_events_to_state_changes.spree.rb +0 -10
  347. data/spec/dummy/db/migrate/20121121030232_add_deleted_at_to_tax_category.spree.rb +0 -6
  348. data/spec/dummy/db/migrate/20121121030233_migrate_images_from_products_to_variants.spree.rb +0 -38
  349. data/spec/dummy/db/migrate/20121121030234_rename_attachment_size_to_attachment_file_size.spree.rb +0 -6
  350. data/spec/dummy/db/migrate/20121121030235_increase_scale_of_tax_rate_amount.spree.rb +0 -10
  351. data/spec/dummy/db/migrate/20121121030236_create_tokenized_permissions_table.spree.rb +0 -17
  352. data/spec/dummy/db/migrate/20121121030237_convert_sales_tax_to_default_tax.spree.rb +0 -10
  353. data/spec/dummy/db/migrate/20121121030238_rename_creditcards_to_credit_cards.spree.rb +0 -12
  354. data/spec/dummy/db/migrate/20121121030239_add_deleted_at_to_spree_shipping_methods.spree.rb +0 -6
  355. data/spec/dummy/db/migrate/20121121030240_remove_credit_total_from_orders.spree.rb +0 -6
  356. data/spec/dummy/db/migrate/20121121030241_add_counter_cache_to_zone_members.spree.rb +0 -15
  357. data/spec/dummy/script/rails +0 -6
  358. data/spec/models/spree_mercado_pago_client_spec.rb +0 -131
@@ -1 +0,0 @@
1
- //= require store/spree_core
@@ -1,29 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Spree::CheckoutController.class_eval do
3
- before_filter :redirect_to_mercado_pago_if_needed, :only => [:update]
4
-
5
- def redirect_to_mercado_pago_if_needed
6
- return unless params[:state] == "payment"
7
-
8
- selected_method_id = params[:order][:payments_attributes].first[:payment_method_id]
9
- @payment_method = Spree::PaymentMethod.find(selected_method_id)
10
-
11
- if @payment_method && @payment_method.kind_of?(PaymentMethod::MercadoPago)
12
- @order.update_attributes(object_params)
13
-
14
- back_urls = {
15
- success: spree.mercado_pago_success_url(order_number: @order.number),
16
- pending: spree.mercado_pago_pending_url(order_number: @order.number),
17
- failure: spree.mercado_pago_failure_url(order_number: @order.number)
18
- }
19
-
20
- m = SpreeMercadoPagoClient.new(@order, back_urls)
21
-
22
- if m.authenticate && m.send_data
23
- redirect_to m.redirect_url
24
- else
25
- render :action => :mercado_pago_error
26
- end
27
- end
28
- end
29
- end
@@ -1,33 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class PaymentMethod::MercadoPago < Spree::PaymentMethod
3
- attr_accessible :preferred_client_id, :preferred_client_secret
4
-
5
- preference :client_id, :integer
6
- preference :client_secret, :string
7
-
8
- def payment_profiles_supported?
9
- false
10
- end
11
-
12
- def actions
13
- %w{capture void}
14
- end
15
-
16
- # Indicates whether its possible to capture the payment
17
- def can_capture?(payment)
18
- ['checkout', 'pending'].include?(payment.state)
19
- end
20
-
21
- # Indicates whether its possible to void the payment.
22
- def can_void?(payment)
23
- payment.state != 'void'
24
- end
25
-
26
- def capture(*args)
27
- ActiveMerchant::Billing::Response.new(true, "", {}, {})
28
- end
29
-
30
- def void(*args)
31
- ActiveMerchant::Billing::Response.new(true, "", {}, {})
32
- end
33
- end
@@ -1,102 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'rest_client'
3
-
4
- class SpreeMercadoPagoClient
5
- # These three includes are because of the user of line_item_description from
6
- # ProductsHelper
7
- include ActionView::Helpers::TextHelper
8
- include ActionView::Helpers::SanitizeHelper
9
- include Spree::ProductsHelper
10
-
11
- attr_reader :errors
12
- attr_reader :auth_response
13
- attr_reader :preferences_response
14
-
15
- def initialize(order, callbacks)
16
- unless callbacks[:success] && callbacks[:pending] && callbacks[:failure]
17
- raise "Url callbacks where not specified"
18
- end
19
-
20
- @order = order
21
- @callbacks = callbacks
22
- @errors = []
23
- config_options
24
- end
25
-
26
- def authenticate
27
- response = send_authentication_request
28
-
29
- if response.code != 200
30
- @auth_response = nil
31
- @errors << I18n.t(:mp_authentication_error)
32
- else
33
- @errors = []
34
- @auth_response = ActiveSupport::JSON.decode(response)
35
- end
36
-
37
- @auth_response
38
- end
39
-
40
- def send_data
41
- response = send_preferences_request
42
-
43
- if response.code != 201
44
- @preferences_response = nil
45
- @errors << I18n.t(:mp_preferences_setup_error)
46
- else
47
- @errors = []
48
- @preferences_response = ActiveSupport::JSON.decode(response)
49
- end
50
-
51
- @preferences_response
52
- end
53
-
54
- def redirect_url
55
- @preferences_response["init_point"] if @preferences_response.present?
56
- end
57
-
58
- private
59
- def send_authentication_request
60
- client_id = @order.payments.last.payment_method.preferred_client_id
61
- client_secret = @order.payments.last.payment_method.preferred_client_secret
62
-
63
- response = RestClient.post(
64
- 'https://api.mercadolibre.com/oauth/token',
65
- {:grant_type => 'client_credentials', :client_id => client_id, :client_secret => client_secret},
66
- :content_type=> "application/x-www-form-urlencoded", :accept => 'application/json'
67
- )
68
- end
69
-
70
- def send_preferences_request
71
- RestClient.post(
72
- mp_preferences_url(@auth_response["access_token"]),
73
- @options.to_json,
74
- :content_type=> 'application/json', :accept => 'application/json'
75
- )
76
- end
77
-
78
- def mp_preferences_url(token)
79
- "https://api.mercadolibre.com/checkout/preferences?access_token=#{token}"
80
- end
81
-
82
- def config_options
83
- @options = Hash.new
84
- @options[:external_reference] = @order.number
85
- @options[:back_urls] = {
86
- :success => @callbacks[:success],
87
- :pending => @callbacks[:pending],
88
- :failure => @callbacks[:failure]
89
- }
90
- @options[:items] = Array.new
91
-
92
- @order.line_items.each do |li|
93
- h = {
94
- :title => line_item_description(li.variant),
95
- :unit_price => li.price.to_f,
96
- :quantity => li.quantity,
97
- :currency_id => "ARS"
98
- }
99
- @options[:items] << h
100
- end
101
- end
102
- end
@@ -1 +0,0 @@
1
- <%= simple_format(I18n.t(:mp_payment_failure)) %>
@@ -1 +0,0 @@
1
- <%= simple_format(I18n.t(:mp_payment_pending)) %>
@@ -1 +0,0 @@
1
- <%= simple_format(I18n.t(:mp_payment_success)) %>
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::CheckoutController do
4
-
5
- let(:order) do
6
- mock_model(
7
- Spree::Order,
8
- :checkout_allowed? => true,
9
- :user => nil,
10
- :email => nil,
11
- :completed? => false,
12
- :update_attributes => true,
13
- :payment? => false,
14
- :insufficient_stock_lines => [],
15
- :coupon_code => nil
16
- ).as_null_object
17
- end
18
-
19
- before(:each) do
20
- user = double("User", :last_incomplete_spree_order => nil)
21
- order.stub(:user => user)
22
- controller.stub :current_order => order
23
- controller.stub(:spree_current_user => user)
24
- end
25
-
26
- context "Using Mercado Pago payment method" do
27
- let(:order_attributes) { { payments_attributes: [{payment_method_id: "fake_id"}] } }
28
-
29
- before(:each) do
30
- payment_method = double("PaymentMethod::MercadoPago")
31
- payment_method.should_receive(:kind_of?).with(PaymentMethod::MercadoPago) { true }
32
- Spree::PaymentMethod.should_receive(:find) { payment_method }
33
- end
34
-
35
- it "redirects to m.redirect_url on success" do
36
- client = double("client")
37
- client.should_receive(:authenticate) { true }
38
- client.should_receive(:send_data) { true }
39
- client.should_receive(:redirect_url) { "http://www.example.com" }
40
- SpreeMercadoPagoClient.should_receive(:new) { client }
41
-
42
- spree_post :update, {state: "payment", order: order_attributes }
43
- response.should redirect_to("http://www.example.com")
44
- end
45
-
46
- it "renders mercado_pago_error.html.erb on error" do
47
- client = double("client")
48
- client.should_receive(:authenticate) { false }
49
- client.stub(:send_data) { true }
50
- client.stub(:redirect_url) { "http://www.example.com" }
51
- SpreeMercadoPagoClient.should_receive(:new) { client }
52
-
53
- spree_post :update, {state: "payment", order: order_attributes }
54
- response.should render_template("mercado_pago_error")
55
- end
56
- end
57
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '6b5f7005856b32c5c6c6c7fb9d670aaafd5460fada65bd075c156a49a533b85038761753a8d5c01b7cc1bbb7dd9d38f95e55689b6fb9dd5b2b7b6d286c849b90'
@@ -1,392 +0,0 @@
1
- # This migration comes from spree (originally 20090823005402)
2
- class SpreeZeroNineZero < ActiveRecord::Migration
3
- # This is a legacy migration consolidating all of the database changes needed as of Spree 0.9.0
4
- # (See http://railsdog.lighthouseapp.com/projects/31096-spree/tickets/772)
5
-
6
- def change
7
- create_table :addresses, :force => true do |t|
8
- t.string :firstname, :lastname, :address1, :address2, :city,
9
- :zipcode, :phone, :state_name, :alternative_phone
10
- t.references :state
11
- t.references :country
12
-
13
- t.timestamps
14
- end
15
-
16
- create_table :adjustments, :force => true do |t|
17
- t.integer :position, :adjustment_source_id
18
- t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
19
- t.string :type, :description, :adjustment_source_type, :secondary_type
20
- t.references :order
21
-
22
- t.timestamps
23
- end
24
-
25
- create_table :assets, :force => true do |t|
26
- t.integer :viewable_id, :attachment_width, :attachment_height,
27
- :attachment_size, :position
28
- t.string :viewable_type, :limit => 50
29
- t.string :attachment_content_type, :attachment_file_name
30
- t.string :type, :limit => 75
31
- t.datetime :attachment_updated_at
32
- end
33
-
34
- create_table :calculators, :force => true do |t|
35
- t.string :type
36
- t.integer :calculable_id, :null => false
37
- t.string :calculable_type, :null => false
38
-
39
- t.timestamps
40
- end
41
-
42
- create_table :checkouts, :force => true do |t|
43
- t.references :order
44
- t.string :email, :ip_address
45
- t.text :special_instructions
46
- t.integer :bill_address_id
47
- t.datetime :completed_at
48
-
49
- t.timestamps
50
- end
51
-
52
- create_table :configurations, :force => true do |t|
53
- t.string :name
54
- t.string :type, :limit => 50
55
-
56
- t.timestamps
57
- end
58
-
59
- add_index :configurations, [:name, :type], :name => 'index_configurations_on_name_and_type'
60
-
61
- create_table :countries, :force => true do |t|
62
- t.string :iso_name, :iso, :iso3, :name
63
- t.integer :numcode
64
- end
65
-
66
- create_table :coupons, :force => true do |t|
67
- t.string :code, :description
68
- t.integer :usage_limit
69
- t.boolean :combine
70
- t.datetime :expires_at, :starts_at
71
-
72
- t.timestamps
73
- end
74
-
75
- create_table :creditcard_txns, :force => true do |t|
76
- t.integer :creditcard_payment_id, :txn_type
77
- t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
78
- t.string :response_code
79
- t.text :avs_response, :cvv_response
80
-
81
- t.timestamps
82
- end
83
-
84
- create_table :creditcards, :force => true do |t|
85
- t.text :number, :verification_value
86
- t.string :month, :year, :cc_type, :display_number, :first_name,
87
- :last_name, :start_month, :start_year, :issue_number
88
- t.references :address
89
- t.references :checkout
90
-
91
- t.timestamps
92
- end
93
-
94
- create_table :gateway_configurations, :force => true do |t|
95
- t.references :gateway
96
-
97
- t.timestamps
98
- end
99
-
100
- create_table :gateway_option_values, :force => true do |t|
101
- t.references :gateway_configuration
102
- t.references :gateway_option
103
- t.text :value
104
-
105
- t.timestamps
106
- end
107
-
108
- create_table :gateway_options, :force => true do |t|
109
- t.string :name
110
- t.text :description
111
- t.boolean :textarea, :default => false
112
- t.references :gateway
113
-
114
- t.timestamps
115
- end
116
-
117
- create_table :gateways, :force => true do |t|
118
- t.string :clazz, :name
119
- t.text :description
120
- t.boolean :active
121
-
122
- t.timestamps
123
- end
124
-
125
- create_table :inventory_units, :force => true do |t|
126
- t.integer :lock_version, :default => 0
127
- t.string :state
128
- t.references :variant
129
- t.references :order
130
-
131
- t.timestamps
132
- end
133
-
134
- create_table :line_items, :force => true do |t|
135
- t.references :order
136
- t.references :variant
137
- t.integer :quantity, :null => false
138
- t.decimal :price, :precision => 8, :scale => 2, :null => false
139
-
140
- t.timestamps
141
- end
142
-
143
- add_index :line_items, :order_id, :name => 'index_line_items_on_order_id'
144
- add_index :line_items, :variant_id, :name => 'index_line_items_on_variant_id'
145
-
146
- create_table :option_types, :force => true do |t|
147
- t.string :name, :limit => 100
148
- t.string :presentation, :limit => 100
149
-
150
- t.timestamps
151
- end
152
-
153
- create_table :option_types_prototypes, :id => false, :force => true do |t|
154
- t.references :prototype
155
- t.references :option_type
156
- end
157
-
158
- create_table :option_values, :force => true do |t|
159
- t.integer :position
160
- t.string :name, :presentation
161
- t.references :option_type
162
-
163
- t.timestamps
164
- end
165
-
166
- create_table :option_values_variants, :id => false, :force => true do |t|
167
- t.integer :variant_id
168
- t.integer :option_value_id
169
- end
170
-
171
- add_index :option_values_variants, :variant_id, :name => 'index_option_values_variants_on_variant_id'
172
-
173
- create_table :orders, :force => true do |t|
174
- t.string :number, :limit => 15
175
- t.decimal :item_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
176
- t.decimal :total, :precision => 8, :scale => 2, :default => 0.0, :null => false
177
- t.string :state
178
- t.string :token
179
- t.decimal :adjustment_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
180
- t.decimal :credit_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
181
- t.references :user
182
-
183
- t.timestamps
184
- end
185
-
186
- add_index :orders, :number, :name => 'index_orders_on_number'
187
-
188
- create_table :payments, :force => true do |t|
189
- t.decimal :amount, :precision => 8, :scale => 2, :default => 0.0, :null => false
190
- t.string :type
191
- t.references :order
192
- t.references :creditcard
193
-
194
- t.timestamps
195
- end
196
-
197
- create_table :preferences, :force => true do |t|
198
- t.string :attribute, :null => false, :limit => 100
199
- t.integer :owner_id, :null => false, :limit => 30
200
- t.string :owner_type, :null => false, :limit => 50
201
- t.integer :group_id
202
- t.string :group_type, :limit => 50
203
- t.string :value
204
-
205
- t.timestamps
206
- end
207
-
208
- add_index :preferences, [:owner_id, :owner_type, :attribute, :group_id, :group_type], :name => 'index_preferences_on_owner_and_attribute_and_preference', :unique => true
209
-
210
- create_table :product_option_types, :force => true do |t|
211
- t.integer :position
212
- t.references :product
213
- t.references :option_type
214
-
215
- t.timestamps
216
- end
217
-
218
- create_table :product_properties, :force => true do |t|
219
- t.string :value
220
- t.references :product
221
- t.references :property
222
-
223
- t.timestamps
224
- end
225
-
226
- create_table :products, :force => true do |t|
227
- t.string :name, :default => '', :null => false
228
- t.text :description
229
- t.datetime :available_on, :deleted_at
230
- t.string :permalink, :meta_description, :meta_keywords
231
- t.references :tax_category
232
- t.references :shipping_category
233
-
234
- t.timestamps
235
- end
236
-
237
- add_index :products, :available_on, :name => 'index_products_on_available_on'
238
- add_index :products, :deleted_at, :name => 'index_products_on_deleted_at'
239
- add_index :products, :name, :name => 'index_products_on_name'
240
- add_index :products, :permalink, :name => 'index_products_on_permalink'
241
-
242
- create_table :products_taxons, :id => false, :force => true do |t|
243
- t.references :product
244
- t.references :taxon
245
- end
246
-
247
- add_index :products_taxons, :product_id, :name => 'index_products_taxons_on_product_id'
248
- add_index :products_taxons, :taxon_id, :name => 'index_products_taxons_on_taxon_id'
249
-
250
- create_table :properties, :force => true do |t|
251
- t.string :name
252
- t.string :presentation, :null => false
253
-
254
- t.timestamps
255
- end
256
-
257
- create_table :properties_prototypes, :id => false, :force => true do |t|
258
- t.references :prototype
259
- t.references :property
260
- end
261
-
262
- create_table :prototypes, :force => true do |t|
263
- t.string :name
264
-
265
- t.timestamps
266
- end
267
-
268
- create_table :roles, :force => true do |t|
269
- t.string :name
270
- end
271
-
272
- create_table :roles_users, :id => false, :force => true do |t|
273
- t.references :role
274
- t.references :user
275
- end
276
-
277
- add_index :roles_users, :role_id, :name => 'index_roles_users_on_role_id'
278
- add_index :roles_users, :user_id, :name => 'index_roles_users_on_user_id'
279
-
280
- create_table :shipments, :force => true do |t|
281
- t.string :tracking, :number
282
- t.decimal :cost, :precision => 8, :scale => 2
283
- t.datetime :shipped_at
284
- t.references :order
285
- t.references :shipping_method
286
- t.references :address
287
-
288
- t.timestamps
289
- end
290
-
291
- create_table :shipping_categories, :force => true do |t|
292
- t.string :name
293
-
294
- t.timestamps
295
- end
296
-
297
- create_table :shipping_methods, :force => true do |t|
298
- t.string :name
299
- t.references :zone
300
-
301
- t.timestamps
302
- end
303
-
304
- create_table :state_events, :force => true do |t|
305
- t.string :name, :previous_state
306
- t.references :order
307
- t.references :user
308
-
309
- t.timestamps
310
- end
311
-
312
- create_table :states, :force => true do |t|
313
- t.string :name
314
- t.string :abbr
315
- t.references :country
316
- end
317
-
318
- create_table :tax_categories, :force => true do |t|
319
- t.string :name, :description
320
-
321
- t.timestamps
322
- end
323
-
324
- create_table :tax_rates, :force => true do |t|
325
- t.decimal :amount, :precision => 8, :scale => 4
326
- t.references :zone
327
- t.references :tax_category
328
-
329
- t.timestamps
330
- end
331
-
332
- create_table :taxonomies, :force => true do |t|
333
- t.string :name, :null => false
334
-
335
- t.timestamps
336
- end
337
-
338
- create_table :taxons, :force => true do |t|
339
- t.integer :parent_id
340
- t.integer :position, :default => 0
341
- t.string :name, :null => false
342
- t.string :permalink
343
- t.references :taxonomy
344
-
345
- t.timestamps
346
- end
347
-
348
- unless defined?(User)
349
- create_table :users, :force => true do |t|
350
- t.string :crypted_password, :limit => 128, :default => '', :null => false
351
- t.string :salt, :limit => 128, :default => '', :null => false
352
- t.string :email, :remember_token, :remember_token_expires_at,
353
- :persistence_token, :single_access_token, :perishable_token
354
- t.integer :login_count, :default => 0, :null => false
355
- t.integer :failed_login_count, :default => 0, :null => false
356
- t.datetime :last_request_at, :current_login_at, :last_login_at
357
- t.string :current_login_ip, :last_login_ip, :login
358
- t.integer :ship_address_id, :bill_address_id
359
-
360
- t.timestamps
361
- end
362
- end
363
-
364
- create_table :variants, :force => true do |t|
365
- t.string :sku, :default => '', :null => false
366
- t.decimal :price, :precision => 8, :scale => 2, :null => false
367
- t.decimal :weight, :precision => 8, :scale => 2
368
- t.decimal :height, :precision => 8, :scale => 2
369
- t.decimal :width, :precision => 8, :scale => 2
370
- t.decimal :depth, :precision => 8, :scale => 2
371
- t.datetime :deleted_at
372
- t.boolean :is_master, :default => false
373
- t.references :product
374
- end
375
-
376
- add_index :variants, :product_id, :name => 'index_variants_on_product_id'
377
-
378
- create_table :zone_members, :force => true do |t|
379
- t.integer :zoneable_id
380
- t.string :zoneable_type
381
- t.references :zone
382
-
383
- t.timestamps
384
- end
385
-
386
- create_table :zones, :force => true do |t|
387
- t.string :name, :description
388
-
389
- t.timestamps
390
- end
391
- end
392
- end