Spree Commerce (Coming Soon)

Spree Commerce

loader-icon

Spree Commerce

 

Spree Commerce - Open Source e-commerce platform

Getting Started with Spree Commerce

Welcome to the Spree Commerce open-source eCommerce documentation guide. Follow the instructions below to learn how to build and deploy your Spree Commerce store.

1. Installing Spree

Getting the Spree Starter template

Setting up Your Development Environment

Adding sample data

2. Exploring Your Store

Feel free to explore your store. You can do so because Spree comes with a default pre-built Storefront and Admin Panel.

Browsing Storefront

Logging into the Admin Dashboard

All Done!

Congrats! You’ve set up your Spree Commerce and it’s looking amazing!

Give Spree a GitHub Star, why dont’t ya? Thank you for supporting Spree open-source!

Need support or want to give some feedback? Join our community with 6000+ members or drop us an email at hello@spreecommerce.org.

Spree Commerce

Spree Commerce

 

https://spreecommerce.org/docs/developer/core-concepts/payments

 

 

https://github.com/activemerchant/active_merchant#supported-payment-gateways

 

 

Adding your custom Payment Method

In order to make your own custom Payment Method show up on the backend list of available payment methods, you need to add it to the spree config list of payment methods first.

Firstly create a new model inheriting from Spree::PaymentMethod in your app/models directory:

class FancyPaymentMethod < Spree::PaymentMethod
end

Next, add your custom gateway to the list of available payment methods in config/initializers/spree.rb:

Rails.application.config.after_initialize do
  Rails.application.config.spree.payment_methods << FancyPaymentMethod
end

Spree Braintree Vzero is a good example of a standalone custom gateway.

Payment Method visibility

We’ve mentioned before that a PaymentMethod can have a display_on attribute. This attribute can have the following values: frontback, or both. For more granular control which Payment Methods should be available in which Store, you can override the available_for_store? method in your PaymentMethod subclass.

class FancyPaymentMethod < Spree::PaymentMethod
  def available_for_store?(store)
    store.supported_currencies.include?('EUR')
  end
end

Above code will make the payment method available only for stores that support the EUR currency.

If you want more control you can specify available_for_order? method to control Payment Method visibility for specific Order, eg.

class FancyPaymentMethod < Spree::PaymentMethod
  def available_for_order?(order)
    order.total > 100 && order.currency == 'USD'
  end
end

This code will make the payment method available only for orders with a total greater than 100 and currency USD.