spree_quad_pay is a gem to support Spree E-commerce with QuadPay interest-free payments.
-
Add this extension to your Gemfile with this line:
gem 'spree_quad_pay', github: 'quadpay/quadpay-spree', branch: '3-3-stable'The
branchoption is important: it must match the version of Spree you're using.For example, use
3-3-stableif you're using Spree3-3-stableor any3.3.xversion. -
Install the gem using Bundler:
bundle install
-
Copy & run migrations
bundle exec rails g spree_quad_pay:install
-
Restart your server
If your server was running, restart it so that it can find the assets properly.
-
Update QuadPay transaction status (optional): To avoid inconsistency between QuadPay and Spree Orders, we need to sync the Order statuses using 1 of these methods:
-
Using cronjob: The gem generator will generate config/schedule.rb and config it to run every 5 minutes. Run this command to update job (this would require gem "whenever" installed):
bundle exec whenever --update-crontab -
Using rake task scheduler: Heroku, for example, doesn't support cronjob. Therefore, you can use rake task combine with Heroku Scheduler:
rake quad_pay_tasks:sync_orders
-
-
Create QuadPay Payment Method:
-
Login into Admin Dashboard and go to Configurations > Payment Method, click on button
New Payment Method. -
On new page, at field
PROVIDERwe will chooseSpree::BillingIntegration::QuadPayCheckoutand fill data to Name and Description. -
Click on
Createbutton to create QuadPay payment method.
-
-
Setup QuadPay API keys and Settings
- Go to Configurations > QuadPay Settings and fill necessary infomation below:
Site URL: Your domain URL. This URL is used for QuadPay callback calls.Merchant Name: Merchant Name provided by QuadPay.Client ID: Client ID provided by QuadPay.Min Amount: The Order minimum amount to qualify for QuadPay Payment. User cannot select QuadPay Payment Method if the Order's total lower than this minimum amount.Max Amount: The Order maximum amount to qualify for QuadPay Payment. User cannot select QuadPay Payment Method if the Order's total greater than this maximum amount.Display Widget At Product Page: Display QuadPay widget on Product Page.Display Widget At Cart Page: Display QuadPay widget on Cart Page.Test Mode: Toggle Test Mode or Live Mode -
Restart your server
- If your server was running, restart it so that it can find the assets properly.
-
The gem provide helper method "quad_pay_widget" to generate the QuadPay widget wherever you want.
quad_pay_widget(type, amount) -
The gem provide rake task to sync QuadPay Orders with Spree Orders.
rake quad_pay_tasks:sync_orders -
By default, the gem will provide Refund for Order cancel and Return Authorization. You can also use explore the built in
Spree::BillingIntegration::QuadPayCheckoutobject to issue any QuadPay command supported:- create_order: create QuadPay Order.
- find_order: find QuadPay Order based on token provided.
- refund: refund with QuadPay payment based on the Payment's response code.
- credit: partial refund back to User.
- cancel: full refund.
First bundle your dependencies, then run rake. rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app.
bundle
bundle exec rakeWhen testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:
require 'spree_quad_pay/factories'