Skip to content

Commit ca24a24

Browse files
committed
handle edge case while determining service agreement
1 parent ea738c2 commit ca24a24

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/algora/payments/payments.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ defmodule Algora.Payments do
198198
charges_enabled: stripe_account.charges_enabled,
199199
details_submitted: stripe_account.details_submitted,
200200
country: stripe_account.country,
201-
service_agreement: stripe_account.tos_acceptance.service_agreement,
201+
service_agreement: get_service_agreement(stripe_account),
202202
provider_meta: Util.normalize_struct(stripe_account)
203203
}
204204

@@ -223,4 +223,12 @@ defmodule Algora.Payments do
223223
end
224224
end
225225
end
226+
227+
defp get_service_agreement(%{tos_acceptance: %{service_agreement: agreement}} = _account) when not is_nil(agreement) do
228+
agreement
229+
end
230+
231+
defp get_service_agreement(%{capabilities: capabilities}) do
232+
if is_nil(capabilities[:card_payments]), do: "recipient", else: "full"
233+
end
226234
end

0 commit comments

Comments
 (0)