This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Braintree refund sync background proecess api
- Loading branch information
1 parent
6a7eb82
commit ecf2acf
Showing
4 changed files
with
684 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.