muck-commerce
A commerce engine for the muck framework.
Configuration
Add the following to your Gemfile
gem "aasm"
gem 'muck-engine'
gem 'muck-users'
gem 'muck-profiles
Add the following to muck.rb and adjust according to the required commerce settings
MuckCommerce.configure do |config|
# config.enable_orders = false
# config.enable_subscriptions = true
# config.enable_coupons = true
# Setup gateway
config.commerce_run_production_as_test = false # Used to set the production gateway for testing before live release. Default is false.
# Authorize.net example
config.cim_gateway = 'authorize_net_cim' # Used to setup enable a system that can store customer information like Authorize.net's CIM or Braintree's vault.
config.gateway = 'authorize_net' # Name of the gateway to use
config.gateway_login = Secrets.gateway_login # The login used to access the gateway
config.gateway_password = Secrets.gateway_password # The password used to access the gateway
# Paypal example
# config.gateway = 'paypal' # Name of the gateway to use
# config.gateway_login = 'TODO YOUR LOGIN GOES HERE' # The login used to access the gateway
# config.gateway_password = 'TODO YOUR PASSWORD GOES HERE' # The password used to access the gateway
# Paypal Express setup
config.enable_paypal_express = true # Turns on paypal express checkout which let's the customer checkout with their paypal account.
config.paypal_login = Secrets.paypal_login # Login for paypal express. Can be the same as the gateway if using paypal as the gateway.
config.paypal_password = Secrets.paypal_password # Password for paypal express. Can be the same as the gateway if using paypal as the gateway.
# The Paypal signature is required if you are using paypal as your gateway or if you are using paypal express.
config.paypal_signature = Secrets.paypal_signature # Paypal signature.
# Payment methods
config.payment_methods = [[ "Credit card", "CC" ], [ "ACH/E-Check", "ACH" ]]
config.credit_card_types = [[ "Visa", "visa" ], [ "MasterCard", "master" ], [ "Discover", "discover" ], [ "American Express", "american_express" ]]
config.achholder_types = [[ "Business", "Business" ], [ "Personal", "Personal" ]]
config.achtypes = [[ "Checking", "Checking" ], [ "Savings", "Savings" ]]
config.require_cvv_value = true # require cvv from credit card
end
Project Setup
Add include MuckCommerce::Models::MuckUser to user.rb
def User
include MuckCommerce::Models::MuckUser
end
The muck commerce engine is setup to use coupons as referral codes for users. To automatically create a coupon code for each user add this code to user.rb
after_create {|user| user.create_referral_code unless user.referral_code}
Create Models
billing_information.rb include MuckCommerce::Models::MuckBillingInformation
coupon.rb include MuckCommerce::Models::MuckCoupon
order.rb:
def Order < ActiveRecord::Base
include MuckCommerce::Models::MuckOrder
end
order_coupon.rb
def OrderCoupon < ActiveRecord::Base
include MuckCommerce::Models::MuckOrderCoupon
end
order_transaction.rb
def OrderTransaction < ActiveRecord::Base
include MuckCommerce::Models::MuckOrderTransaction
end
subscription.rb
def Subscription < ActiveRecord::Base
include MuckCommerce::Models::MuckSubscription
end
subscription_plan.rb
def SubscriptionPlan < ActiveRecord::Base
include MuckCommerce::Models::MuckSubscriptionPlan
end
subscription_record.rb
def SubscriptionRecord < ActiveRecord::Base
include MuckCommerce::Models::MuckSubscriptionRecord
end
give_referral_benefit
Notes
!!!!!!!!!!!!!!!!!!!!!!!!! The Authorize.net CIM code uses decimals NOT integers like the rest of the ActiveMerchant API. This means that you must convert 1000 cents into 10.00 dollars before sending the transaction or else you will bill the user $1000. !!!!!!!!!!!!!!!!!!!!!!!!!
Tests
This project includes tests that run local and tests that run against a remote test gateway. After configuring all required settings in global_config.yml you can run remote tests against a live test gateway with:
rake test:remote
Copyright
Copyright © 2009-2011 Tatemae.com See LICENSE for details.