Add verification_document_id handling to StripeAccountController#581
Add verification_document_id handling to StripeAccountController#581
Conversation
|
|
||
| defp handle_create_result({:error, %Ecto.Changeset{} = changeset}, _conn), do: changeset | ||
| defp handle_create_result({:ok, %StripeFileUpload{}} = result, conn) do | ||
| result |> CodeCorps.Analytics.Segment.track(:created, conn) |
There was a problem hiding this comment.
Tracking this is a good idea, I think!
There was a problem hiding this comment.
Oh, you were asking about the error. I don't think we'll track that.
| Converts a map received from the Stripe API into a map that can be used | ||
| to create a `CodeCorps.StripeFileUpload` record | ||
| """ | ||
| @stripe_attributes [:file, :purpose, :id] |
There was a problem hiding this comment.
I think we want to pull in all of Stripe's attributes for the file upload here:
{
"id": "file_19RAITKUlS7mA39fpztNbjpd",
"object": "file_upload",
"created": 1481850845,
"purpose": "identity_document",
"size": 238253,
"type": "jpg"
}
There was a problem hiding this comment.
So this would mean id, created, purpose, size, and type (not object).
|
To fix the error on Circle, you'll need to create an |
| {:ok, result} | ||
| end | ||
|
|
||
| @non_stripe_attributes ["project_id"] |
There was a problem hiding this comment.
I think this would be stripe_connect_account_id.
|
Unfortunately, Stripe's documentation was really unclear on the fact that you can upload files via the browser. This PR is going to change to the following:
|
| @@ -0,0 +1,30 @@ | |||
| defmodule CodeCorps.StripeFileUploadControllerTest do | |||
There was a problem hiding this comment.
This file needs deleted.
| @@ -0,0 +1,21 @@ | |||
| defmodule CodeCorps.StripeFileUploadController do | |||
There was a problem hiding this comment.
This file needs deleted.
web/router.ex
Outdated
| resources "/stripe-connect-accounts", StripeConnectAccountController, only: [:show, :create] | ||
| resources "/stripe-connect-plans", StripeConnectPlanController, only: [:show, :create] | ||
| resources "/stripe-connect-subscriptions", StripeConnectSubscriptionController, only: [:show, :create] | ||
| resources "/stripe-file-uploads", StripeFileUploadController, only: [:create] |
There was a problem hiding this comment.
This line needs deleted.
|
|
||
| @api Application.get_env(:code_corps, :stripe) | ||
|
|
||
| def create(%{"file" => file, "purpose" => purpose, "stripe_connect_account_id" => stripe_connect_account_id} = attributes) do |
There was a problem hiding this comment.
We'll remove create and replace with retrieve.
|
This is partly blocked by #572 now. Can be resolved by creating a mock for the |
|
|
||
| def add_vertification_document(%{"verification_document_id" => verification_document_id, "stripe_connect_account" => connect_account} = attributes) do | ||
| with {:ok, %Stripe.FileUpload{} = file} <- Stripe.FileUpload.retrieve(verification_document_id), | ||
| {:ok, %Stripe.Account{} = account} <- Stripe.Account.update(%{verification_document_id: file.id}) |
There was a problem hiding this comment.
Stripe.FileUpload => @api.FileUpload
Stripe.Account => @api.Account
| |> CodeCorps.StripeAccount.update | ||
|
|
||
| file_upload | ||
| |> CodeCorps.FileUpload.create_identity_document_changeset |
There was a problem hiding this comment.
I assume you're looping back but both these should be wrapped in a transaction.
|
No longer blocked. |
|
@joshsmith This PR seems to mostly be dealing with the file upload controller. I'll implement adding a |
|
Was a bit too quick with the previous comment. Quick glance had me thinking the file upload controller is still what's the focus of the PR. I see that this part has been cleaned up somewhat. I'll just take over from this pr @snewcomer. Hope you don't mind. Good work so far. |
16f7be5 to
c1395c5
Compare
|
@joshsmith I renamed the document id field to #588 should be merged first, then conflicts created by that resolved here. Until then, we should consider it blocked. |
5d37d90 to
0868928
Compare
0868928 to
4c57465
Compare
What's in this PR?
WIP PR for @snewcomer.
Fixes #570 when done.