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.
- checksums.yaml +7 -0
- data/app/assets/javascripts/{admin → spree/admin}/spree_mercado_pago_payment_method.js +0 -0
- data/app/assets/javascripts/spree/frontend/spree_mercado_pago_payment_method.js +25 -0
- data/app/controllers/spree/mercado_pago_controller.rb +53 -31
- data/app/models/mercado_pago/client.rb +63 -0
- data/app/models/mercado_pago/client/api.rb +43 -0
- data/app/models/mercado_pago/client/authentication.rb +36 -0
- data/app/models/mercado_pago/client/preferences.rb +20 -0
- data/app/models/mercado_pago/notification.rb +8 -0
- data/app/models/mercado_pago/order_preferences_builder.rb +68 -0
- data/app/models/spree/payment_method/mercado_pago.rb +46 -0
- data/app/services/mercado_pago/handle_received_notification.rb +18 -0
- data/app/services/mercado_pago/process_notification.rb +54 -0
- data/app/views/spree/checkout/payment/_mercadopago.html.erb +15 -1
- data/config/locales/en.yml +3 -12
- data/config/locales/es.yml +3 -13
- data/config/routes.rb +5 -7
- data/lib/generators/spree_mercado_pago_payment_method/install/install_generator.rb +15 -10
- data/lib/spree_mercado_pago_payment_method.rb +1 -0
- data/lib/spree_mercado_pago_payment_method/engine.rb +1 -2
- data/lib/tasks/mercado_user.rake +0 -1
- data/spec/controllers/spree/mercado_pago_controller_spec.rb +18 -76
- data/spec/dummy/README.rdoc +15 -248
- data/spec/dummy/Rakefile +1 -2
- data/spec/dummy/app/assets/stylesheets/application.css +5 -3
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/application.rb +0 -36
- data/spec/dummy/config/database.yml +3 -5
- data/spec/dummy/config/environment.rb +3 -5
- data/spec/dummy/config/environments/development.rb +19 -19
- data/spec/dummy/config/environments/production.rb +41 -30
- data/spec/dummy/config/environments/test.rb +3 -6
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/devise.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/spree.rb +4 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/routes.rb +8 -2
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spree.yml +1 -1
- data/spec/dummy/db/migrate/20141112193407_spree_one_two.spree.rb +482 -0
- data/spec/dummy/db/migrate/20141112193408_spree_promo_one_two.spree.rb +46 -0
- data/spec/dummy/db/migrate/{20121121030242_add_tax_rate_label.spree.rb → 20141112193409_add_tax_rate_label.spree.rb} +0 -0
- data/spec/dummy/db/migrate/{20121121030243_add_toggle_tax_rate_display.spree.rb → 20141112193410_add_toggle_tax_rate_display.spree.rb} +0 -0
- data/spec/dummy/db/migrate/20141112193411_remove_unused_preference_columns.spree.rb +9 -0
- data/spec/dummy/db/migrate/{20121121030244_add_lock_version_to_variant.spree.rb → 20141112193412_add_lock_version_to_variant.spree.rb} +0 -0
- data/spec/dummy/db/migrate/20141112193413_add_states_required_to_countries.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193414_add_on_demand_to_product_and_variant.spree.rb +7 -0
- 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
- data/spec/dummy/db/migrate/20141112193416_split_prices_from_variants.spree.rb +32 -0
- data/spec/dummy/db/migrate/20141112193417_remove_not_null_from_spree_prices_amount.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193418_add_currency_to_line_items.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193419_add_currency_to_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193420_add_cost_currency_to_variants.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193421_remove_display_on_from_payment_methods.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193422_add_position_to_taxonomies.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193423_add_last_ip_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193424_add_state_to_spree_adjustments.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193425_add_display_on_to_spree_payment_methods.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193426_add_position_to_product_properties.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193427_add_identifier_to_spree_payments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193428_add_order_id_index_to_payments.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193429_add_primary_to_spree_products_taxons.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193430_create_spree_stock_items.spree.rb +15 -0
- data/spec/dummy/db/migrate/20141112193431_create_spree_stock_locations.spree.rb +12 -0
- data/spec/dummy/db/migrate/20141112193432_create_default_stock.spree.rb +31 -0
- data/spec/dummy/db/migrate/20141112193433_add_order_id_index_to_shipments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193434_change_meta_description_on_spree_products_to_text.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193435_add_stock_location_id_to_spree_shipments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193436_add_pending_to_inventory_unit.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193437_remove_on_demand_from_product_and_variant.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193438_create_shipping_method_zone.spree.rb +23 -0
- data/spec/dummy/db/migrate/20141112193439_remove_shipping_category_id_from_shipping_method.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193440_create_shipping_method_categories.spree.rb +14 -0
- data/spec/dummy/db/migrate/20141112193441_add_tracking_url_to_spree_shipping_methods.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193442_create_spree_shipping_rates.spree.rb +25 -0
- data/spec/dummy/db/migrate/20141112193443_remove_category_match_attributes_from_shipping_method.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193444_create_stock_movements.spree.rb +13 -0
- data/spec/dummy/db/migrate/20141112193445_add_address_fields_to_stock_location.spree.rb +23 -0
- data/spec/dummy/db/migrate/20141112193446_add_active_field_to_stock_locations.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193447_add_backorderable_to_stock_item.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193448_add_default_quantity_to_stock_movement.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193449_add_source_and_destination_to_stock_movements.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193450_change_orders_total_precision.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193451_change_spree_payments_amount_precision.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193452_change_spree_return_authorization_amount_precision.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193453_change_adjustments_amount_precision.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193454_add_originator_to_stock_movement.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193455_drop_source_and_destination_from_stock_movement.spree.rb +16 -0
- data/spec/dummy/db/migrate/20141112193456_migrate_inventory_unit_sold_to_on_hand.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193457_add_stock_location_to_rma.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193458_update_shipment_state_for_canceled_orders.spree.rb +16 -0
- data/spec/dummy/db/migrate/20141112193459_add_seo_metas_to_taxons.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193460_remove_stock_item_and_variant_lock.spree.rb +15 -0
- data/spec/dummy/db/migrate/20141112193461_add_name_to_spree_credit_cards.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193462_update_name_fields_on_spree_credit_cards.spree.rb +14 -0
- data/spec/dummy/db/migrate/20141112193463_add_index_to_source_columns_on_adjustments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193464_update_adjustment_states.spree.rb +17 -0
- data/spec/dummy/db/migrate/20141112193465_add_shipping_rates_to_shipments.spree.rb +16 -0
- data/spec/dummy/db/migrate/20141112193466_create_spree_stock_transfers.spree.rb +15 -0
- data/spec/dummy/db/migrate/20141112193467_drop_products_count_on_hand.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193468_set_default_shipping_rate_cost.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193469_add_number_to_stock_transfer.spree.rb +24 -0
- data/spec/dummy/db/migrate/20141112193470_add_sku_index_to_spree_variants.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193471_add_backorderable_default_to_spree_stock_location.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193472_add_propage_all_variants_to_spree_stock_location.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193473_rename_shipping_methods_zones_to_spree_shipping_methods_zones.spree.rb +11 -0
- data/spec/dummy/db/migrate/20141112193474_add_user_id_index_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193475_add_updated_at_to_spree_countries.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193476_add_updated_at_to_spree_states.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193477_add_cvv_result_code_and_cvv_result_message_to_spree_payments.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193478_add_unique_index_to_permalink_on_spree_products.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193479_add_unique_index_to_orders_shipments_and_stock_transfers.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193480_add_deleted_at_to_spree_tax_rates.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193481_remove_lock_version_from_inventory_units.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193482_add_cost_price_to_line_item.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193483_set_backorderable_to_default_to_false.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193484_add_created_by_id_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193485_index_completed_at_on_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193486_add_tax_category_id_to_spree_line_items.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193487_migrate_tax_categories_to_line_items.spree.rb +11 -0
- data/spec/dummy/db/migrate/20141112193488_drop_spree_mail_methods.spree.rb +13 -0
- data/spec/dummy/db/migrate/20141112193489_set_default_stock_location_on_shipments.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193490_upgrade_adjustments.spree.rb +40 -0
- data/spec/dummy/db/migrate/20141112193491_rename_adjustment_fields.spree.rb +15 -0
- data/spec/dummy/db/migrate/20141112193492_add_admin_name_column_to_spree_shipping_methods.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193493_add_admin_name_column_to_spree_stock_locations.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193494_add_shipment_total_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193495_expand_order_number_size.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193496_rename_activators_to_promotions.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193497_add_adjustment_total_to_line_items.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193498_add_adjustment_total_to_shipments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193499_add_depth_to_spree_taxons.spree.rb +17 -0
- data/spec/dummy/db/migrate/20141112193500_add_tax_total_to_line_items_shipments_and_orders.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193501_add_shipping_category_to_shipping_methods_and_products.spree.rb +16 -0
- data/spec/dummy/db/migrate/20141112193502_migrate_old_shipping_calculators.spree.rb +20 -0
- data/spec/dummy/db/migrate/20141112193503_add_code_to_spree_promotion_rules.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193504_change_states_required_for_countries.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193505_add_deleted_at_to_spree_stock_items.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193506_remove_promotions_event_name_field.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193507_add_promo_total_to_line_items_and_shipments_and_orders.spree.rb +8 -0
- data/spec/dummy/db/migrate/20141112193508_remove_unused_credit_card_fields.spree.rb +17 -0
- data/spec/dummy/db/migrate/20141112193509_add_track_inventory_to_variant.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193510_add_tax_category_to_variants.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193511_add_channel_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193512_add_included_to_adjustments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193513_rename_tax_total_fields.spree.rb +12 -0
- data/spec/dummy/db/migrate/20141112193514_add_line_item_id_to_spree_inventory_units.spree.rb +22 -0
- data/spec/dummy/db/migrate/20141112193515_add_updated_at_to_variants.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193516_add_position_to_classifications.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193517_create_spree_orders_promotions.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193518_unique_shipping_method_categories.spree.rb +25 -0
- data/spec/dummy/db/migrate/20141112193519_add_item_count_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193520_remove_value_type_from_spree_preferences.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193521_rename_permalink_to_slug_for_products.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193522_add_index_to_variant_id_and_currency_on_prices.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193523_rename_activator_id_in_rules_and_actions_to_promotion_id.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193524_add_deleted_at_to_spree_prices.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193525_add_approver_id_and_approved_at_to_orders.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193526_add_confirmation_delivered_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193527_add_auto_capture_to_payment_methods.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193528_create_spree_payment_capture_events.spree.rb +13 -0
- data/spec/dummy/db/migrate/20141112193529_add_uncaptured_amount_to_payments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193530_default_variant_weight_to_zero.spree.rb +12 -0
- data/spec/dummy/db/migrate/20141112193531_add_tax_category_id_to_shipping_methods.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193532_add_tax_rate_id_to_shipping_rates.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193533_add_pre_tax_amount_to_line_items_and_shipments.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193534_add_more_indexes.spree.rb +14 -0
- data/spec/dummy/db/migrate/20141112193535_add_considered_risky_to_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193536_add_preference_store_to_everything.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193537_add_user_id_to_spree_credit_cards.spree.rb +14 -0
- data/spec/dummy/db/migrate/20141112193538_migrate_old_preferences.spree.rb +24 -0
- data/spec/dummy/db/migrate/20141112193539_create_spree_stores.spree.rb +26 -0
- data/spec/dummy/db/migrate/20141112193540_create_store_from_preferences.spree.rb +31 -0
- data/spec/dummy/db/migrate/20141112193541_add_timestamps_to_spree_assets.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193542_add_additional_store_fields.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193543_add_many_missing_indexes.spree.rb +19 -0
- data/spec/dummy/db/migrate/20141112193544_correct_some_polymorphic_index_and_add_more_missing.spree.rb +67 -0
- data/spec/dummy/db/migrate/20141112193545_add_user_id_created_by_id_index_to_order.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193546_change_spree_price_amount_precision.spree.rb +9 -0
- data/spec/dummy/db/migrate/20141112193547_add_token_to_spree_orders.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193548_move_order_token_from_tokenized_permission.spree.rb +30 -0
- data/spec/dummy/db/migrate/20141112193549_set_shipment_total_for_users_upgrading.spree.rb +11 -0
- data/spec/dummy/db/migrate/20141112193550_drop_credit_card_first_name_and_last_name.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193551_add_deleted_at_to_spree_promotion_actions.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193552_remove_uncaptured_amount_from_spree_payments.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193553_add_default_to_shipment_cost.spree.rb +11 -0
- data/spec/dummy/db/migrate/20141112193554_default_pre_tax_amount_should_be_zero.spree.rb +7 -0
- data/spec/dummy/db/migrate/20141112193555_add_state_lock_version_to_order.spree.rb +6 -0
- data/spec/dummy/db/migrate/20141112193556_fix_adjustment_order_presence.spree.rb +14 -0
- data/spec/dummy/db/migrate/20141112193557_update_classifications_positions.spree.rb +10 -0
- data/spec/dummy/db/migrate/20141112193558_add_api_key_to_spree_users.spree_api.rb +8 -0
- data/spec/dummy/db/migrate/20141112193559_resize_api_key_field.spree_api.rb +8 -0
- data/spec/dummy/db/migrate/20141112193560_rename_api_key_to_spree_api_key.spree_api.rb +8 -0
- data/spec/dummy/db/migrate/20141112193561_add_index_to_user_spree_api_key.spree_api.rb +8 -0
- data/spec/dummy/db/migrate/{20121121030246_create_users.spree_auth.rb → 20141112193562_create_users.spree_auth.rb} +0 -0
- data/spec/dummy/db/migrate/{20121121030247_rename_columns_for_devise.spree_auth.rb → 20141112193563_rename_columns_for_devise.spree_auth.rb} +0 -0
- data/spec/dummy/db/migrate/{20121121030248_convert_user_remember_field.spree_auth.rb → 20141112193564_convert_user_remember_field.spree_auth.rb} +0 -0
- 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
- 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
- data/spec/dummy/db/migrate/20141202172111_create_spree_mercado_pago_notifications.spree_mercado_pago_payment_method_engine.rb +10 -0
- data/spec/dummy/db/schema.rb +581 -260
- data/spec/dummy/db/seeds.rb +2 -2
- data/spec/dummy/db/spree_development.sqlite3 +0 -0
- data/spec/dummy/db/spree_test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +27822 -1376
- data/spec/dummy/log/test.log +87064 -37048
- data/spec/dummy/public/404.html +54 -13
- data/spec/dummy/public/422.html +54 -13
- data/spec/dummy/public/500.html +53 -12
- data/spec/dummy/tmp/cache/17E/D61/spree%2Fapp_configuration%2Fdefault_seo_title +1 -0
- data/spec/dummy/tmp/cache/2CC/B21/spree%2Fapp_configuration%2Frequire_master_price +1 -0
- data/spec/dummy/tmp/cache/334/AA1/spree%2Fapp_configuration%2Fdefault_meta_keywords +1 -0
- data/spec/dummy/tmp/cache/397/F31/spree%2Fapp_configuration%2Fbinary_inventory_cache +1 -0
- data/spec/dummy/tmp/cache/39C/F91/spree%2Fapp_configuration%2Ftax_using_ship_address +1 -0
- data/spec/dummy/tmp/cache/3A7/4A1/spree%2Fapp_configuration%2Faddress_requires_state +1 -0
- data/spec/dummy/tmp/cache/3B7/CD1/spree%2Fapp_configuration%2Fredirect_https_to_http +1 -0
- data/spec/dummy/tmp/cache/3BE/851/spree%2Fapp_configuration%2Ftrack_inventory_levels +1 -0
- data/spec/dummy/tmp/cache/460/D81/spree%2Fapp_configuration%2Fdefault_meta_description +1 -0
- data/spec/dummy/tmp/cache/5AE/6A1/spree%2Fapp_configuration%2Falways_include_confirm_step +1 -0
- data/spec/dummy/tmp/cache/DD9/320/spree%2Fapp_configuration%2Fsite_url +1 -0
- data/spec/dummy/tmp/cache/DDD/2D0/spree%2Fapp_configuration%2Fcurrency +1 -0
- data/spec/dummy/tmp/cache/E27/320/spree%2Fapp_configuration%2Fsite_name +1 -0
- data/spec/dummy/tmp/cache/E9B/7F0/spree%2Fapp_configuration%2Fmails_from +1 -0
- data/spec/dummy/tmp/cache/F01/FD0/spree%2Ffrontend_configuration%2Flocale +1 -0
- data/spec/dummy/{app/assets/javascripts/admin → vendor/assets/javascripts/spree/backend}/all.js +2 -1
- data/spec/dummy/{app/assets/javascripts/store → vendor/assets/javascripts/spree/frontend}/all.js +2 -1
- data/spec/dummy/{app/assets/stylesheets/admin → vendor/assets/stylesheets/spree/backend}/all.css +2 -1
- data/spec/dummy/{app/assets/stylesheets/store → vendor/assets/stylesheets/spree/frontend}/all.css +2 -1
- data/spec/models/mercado_pago/client_spec.rb +138 -0
- data/spec/models/mercado_pago/notification_spec.rb +17 -0
- data/spec/models/mercado_pago/order_preferences_builder_spec.rb +66 -0
- data/spec/services/mercado_pago/process_notification_spec.rb +57 -0
- data/spec/spec_helper.rb +12 -53
- metadata +444 -328
- data/app/assets/javascripts/store/spree_mercado_pago_payment_method.js +0 -1
- data/app/controllers/spree/checkout_controller_decorator.rb +0 -29
- data/app/models/payment_method/mercado_pago.rb +0 -33
- data/app/models/spree_mercado_pago_client.rb +0 -102
- data/app/views/spree/mercado_pago/failure.html.erb +0 -1
- data/app/views/spree/mercado_pago/pending.html.erb +0 -1
- data/app/views/spree/mercado_pago/success.html.erb +0 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +0 -57
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/db/migrate/20121121030140_spree_zero_nine_zero.spree.rb +0 -392
- data/spec/dummy/db/migrate/20121121030141_create_indexes_for_inventory_units.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030142_add_count_on_hand_to_variants_and_products.spree.rb +0 -50
- data/spec/dummy/db/migrate/20121121030143_change_taxons_to_nested_set.spree.rb +0 -47
- data/spec/dummy/db/migrate/20121121030144_move_to_configurable_gateways.spree.rb +0 -55
- data/spec/dummy/db/migrate/20121121030145_add_open_id_authentication_tables.spree.rb +0 -16
- data/spec/dummy/db/migrate/20121121030146_add_openid_field_to_users.spree.rb +0 -27
- data/spec/dummy/db/migrate/20121121030147_change_preference_value_type.spree.rb +0 -11
- data/spec/dummy/db/migrate/20121121030148_create_billing_integrations.spree.rb +0 -13
- data/spec/dummy/db/migrate/20121121030149_charge_refactoring.spree.rb +0 -40
- data/spec/dummy/db/migrate/20121121030150_add_some_indexes.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030151_checkout_state_machine.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030152_state_for_shipments.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030153_make_state_events_polymorphic.spree.rb +0 -13
- data/spec/dummy/db/migrate/20121121030154_ship_address_id_for_checkouts.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030155_shipping_method_id_for_checkouts.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030156_creditcard_last_four_digits.spree.rb +0 -15
- data/spec/dummy/db/migrate/20121121030157_populate_legacy_shipment_state.spree.rb +0 -16
- data/spec/dummy/db/migrate/20121121030158_add_cost_price.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030159_shipment_id_for_inventory_units.spree.rb +0 -26
- data/spec/dummy/db/migrate/20121121030160_cim_fields_for_creditcards.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030161_create_return_authorizations.spree.rb +0 -13
- data/spec/dummy/db/migrate/20121121030162_add_return_authorization_to_inventory_units.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030163_create_trackers.spree.rb +0 -11
- data/spec/dummy/db/migrate/20121121030164_creditcard_id_for_creditcard_txns.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030165_original_creditcard_txn_id_for_creditcard_txns.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030166_add_test_mode_to_billing_integration.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030167_create_payment_methods.spree.rb +0 -17
- data/spec/dummy/db/migrate/20121121030168_polymorphic_payments.spree.rb +0 -43
- data/spec/dummy/db/migrate/20121121030169_change_payments_payment_method_to_belongs_to.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030170_assign_creditcard_txns_to_payment.spree.rb +0 -24
- data/spec/dummy/db/migrate/20121121030171_sti_for_transactions.spree.rb +0 -16
- data/spec/dummy/db/migrate/20121121030172_drop_billing_integrations.spree.rb +0 -17
- data/spec/dummy/db/migrate/20121121030173_deleted_at_for_payment_methods.spree.rb +0 -15
- data/spec/dummy/db/migrate/20121121030174_add_adjustments_index.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030175_add_alt_text_to_images.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030176_fix_existing_coupon_credits.spree.rb +0 -14
- data/spec/dummy/db/migrate/20121121030177_add_display_to_payment_methods.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030178_add_addresses_checkouts_indexes.spree.rb +0 -9
- data/spec/dummy/db/migrate/20121121030179_add_icon_to_taxons.spree.rb +0 -18
- data/spec/dummy/db/migrate/20121121030180_add_description_to_taxons.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030181_index_for_shipments_number.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030182_add_index_on_users_persistence_token.spree.rb +0 -8
- data/spec/dummy/db/migrate/20121121030183_add_default_to_tax_categories.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030184_add_display_to_shipping_methods.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030185_rename_payment_method_display.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030186_rename_preferences_field.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030187_add_guest_flag.spree.rb +0 -8
- data/spec/dummy/db/migrate/20121121030188_drop_order_token.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030189_payments_state_and_assigned_to_order_only.spree.rb +0 -15
- data/spec/dummy/db/migrate/20121121030190_create_address_keys_for_order.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030191_payment_total_for_orders.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030192_shipping_method_id_for_orders.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030193_add_shipment_and_payment_state.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030194_refactor_adjustments.spree.rb +0 -30
- data/spec/dummy/db/migrate/20121121030195_response_code_and_avs_response_for_payments.spree.rb +0 -7
- data/spec/dummy/db/migrate/20121121030196_change_guest_flag_to_anonymous.spree.rb +0 -8
- data/spec/dummy/db/migrate/20121121030197_email_for_orders.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030198_create_mail_methods.spree.rb +0 -11
- data/spec/dummy/db/migrate/20121121030199_rename_frozen_to_locked.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030200_move_special_instructions_to_orders.spree.rb +0 -11
- data/spec/dummy/db/migrate/20121121030201_create_log_entries.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030202_migrate_transactions_to_payment_state.spree.rb +0 -99
- data/spec/dummy/db/migrate/20121121030203_delete_in_progress_orders.spree.rb +0 -20
- data/spec/dummy/db/migrate/20121121030204_migrate_checkout_to_orders.spree.rb +0 -24
- data/spec/dummy/db/migrate/20121121030205_remove_shipped_state.spree.rb +0 -13
- data/spec/dummy/db/migrate/20121121030206_prevent_nil_payment_total.spree.rb +0 -9
- data/spec/dummy/db/migrate/20121121030207_prevent_nil_email.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030208_generate_anonymous_users.spree.rb +0 -21
- data/spec/dummy/db/migrate/20121121030209_update_order_state.spree.rb +0 -13
- data/spec/dummy/db/migrate/20121121030210_cleanup_legacy_tables.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030211_remove_number_and_cvv_from_credicard.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030212_drop_anonymous_field_for_user.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030213_renamed_rma_cancelled_state.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030214_fix_problematic_index_names.spree.rb +0 -14
- data/spec/dummy/db/migrate/20121121030215_add_position_to_variants.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030216_add_next_state_to_state_events.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030217_add_position_to_option_types.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030218_remove_trailing_slashes_in_taxon_permalinks.spree.rb +0 -20
- data/spec/dummy/db/migrate/20121121030219_create_activators.spree.rb +0 -15
- data/spec/dummy/db/migrate/20121121030220_eligible_for_adjustments.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030221_namespace_top_level_models.spree.rb +0 -67
- data/spec/dummy/db/migrate/20121121030222_migrate_namespaced_polymorphic_models.spree.rb +0 -53
- data/spec/dummy/db/migrate/20121121030223_make_adjustments_polymorphic.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030224_add_company_to_addresses.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030225_add_inc_tax_to_tax_rates.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030226_rename_inc_price_attribute.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030227_add_default_tax_zone.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030228_associate_shipping_methods_and_shipping_categories.spree.rb +0 -8
- data/spec/dummy/db/migrate/20121121030229_add_match_rules_to_shipping_methods.spree.rb +0 -8
- data/spec/dummy/db/migrate/20121121030230_new_preferences.spree.rb +0 -49
- data/spec/dummy/db/migrate/20121121030231_rename_state_events_to_state_changes.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030232_add_deleted_at_to_tax_category.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030233_migrate_images_from_products_to_variants.spree.rb +0 -38
- data/spec/dummy/db/migrate/20121121030234_rename_attachment_size_to_attachment_file_size.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030235_increase_scale_of_tax_rate_amount.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030236_create_tokenized_permissions_table.spree.rb +0 -17
- data/spec/dummy/db/migrate/20121121030237_convert_sales_tax_to_default_tax.spree.rb +0 -10
- data/spec/dummy/db/migrate/20121121030238_rename_creditcards_to_credit_cards.spree.rb +0 -12
- data/spec/dummy/db/migrate/20121121030239_add_deleted_at_to_spree_shipping_methods.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030240_remove_credit_total_from_orders.spree.rb +0 -6
- data/spec/dummy/db/migrate/20121121030241_add_counter_cache_to_zone_members.spree.rb +0 -15
- data/spec/dummy/script/rails +0 -6
- data/spec/models/spree_mercado_pago_client_spec.rb +0 -131
@@ -0,0 +1,54 @@
|
|
1
|
+
# Process notification:
|
2
|
+
# ---------------------
|
3
|
+
# Fetch collection information
|
4
|
+
# Find payment by external reference
|
5
|
+
# If found
|
6
|
+
# Update payment status
|
7
|
+
# Notify user
|
8
|
+
# If not found
|
9
|
+
# Ignore notification (maybe payment from outside Spree)
|
10
|
+
module MercadoPago
|
11
|
+
class ProcessNotification
|
12
|
+
# Equivalent payment states
|
13
|
+
# MP state => Spree state
|
14
|
+
# =======================
|
15
|
+
#
|
16
|
+
# approved => complete
|
17
|
+
# pending => pend
|
18
|
+
# in_process => pend
|
19
|
+
# rejected => failed
|
20
|
+
# refunded => void
|
21
|
+
# cancelled => void
|
22
|
+
# in_mediation => pend
|
23
|
+
# charged_back => void
|
24
|
+
STATES = {
|
25
|
+
complete: %w(approved),
|
26
|
+
failure: %w(rejected),
|
27
|
+
void: %w(refunded cancelled charged_back)
|
28
|
+
}
|
29
|
+
|
30
|
+
attr_reader :notification
|
31
|
+
|
32
|
+
def initialize(notification)
|
33
|
+
@notification = notification
|
34
|
+
end
|
35
|
+
|
36
|
+
def process!
|
37
|
+
client = ::Spree::PaymentMethod::MercadoPago.provider
|
38
|
+
op_info = client.get_operation_info(notification.operation_id)["collection"]
|
39
|
+
|
40
|
+
if payment = Spree::Payment.where(identifier: op_info["external_reference"]).first
|
41
|
+
if STATES[:complete].include?(op_info["status"])
|
42
|
+
payment.complete
|
43
|
+
elsif STATES[:failure].include?(op_info["status"])
|
44
|
+
payment.failure
|
45
|
+
elsif STATES[:void].include?(op_info["status"])
|
46
|
+
payment.void
|
47
|
+
end
|
48
|
+
|
49
|
+
# When Spree issue #5246 is fixed we can remove this line
|
50
|
+
payment.order.updater.update
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1 +1,15 @@
|
|
1
|
-
<
|
1
|
+
<script>
|
2
|
+
MercadoPago.paymentMethodID = "<%= payment_method.id %>";
|
3
|
+
</script>
|
4
|
+
|
5
|
+
<div class="row">
|
6
|
+
<div class="twelve rows alpha omega">
|
7
|
+
<img src="http://imgmp.mlstatic.com/org-img/banners/ar/medios/575X40.jpg" title="MercadoPago - Medios de pago" alt="MercadoPago - Medios de pago" width="575" height="40"/>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="row">
|
12
|
+
<div class="twelve rows alpha omega">
|
13
|
+
<%= link_to I18n.t(:make_payment, scope: :mercado_pago), mercado_pago_checkout_path(payment_method_id: payment_method.id), method: :post, class: "button primary" %>
|
14
|
+
</div>
|
15
|
+
</div>
|
data/config/locales/en.yml
CHANGED
@@ -1,13 +1,4 @@
|
|
1
1
|
en:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
Your payent with Mercado Pago was successful.
|
6
|
-
|
7
|
-
Please take into account that this payment may take some hours to reflect
|
8
|
-
on this site.
|
9
|
-
mp_payment_failure: "Your payment could not be processed by Mercado Pago"
|
10
|
-
mp_payment_pending:
|
11
|
-
Your order has been placed but your payment is still pending we will ship
|
12
|
-
your order and contact you as soon as the payment is processed"
|
13
|
-
mp_invalid_order: "The specified order is invalid"
|
2
|
+
mercado_pago:
|
3
|
+
make_payment: "Pay with Mercado Pago"
|
4
|
+
authentication_error: "It was not possible to authenticate with Mercado Pago"
|
data/config/locales/es.yml
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
es:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
Su pago con Mercado Pago se ha efectuado con éxito.
|
6
|
-
|
7
|
-
Por favor tenga en cuenta que el estado de su pago puede tardar
|
8
|
-
algunas horas en reflejarse en este sitio.
|
9
|
-
mp_payment_failure: "Su pago no pudo ser procesado por Mercado Pago"
|
10
|
-
mp_payment_pending:
|
11
|
-
Su orden fue procesada con éxito aunque su pago aún se encuentra pendiente.
|
12
|
-
|
13
|
-
En cuanto su pago se concrete su pedido será finalizado.
|
14
|
-
mp_invalid_order: "La órden especificada es inválida"
|
2
|
+
mercado_pago:
|
3
|
+
make_payment: "Realizar pago en Mercado Pago"
|
4
|
+
authentication_error: "Hubo un error al realizar la autenticación con Mercado Pago"
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
get :failure, as: :mercado_pago_failure
|
7
|
-
end
|
1
|
+
Spree::Core::Engine.add_routes do
|
2
|
+
post '/mercado_pago/checkout', to: "mercado_pago#checkout", as: :mercado_pago_checkout
|
3
|
+
get '/mercado_pago/success', to: "mercado_pago#success", as: :mercado_pago_success
|
4
|
+
get '/mercado_pago/failure', to: "mercado_pago#failure", as: :mercado_pago_failure
|
5
|
+
post '/mercado_pago/ipn', to: "mercado_pago#ipn", as: :mercado_pago_ipn
|
8
6
|
end
|
@@ -3,13 +3,18 @@ module SpreeMercadoPagoPaymentMethod
|
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
4
|
|
5
5
|
def add_javascripts
|
6
|
-
append_file '
|
7
|
-
append_file '
|
6
|
+
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_mercado_pago_payment_method\n"
|
7
|
+
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_mercado_pago_payment_method\n"
|
8
8
|
end
|
9
9
|
|
10
10
|
def add_stylesheets
|
11
|
-
|
12
|
-
|
11
|
+
frontend_css_file = "vendor/assets/stylesheets/spree/frontend/all.css"
|
12
|
+
backend_css_file = "vendor/assets/stylesheets/spree/backend/all.css"
|
13
|
+
|
14
|
+
if File.exist?(backend_css_file) && File.exist?(frontend_css_file)
|
15
|
+
inject_into_file frontend_css_file, " *= require spree/frontend/spree_mercado_pago_payment_method\n", :before => /\*\//, :verbose => true
|
16
|
+
inject_into_file backend_css_file, " *= require spree/backend/spree_mercado_pago_payment_method\n", :before => /\*\//, :verbose => true
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
def add_migrations
|
@@ -17,12 +22,12 @@ module SpreeMercadoPagoPaymentMethod
|
|
17
22
|
end
|
18
23
|
|
19
24
|
def run_migrations
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
res = ask 'Would you like to run the migrations now? [Y/n]'
|
26
|
+
if res == '' || res.downcase == 'y'
|
27
|
+
run 'bundle exec rake db:migrate'
|
28
|
+
else
|
29
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
require 'spree_core'
|
3
2
|
|
4
3
|
module SpreeMercadoPagoPaymentMethod
|
@@ -15,7 +14,7 @@ module SpreeMercadoPagoPaymentMethod
|
|
15
14
|
end
|
16
15
|
|
17
16
|
initializer "spree_payment_network.register.payment_methods" do |app|
|
18
|
-
app.config.spree.payment_methods += [PaymentMethod::MercadoPago]
|
17
|
+
app.config.spree.payment_methods += [Spree::PaymentMethod::MercadoPago]
|
19
18
|
end
|
20
19
|
|
21
20
|
config.to_prepare &method(:activate).to_proc
|
data/lib/tasks/mercado_user.rake
CHANGED
@@ -1,89 +1,31 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
module Spree
|
4
|
+
describe MercadoPagoController do
|
5
|
+
describe "#ipn" do
|
6
|
+
let(:operation_id) { "op123" }
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
context "Logged in user" do
|
12
|
-
let(:user) { create(:user) }
|
13
|
-
let(:payment_method) { create(:payment_method, type: "PaymentMethod::MercadoPago") }
|
14
|
-
let(:order) do
|
15
|
-
order = create(:order, user: user, state: "payment")
|
16
|
-
create(:payment, payment_method: payment_method, order: order)
|
17
|
-
order
|
18
|
-
end
|
19
|
-
|
20
|
-
before { controller.stub(:spree_current_user => user) }
|
21
|
-
before do
|
22
|
-
order.payment.should_not be_nil
|
23
|
-
order.payment_method.should_not be_nil
|
24
|
-
order.payment_method.type.should eq("PaymentMethod::MercadoPago")
|
25
|
-
end
|
8
|
+
describe "for valid notifications" do
|
9
|
+
let(:use_case) { double("use_case") }
|
26
10
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
spree_get :success, { order_number: order.number }
|
31
|
-
end
|
32
|
-
|
33
|
-
it { response.should be_success }
|
34
|
-
it { assigns(:order).should_not be_nil }
|
35
|
-
it { assigns(:order).state.should eq("complete") }
|
36
|
-
it { assigns(:order).id.should eq(order.id)}
|
37
|
-
it { assigns(:order).payment.state.should eq("pending") }
|
38
|
-
end
|
11
|
+
it "handles notification and returns success" do
|
12
|
+
MercadoPago::HandleReceivedNotification.should_receive(:new).and_return(use_case)
|
13
|
+
use_case.should_receive(:process!)
|
39
14
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
it { response.should redirect_to(spree.root_path) }
|
44
|
-
it { flash[:error].should eq(I18n.t(:mp_invalid_order)) }
|
45
|
-
end
|
46
|
-
end
|
15
|
+
spree_post :ipn, { id: operation_id, topic: "payment" }
|
16
|
+
response.should be_success
|
47
17
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
spree_get :pending, { order_number: order.number }
|
18
|
+
notification = ::MercadoPago::Notification.order(:created_at).last
|
19
|
+
notification.topic.should eq("payment")
|
20
|
+
notification.operation_id.should eq(operation_id)
|
52
21
|
end
|
53
|
-
|
54
|
-
it { response.should be_success }
|
55
|
-
it { assigns(:order).should_not be_nil }
|
56
|
-
it { assigns(:order).state.should eq("complete") }
|
57
|
-
it { assigns(:order).id.should eq(order.id)}
|
58
|
-
it { assigns(:order).payment.state.should eq("pending") }
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with invalid order" do
|
62
|
-
before { spree_get :pending }
|
63
|
-
|
64
|
-
it { response.should redirect_to(spree.root_path) }
|
65
|
-
it { flash[:error].should eq(I18n.t(:mp_invalid_order)) }
|
66
22
|
end
|
67
|
-
end
|
68
23
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
24
|
+
describe "for invalid notification" do
|
25
|
+
it "responds with invalid request" do
|
26
|
+
spree_post :ipn, { id: operation_id, topic: "nonexistent_topic" }
|
27
|
+
response.should be_bad_request
|
73
28
|
end
|
74
|
-
|
75
|
-
it { response.should be_success }
|
76
|
-
it { assigns(:order).should_not be_nil }
|
77
|
-
it { assigns(:order).state.should eq("payment") }
|
78
|
-
it { assigns(:order).id.should eq(order.id)}
|
79
|
-
it { assigns(:order).payment.state.should eq("pending") }
|
80
|
-
end
|
81
|
-
|
82
|
-
context "with invalid order" do
|
83
|
-
before { spree_get :failure }
|
84
|
-
|
85
|
-
it { response.should redirect_to(spree.root_path) }
|
86
|
-
it { flash[:error].should eq(I18n.t(:mp_invalid_order)) }
|
87
29
|
end
|
88
30
|
end
|
89
31
|
end
|
data/spec/dummy/README.rdoc
CHANGED
@@ -1,261 +1,28 @@
|
|
1
|
-
==
|
1
|
+
== README
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
5
|
|
6
|
-
|
7
|
-
templates that are primarily responsible for inserting pre-built data in between
|
8
|
-
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
-
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
-
persist themselves to a database. The controller handles the incoming requests
|
11
|
-
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
-
and directing data to the view.
|
6
|
+
Things you may want to cover:
|
13
7
|
|
14
|
-
|
15
|
-
layer entitled Active Record. This layer allows you to present the data from
|
16
|
-
database rows as objects and embellish these data objects with business logic
|
17
|
-
methods. You can read more about Active Record in
|
18
|
-
link:files/vendor/rails/activerecord/README.html.
|
8
|
+
* Ruby version
|
19
9
|
|
20
|
-
|
21
|
-
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
-
are bundled in a single package due to their heavy interdependence. This is
|
23
|
-
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
-
more separate. Each of these packages can be used independently outside of
|
25
|
-
Rails. You can read more about Action Pack in
|
26
|
-
link:files/vendor/rails/actionpack/README.html.
|
10
|
+
* System dependencies
|
27
11
|
|
12
|
+
* Configuration
|
28
13
|
|
29
|
-
|
14
|
+
* Database creation
|
30
15
|
|
31
|
-
|
32
|
-
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
16
|
+
* Database initialization
|
33
17
|
|
34
|
-
|
35
|
-
<tt>cd myapp; rails server</tt> (run with --help for options)
|
18
|
+
* How to run the test suite
|
36
19
|
|
37
|
-
|
38
|
-
"Welcome aboard: You're riding Ruby on Rails!"
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
39
21
|
|
40
|
-
|
41
|
-
the following resources handy:
|
22
|
+
* Deployment instructions
|
42
23
|
|
43
|
-
*
|
44
|
-
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
24
|
+
* ...
|
45
25
|
|
46
26
|
|
47
|
-
|
48
|
-
|
49
|
-
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
-
will help you debug it and get it back on the rails.
|
51
|
-
|
52
|
-
First area to check is the application log files. Have "tail -f" commands
|
53
|
-
running on the server.log and development.log. Rails will automatically display
|
54
|
-
debugging and runtime information to these files. Debugging info will also be
|
55
|
-
shown in the browser on requests from 127.0.0.1.
|
56
|
-
|
57
|
-
You can also log your own messages directly into the log file from your code
|
58
|
-
using the Ruby logger class from inside your controllers. Example:
|
59
|
-
|
60
|
-
class WeblogController < ActionController::Base
|
61
|
-
def destroy
|
62
|
-
@weblog = Weblog.find(params[:id])
|
63
|
-
@weblog.destroy
|
64
|
-
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
The result will be a message in your log file along the lines of:
|
69
|
-
|
70
|
-
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
-
|
72
|
-
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
-
|
74
|
-
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
-
several books available online as well:
|
76
|
-
|
77
|
-
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
-
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
-
|
80
|
-
These two books will bring you up to speed on the Ruby language and also on
|
81
|
-
programming in general.
|
82
|
-
|
83
|
-
|
84
|
-
== Debugger
|
85
|
-
|
86
|
-
Debugger support is available through the debugger command when you start your
|
87
|
-
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
-
execution at any point in the code, investigate and change the model, and then,
|
89
|
-
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
-
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
-
|
92
|
-
class WeblogController < ActionController::Base
|
93
|
-
def index
|
94
|
-
@posts = Post.all
|
95
|
-
debugger
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
So the controller will accept the action, run the first line, then present you
|
100
|
-
with a IRB prompt in the server window. Here you can do things like:
|
101
|
-
|
102
|
-
>> @posts.inspect
|
103
|
-
=> "[#<Post:0x14a6be8
|
104
|
-
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
-
#<Post:0x14a6620
|
106
|
-
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
-
>> @posts.first.title = "hello from a debugger"
|
108
|
-
=> "hello from a debugger"
|
109
|
-
|
110
|
-
...and even better, you can examine how your runtime objects actually work:
|
111
|
-
|
112
|
-
>> f = @posts.first
|
113
|
-
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
-
>> f.
|
115
|
-
Display all 152 possibilities? (y or n)
|
116
|
-
|
117
|
-
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
-
|
119
|
-
|
120
|
-
== Console
|
121
|
-
|
122
|
-
The console is a Ruby shell, which allows you to interact with your
|
123
|
-
application's domain model. Here you'll have all parts of the application
|
124
|
-
configured, just like it is when the application is running. You can inspect
|
125
|
-
domain models, change values, and save to the database. Starting the script
|
126
|
-
without arguments will launch it in the development environment.
|
127
|
-
|
128
|
-
To start the console, run <tt>rails console</tt> from the application
|
129
|
-
directory.
|
130
|
-
|
131
|
-
Options:
|
132
|
-
|
133
|
-
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
-
made to the database.
|
135
|
-
* Passing an environment name as an argument will load the corresponding
|
136
|
-
environment. Example: <tt>rails console production</tt>.
|
137
|
-
|
138
|
-
To reload your controllers and models after launching the console run
|
139
|
-
<tt>reload!</tt>
|
140
|
-
|
141
|
-
More information about irb can be found at:
|
142
|
-
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
-
|
144
|
-
|
145
|
-
== dbconsole
|
146
|
-
|
147
|
-
You can go to the command line of your database directly through <tt>rails
|
148
|
-
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
-
defined in database.yml. Starting the script without arguments will connect you
|
150
|
-
to the development database. Passing an argument will connect you to a different
|
151
|
-
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
-
PostgreSQL and SQLite 3.
|
153
|
-
|
154
|
-
== Description of Contents
|
155
|
-
|
156
|
-
The default directory structure of a generated Ruby on Rails application:
|
157
|
-
|
158
|
-
|-- app
|
159
|
-
| |-- assets
|
160
|
-
| |-- images
|
161
|
-
| |-- javascripts
|
162
|
-
| `-- stylesheets
|
163
|
-
| |-- controllers
|
164
|
-
| |-- helpers
|
165
|
-
| |-- mailers
|
166
|
-
| |-- models
|
167
|
-
| `-- views
|
168
|
-
| `-- layouts
|
169
|
-
|-- config
|
170
|
-
| |-- environments
|
171
|
-
| |-- initializers
|
172
|
-
| `-- locales
|
173
|
-
|-- db
|
174
|
-
|-- doc
|
175
|
-
|-- lib
|
176
|
-
| `-- tasks
|
177
|
-
|-- log
|
178
|
-
|-- public
|
179
|
-
|-- script
|
180
|
-
|-- test
|
181
|
-
| |-- fixtures
|
182
|
-
| |-- functional
|
183
|
-
| |-- integration
|
184
|
-
| |-- performance
|
185
|
-
| `-- unit
|
186
|
-
|-- tmp
|
187
|
-
| |-- cache
|
188
|
-
| |-- pids
|
189
|
-
| |-- sessions
|
190
|
-
| `-- sockets
|
191
|
-
`-- vendor
|
192
|
-
|-- assets
|
193
|
-
`-- stylesheets
|
194
|
-
`-- plugins
|
195
|
-
|
196
|
-
app
|
197
|
-
Holds all the code that's specific to this particular application.
|
198
|
-
|
199
|
-
app/assets
|
200
|
-
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
-
|
202
|
-
app/controllers
|
203
|
-
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
-
automated URL mapping. All controllers should descend from
|
205
|
-
ApplicationController which itself descends from ActionController::Base.
|
206
|
-
|
207
|
-
app/models
|
208
|
-
Holds models that should be named like post.rb. Models descend from
|
209
|
-
ActiveRecord::Base by default.
|
210
|
-
|
211
|
-
app/views
|
212
|
-
Holds the template files for the view that should be named like
|
213
|
-
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
-
eRuby syntax by default.
|
215
|
-
|
216
|
-
app/views/layouts
|
217
|
-
Holds the template files for layouts to be used with views. This models the
|
218
|
-
common header/footer method of wrapping views. In your views, define a layout
|
219
|
-
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
-
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
-
layout.
|
222
|
-
|
223
|
-
app/helpers
|
224
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
-
generated for you automatically when using generators for controllers.
|
226
|
-
Helpers can be used to wrap functionality for your views into methods.
|
227
|
-
|
228
|
-
config
|
229
|
-
Configuration files for the Rails environment, the routing map, the database,
|
230
|
-
and other dependencies.
|
231
|
-
|
232
|
-
db
|
233
|
-
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
-
sequence of Migrations for your schema.
|
235
|
-
|
236
|
-
doc
|
237
|
-
This directory is where your application documentation will be stored when
|
238
|
-
generated using <tt>rake doc:app</tt>
|
239
|
-
|
240
|
-
lib
|
241
|
-
Application specific libraries. Basically, any kind of custom code that
|
242
|
-
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
-
the load path.
|
244
|
-
|
245
|
-
public
|
246
|
-
The directory available for the web server. Also contains the dispatchers and the
|
247
|
-
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
-
server.
|
249
|
-
|
250
|
-
script
|
251
|
-
Helper scripts for automation and generation.
|
252
|
-
|
253
|
-
test
|
254
|
-
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
-
command, template test files will be generated for you and placed in this
|
256
|
-
directory.
|
257
|
-
|
258
|
-
vendor
|
259
|
-
External libraries that the application depends on. Also includes the plugins
|
260
|
-
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
-
vendor/rails/. This directory is in the load path.
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|