-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename pinwheel, add modal, add CSP, create new service and connect * Working employer select * Only include usable service methods * Return the Pinwheel class * Remove unused head tag items * Incl onEvent * Autocorrect * Load pinwheel earlier; remove sandbox * Drop Argyle from CSP directives * Add tests * Inital setup * WIP * Failing test * True negative * Use a better test * Passing tests * Paystubs channel * Subscribing and listneing for webhook events * add url identifier * Store link id information * Lint * Cleanup * Rename * Remove the account creation line * Rename the channel to be more generic * Style * Remove stale * Store API key as instance var * Remove stale comment * Query for accounts/then payroll * Rubocopify * Use a UUID for the Pinwheel end_user_id * Remove pgcrypto extension It shouldn't be necessary just for the pgcrypto extension. * Remove almost all mentions of Argyle This removes all the previous Argyle functionality: controllers, routes, tests, and fixtures. This commit leaves in place: * Database columns (we can handle them later) * Environmet variables (I will handle that in a second commit now) * Remove ARGYLE environment variables This removes the configuration for ARGYLE_SANDBOX, ARGYLE_WEBHOOK_SECRET, and ARGYLE_API_TOKEN, as we won't need them with Pinwheel. * Clear up merge conflict --------- Co-authored-by: Tom Dooner <[email protected]>
- Loading branch information
1 parent
98a3859
commit c83417a
Showing
38 changed files
with
438 additions
and
485 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
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
ARGYLE_API_TOKEN= | ||
ARGYLE_SANDBOX=true | ||
ARGYLE_WEBHOOK_SECRET= | ||
NGROK_URL= | ||
CBV_INVITE_SECRET=development | ||
DOMAIN_NAME=localhost | ||
PINWHEEL_API_TOKEN=API secret |
2 changes: 1 addition & 1 deletion
2
app/app/channels/argyle_paystubs_channel.rb → app/app/channels/paystubs_channel.rb
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
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
class Api::PinwheelController < ApplicationController | ||
# run the token here with the included employer/payroll provider id | ||
def create_token | ||
cbv_flow = CbvFlow.find(session[:cbv_flow_id]) | ||
token_response = provider.create_link_token( | ||
response_type: token_params[:response_type], | ||
id: token_params[:id], | ||
end_user_id: cbv_flow.pinwheel_end_user_id | ||
) | ||
token = token_response["data"]["token"] | ||
|
||
render json: { status: :ok, token: token } | ||
end | ||
|
||
private | ||
|
||
def provider | ||
PinwheelService.new | ||
end | ||
|
||
def token_params | ||
params.require(:pinwheel).permit(:response_type, :id) | ||
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
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
app/app/controllers/webhooks/pinwheel/events_controller.rb
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,27 @@ | ||
class Webhooks::Pinwheel::EventsController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
def create | ||
signature = request.headers["X-Pinwheel-Signature"] | ||
timestamp = request.headers["X-Timestamp"] | ||
|
||
digest = provider.generate_signature_digest(timestamp, request.raw_post) | ||
|
||
unless provider.verify_signature(signature, digest) | ||
return render json: { error: "Invalid signature" }, status: :unauthorized | ||
end | ||
|
||
if params["event"] == "paystubs.added" | ||
@cbv_flow = CbvFlow.find_by_pinwheel_end_user_id(params["payload"]["end_user_id"]) | ||
|
||
if @cbv_flow | ||
@cbv_flow.update(payroll_data_available_from: params["payload"]["params"]["from_pay_date"]) | ||
PaystubsChannel.broadcast_to(@cbv_flow, params) | ||
end | ||
end | ||
end | ||
|
||
def provider | ||
PinwheelService.new | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
import loadScript from 'load-script'; | ||
import metaContent from "./meta"; | ||
import CSRF from './csrf'; | ||
|
||
const PINWHEEL_TOKENS_GENERATE = '/api/pinwheel/tokens'; | ||
|
||
export function loadPinwheel() { | ||
return new Promise((resolve, reject) => { | ||
loadScript('https://cdn.getpinwheel.com/pinwheel-v3.0.js', (err, script) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(Pinwheel); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
export function initializePinwheel(Pinwheel, linkToken, callbacks) { | ||
Pinwheel.open({ | ||
linkToken, | ||
...callbacks | ||
}); | ||
|
||
return Pinwheel; | ||
} | ||
|
||
export const fetchToken = (response_type, id) => { | ||
return fetch(PINWHEEL_TOKENS_GENERATE, { | ||
method: 'post', | ||
headers: { | ||
'X-CSRF-Token': CSRF.token, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ response_type, id }), | ||
}).then(response => response.json()); | ||
} |
Oops, something went wrong.