Solidus Returnly =============== This gem adds the required APIs to allow returnly obtain an estimate, process a return and apply a reimbursement KNOW ISSUES ----------- * Currently the restock feature only supports the order shipping warehouse * The API user should have the right to create an order there is no an special permission yet for this api Installation ------------ Add solidus_returnly to your Gemfile: ```ruby gem 'solidus_returnly' ``` Bundle your dependencies and run the installation generator: ```shell bundle bundle exec rails g solidus_returnly:install ``` Testing ------- 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, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`. ```shell bundle bundle exec rake ``` When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper: ```ruby require 'solidus/returnly/factories' ``` Solidus/Spree Sandbox --------------------- You can create a sandbox spree installationm ```shell git clone git@github.com:solidusio/solidus.git cd solidus git co v2.0 bundle install rake sandbox cd sandbox rake spree_auth:admin:create ``` default admin credentials: ``` Email [admin@example.com] Password [test123] ``` this will create a pristine solidus installation you can add the `solidus_returnly` gem and test the endpoints live API --- To get an estimate of the return order and taxes `POST /api/returnly/refunds/:order_number/estimate` Payload: ```json { "line_items": [ { "order_line_item_id": "{spree order line item id}", "quantity": 1 } ] } ``` Response: ```json { "total_amount": "{money}", "subtotal_amount": "{money}", "tax_amount": "{money}", "discount_amount": "{money}", "shipping_amount": "{money}", "line_items": [ { "order_line_item_id": "{x_order_line_item_id1}", "quantity": 1, "total_amount": "{money}", "subtotal_amount": "{money}", "tax_amount": "{money}", "discount_amount": "{money}", } ] } ``` To process the return and apply the reimbursement**immediately** you can pass the `restock` parameter on false to prevent the api to immediately change the stock in the default warehouse `POST /api/returnly/refunds/:order_number` Payload: ```json { "line_items": [ { "order_line_item_id": "{x_order_line_item_id1}", "quantity": 2 }, ], "transactions": [{ "parent_id": "{parent (order) tx id}", "amount": "{money}" }], "note": "comment text", "restock": true } ``` Response: ```json { "refund_id": "{x_refund_id}", "created_at": "{timestamp}", "updated_at": "{timestamp}", "user_id": "{optional merchant user ID}", "line_items": [ { "refund_line_item_id": "{x_refund_line_item_id1}", "order_line_item_id": "{x_order_line_item_id1}", "quantity": 2 }, ], "transactions": [ "id": "{refund tx id}", "amount": "{money}" ], "note": "comment text", "restock": true } ``` Copyright (c) 2017 Returnly Technologies, Inc, released under the New BSD License