Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Braintree refund sync background proecess api
Browse files Browse the repository at this point in the history
  • Loading branch information
shivashankar-ror committed May 28, 2019
1 parent 6a7eb82 commit ecf2acf
Show file tree
Hide file tree
Showing 4 changed files with 684 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/controllers/api/background_services_controller.rb
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class Api::BackgroundServicesController < ActionController::Base
before_action :check_api_key

# Fetch last 6 month refund records and sync with
# payment_braintree_transactions table
def sync_braintree_refunds
tracker = PaymentProcessor::Braintree::RefundTracker.new
tracker.sync
render json: { refund_ids_synced: tracker.unsynced_ids }, status: :ok
end

protected

def check_api_key
return head :forbidden unless valid_api_key?
end

def valid_api_key?
request.headers['X-Api-Key'] == Settings.api_key
end
end
4 changes: 4 additions & 0 deletions config/routes.rb
Expand Up @@ -111,6 +111,10 @@
resource :reset_password

namespace :api do
namespace :background_services, defaults: { format: 'json' } do
get 'sync_braintree_refunds'
end

scope :shares do
post 'track', to: '/share/shares#track'
end
Expand Down

0 comments on commit ecf2acf

Please sign in to comment.