Functions for moving money between Gratipay and the outside world.


Given an amount, return a higher amount and the difference.

gratipay.billing.exchanges.create_card_hold(db, participant, amount)[source]

Create a hold on the participant’s credit card.

Amount should be the nominal amount. We’ll compute Gratipay’s fee below this function and add it to amount to end up with charge_amount.

gratipay.billing.exchanges.capture_card_hold(db, participant, amount, hold)[source]

Capture the previously created hold on the participant’s credit card.


Cancel the previously created hold on the participant’s credit card.

gratipay.billing.exchanges.record_exchange(db, route, amount, fee, participant, status, ref, error=None)[source]

Given a Bunch of Stuff, return an int (exchange_id).

Records in the exchanges table have these characteristics:

amount It’s negative for credits (representing an outflow from
Gratipay to you) and positive for charges. The sign is how we differentiate the two in, e.g., the history page.

fee The payment processor’s fee. It’s always positive.

ref transaction id in the external system.

gratipay.billing.exchanges.record_exchange_result(db, exchange_id, status, error, participant)[source]

Updates the status of an exchange.

gratipay.billing.exchanges.propagate_exchange(cursor, participant, route, error, amount)[source]

Propagates an exchange’s result to the participant’s balance and the route’s status.