Api reference
components.alan_pay.public.business_logic ¶
alan_pay_actions ¶
AlanPayActions ¶
Public actions interface with the Alan Pay component.
declare_profile
staticmethod
¶
Create a new Alan Pay profile for the given user, and return its ID.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
declare_sepa_mandate
classmethod
¶
declare_sepa_mandate(
app_id,
app_user_id,
debtor_name,
debtor_iban,
debtor_country,
unique_mandate_reference,
signature_date,
save=True,
)
Declare a SEPA mandate for the given user.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
offboard_user
staticmethod
¶
Offboard an existing user from Alan Pay.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
onboard_user
staticmethod
¶
onboard_user(
app_id,
app_user_id,
phone_number_verification_request_id,
phone_number_otp_code,
first_name,
last_name,
birth_date,
email,
lang,
)
Onboard a new user on Alan Pay by: - Verifying its phone number using the OTP (One Time Password) they received - Creating a new account membership and a card
Raises an InvalidPhoneNumberVerificationCodeException if the OTP is invalid
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
request_external_transaction
staticmethod
¶
request_external_transaction(
app_id,
app_user_id,
transaction_date,
requested_amount_in_cents,
external_transaction_id,
save=True,
)
Request creation of a new external transaction for the given user.
- If user has no debt to Alan (ex: no recent card payment), no transaction will be created
- If user has a debt to Alan, a new transaction will be created, whose amount will be the min value between the user debt and requested_amount_in_cents
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
set_push_notification_date_for_external_transactions
staticmethod
¶
Update the date a push notification was sent for the given external transactions.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
start_phone_number_verification
staticmethod
¶
Start phone number verification by sending a OTP (One Time Password) to the given phone number.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
view_card_numbers
staticmethod
¶
Returns the numbers of the latest active card of the given user.
Source code in components/alan_pay/public/business_logic/alan_pay_actions.py
alan_pay_queries ¶
AlanPayQueries ¶
Public queries interface with the Alan Pay component.
get_alan_balance
staticmethod
¶
Return the live amount of the Alan Balance for the given user.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_alan_balance_transactions
staticmethod
¶
Return a list of Alan Balance transactions for the given user.
If transaction_ids is not None, only the transactions with the given ids will be returned.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_alan_balance_transactions_by_external_id
staticmethod
¶
Return a list of Alan Balance transactions whose external ids are from the given ones.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_latest_payments
staticmethod
¶
Returns a list of the latest payments made by the given Alan Pay profile.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_merchant_category_code_descriptions
staticmethod
¶
Returns description labels for merchant category codes.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_next_recovery_debt
classmethod
¶
Returns the next recovery debt for the given user.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_next_recovery_session
staticmethod
¶
Returns the closest Alan Pay recovery session (can be today).
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_profile
staticmethod
¶
Returns the Alan Pay profile for the given user info, or null if not found.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_profile_by_id
staticmethod
¶
Returns a specific Alan Pay profile.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_profiles
staticmethod
¶
Returns all the existing Alan Pay profiles for the given app.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_recovery_debt
staticmethod
¶
Return debt info for the given recovery session and user.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_recovery_debt_by_id
staticmethod
¶
Return info for a specific debt.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_recovery_debts
staticmethod
¶
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
get_recovery_debts_for_user
staticmethod
¶
Return debt info for the given recovery session and user.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
has_card_provisioning
staticmethod
¶
Returns True if the alan pay profile has a provision for its card
is_support_appointment_scheduling_enabled
staticmethod
¶
Returns true if members are allowed to schedule appointments with a member of the team (though Google Calendar), false otherwise.
Source code in components/alan_pay/public/business_logic/alan_pay_queries.py
reset_local_onboarding_flow_action ¶
reset_swan_and_alan_pay_dev_environment_for_user ¶
Source code in components/alan_pay/public/business_logic/reset_local_onboarding_flow_action.py
components.alan_pay.public.commands ¶
app_group ¶
alan_pay_commands
module-attribute
¶
alan_pay_commands = AppGroup(
name="alan_pay",
help="Main command group for the Alan Pay component",
)
push_notification ¶
app_group ¶
send_for_non_provisioned_members ¶
send_for_non_provisioned_members ¶
Send a notification to all members that onboarded recently and didn't add their card in their wallet
Source code in components/alan_pay/public/commands/push_notification/send_for_non_provisioned_members.py
send_for_recovery_session ¶
send_for_recovery_session ¶
Send a recovery push notification to all members that will be debited during the recovery session Should be ran one day after the execution of the recovery session command
Source code in components/alan_pay/public/commands/push_notification/send_for_recovery_session.py
send_for_transaction ¶
send_for_transaction ¶
Send a push notification for a given alan balance transaction ID.
Source code in components/alan_pay/public/commands/push_notification/send_for_transaction.py
recovery ¶
list_alan_pay_recovery_sessions ¶
list_sessions ¶
List all existing recovery session.
Source code in components/alan_pay/public/commands/recovery/list_alan_pay_recovery_sessions.py
run_alan_pay_recovery_session ¶
run_session ¶
Recover money from the given recovery session.
Source code in components/alan_pay/public/commands/recovery/run_alan_pay_recovery_session.py
swan ¶
spending_limits ¶
check_spending_limits ¶
This command logs Swan cards whose spending limits are not configured as expected
Source code in components/alan_pay/public/commands/swan/spending_limits.py
components.alan_pay.public.controllers ¶
support ¶
SupportController ¶
Bases: BaseController
get_support_configuration ¶
Returns a hardcoded configuration for Alan Pay's support.
This endpoint has been added so we can easily switch appointment scheduling on and off in the future.
Source code in components/alan_pay/public/controllers/support.py
components.alan_pay.public.entities ¶
in_memory_alan_balance_transaction ¶
InMemoryAlanBalanceTransaction
dataclass
¶
InMemoryAlanBalanceTransaction(
id,
alan_pay_profile_id,
alan_pay_recovery_debt_id,
amount_in_cents,
event_type,
transaction_date,
card_payment,
sepa_debit,
external_transaction_id,
push_notification_sent_at,
)
alan_pay_profile_id
instance-attribute
¶
The id of the Alan Pay profile this transaction is tied to. We only expose the profile id for performance reasons. If a caller component requires the complete profile, it can fetch it using this id.
alan_pay_recovery_debt_id
instance-attribute
¶
The id of the Alan Pay debt this transaction will be recovered with. We only expose the debt id for performance reasons. If a caller component requires the complete debt info, it can fetch it using this id.
amount_in_cents
instance-attribute
¶
The transaction amount in cents. Negative amount means the member owes money to Alan, positive amount means the opposite.
card_payment
instance-attribute
¶
Additional payment information in case the event source is a card payment.
external_transaction_id
instance-attribute
¶
The id of the external transaction in case the event type is external_transaction
push_notification_sent_at
instance-attribute
¶
The date we sent a push notification to the member for this transaction, if applicable.
sepa_debit
instance-attribute
¶
Additional SEPA debit information in case the event source is recovery.
in_memory_alan_pay_card_numbers ¶
in_memory_alan_pay_card_payment ¶
InMemoryAlanPayCardPayment
dataclass
¶
InMemoryAlanPayCardPayment(
effective_date,
amount_in_cents,
status,
rejection_reason,
is_recovered,
merchant_name,
merchant_postal_code,
merchant_city,
merchant_country,
merchant_id,
merchant_category_code,
)
amount_in_cents
instance-attribute
¶
The payment amount in cents. If the payment is not captured yet, this amount is the authorized one.
merchant_category_code
instance-attribute
¶
The category code of the merchant that initiated the transaction (MCC).
merchant_id
instance-attribute
¶
The ID of the merchant that initiated the transaction within the banking network (MID).
merchant_name
instance-attribute
¶
The name of the merchant that initiated the transaction.
rejection_reason
instance-attribute
¶
The reason why the payment was rejected, if applicable.
status
instance-attribute
¶
The status of the payment. Can be authorized, captured, or rejected.
in_memory_alan_pay_phone_number_verification ¶
in_memory_alan_pay_profile ¶
in_memory_alan_pay_recovery_debt ¶
InMemoryAlanPayRecoveryDebt
dataclass
¶
InMemoryAlanPayRecoveryDebt(
id,
profile,
recovery_session,
status,
transactions,
amount_in_cents,
recovered_amount_in_cents,
refunded_amount_in_cents,
)
recovered_amount_in_cents
instance-attribute
¶
The amount that was effectively recovered for this debt (null until the debt is effectively settled).
recovery_session
instance-attribute
¶
The recovery session the recovery debt is included in.
refunded_amount_in_cents
instance-attribute
¶
The amount that was effectively refunded for this debt (null until the debt is effectively settled).
in_memory_alan_pay_recovery_session ¶
InMemoryAlanPayRecoverySession
dataclass
¶
InMemoryAlanPayRecoverySession(
id,
recovery_period_start_date,
recovery_period_end_date,
freeze_date,
recovery_date,
status,
)
freeze_date
instance-attribute
¶
The cutoff date after which the recovery session is frozen (amounts won't change).
recovery_period_end_date
instance-attribute
¶
The (inclusive) end date of the recovery period.
recovery_period_start_date
instance-attribute
¶
The (inclusive) start date of the recovery period.
in_memory_alan_pay_sepa_debit ¶
InMemoryAlanPaySepaDebit
dataclass
¶
sepa_mandate
instance-attribute
¶
The SEPA mandate used for the debit.
Field has been made optional as we started recovery with credit transfers (from members to Alan) at the very beginning of Alan Pay. Yet, to keep things simple, we map these credit transfers to this SEPA debit model.
in_memory_alan_pay_sepa_mandate ¶
InMemoryAlanPaySepaMandate
dataclass
¶
InMemoryAlanPaySepaMandate(
sepa_creditor_identifier,
debtor_name,
debtor_iban,
unique_mandate_reference,
)
components.alan_pay.public.enums ¶
alan_balance_transaction_event_type ¶
AlanBalanceTransactionEventType ¶
Bases: AlanBaseEnum
The type of event that triggered the balance transaction.
card_payment
class-attribute
instance-attribute
¶
A payment has been captured with the Alan Pay card.
external_transaction
class-attribute
instance-attribute
¶
Balance transaction issued from a component consumer.
failed_recovery
class-attribute
instance-attribute
¶
Alan tried but failed to recover debt issued from the Alan Pay card from the member.
recovery
class-attribute
instance-attribute
¶
Alan recovered debt issued from the Alan Pay card from the member.
refund
class-attribute
instance-attribute
¶
Alan refunded a debt issued from the Alan Pay card to the member (ex: payment canceled after we blocked some care reimbursements).
rejected_card_payment
class-attribute
instance-attribute
¶
A payment has been rejected with the Alan Pay card.
released_card_payment
class-attribute
instance-attribute
¶
A payment that was authorized - but partially (or never) captured.
alan_pay_card_payment_rejection_reason ¶
alan_pay_card_transaction_status ¶
AlanPayCardTransactionStatus ¶
Bases: AlanBaseEnum
authorized
class-attribute
instance-attribute
¶
A received payment was eventually authorized.
captured
class-attribute
instance-attribute
¶
An authorized payment was eventually captured.
received
class-attribute
instance-attribute
¶
The Alan Pay card was used to initiate a new payment, that still needs to be authorized or rejected.
rejected
class-attribute
instance-attribute
¶
A received payment was eventually rejected.
released
class-attribute
instance-attribute
¶
An authorized payment whose remaining authorized amount was eventually released.
alan_pay_profile_status ¶
alan_pay_push_notification_name ¶
AlanPayPushNotificationName ¶
Bases: BasePushNotificationName
alan_pay__external_transaction
class-attribute
instance-attribute
¶
Used by any caller component when a push notification is sent for one or several external transactions.
alan_pay__post_payment
class-attribute
instance-attribute
¶
Sent when a payment is made by a member.
alan_pay__provisioning_reminder
class-attribute
instance-attribute
¶
Sent when a profile has no card provisioning after a few days
alan_pay__recovery_session
class-attribute
instance-attribute
¶
Sent before the members are debited to inform them
alan_pay_recovery_debt_status ¶
AlanPayRecoveryDebtStatus ¶
Bases: AlanBaseEnum
executed
class-attribute
instance-attribute
¶
Bank transfer has been executed, but we did not store the result in our database yet.
initiated
class-attribute
instance-attribute
¶
Recovery process has been initiated, but no bank transfer has been processed yet.
succeeded
class-attribute
instance-attribute
¶
Bank transfer has been executed, and we stored the result in our database without any error.