Ejemplo n.º 1
0
def _ipn_new_subscription_payment(params, config, session):
    user = session.query(User).get(int(params['custom']))
    assert user is not None
    payment.record_transaction(user.user_id, params['txn_id'], params, session)
    user.subscr_id = params['subscr_id']
    # assign plan and sms credits
    user.plan = _plan_by_name(params['item_name'])
    user.sms_credits_plan = _credits_by_plan(user.plan)
Ejemplo n.º 2
0
def ipn_purchase(params, config, session):
    log.info('Purchase')
    if not payment.is_unique_transaction(params['txn_id'], session):
        log.error('Duplicate transaction: %s', params['txn_id'])
        raise Exception('Duplicate Transaction')
    user = session.query(User).get(int(params['custom']))
    assert user is not None
    payment.record_transaction(user.user_id, params['txn_id'], params, session)
    new_credits_purchased = _credits_by_item_name(params['item_name'])
    log.info('User %d purchased %d SMS credits.', user.user_id, new_credits_purchased)
    user.sms_credits_purchased = user.sms_credits_purchased + new_credits_purchased
Ejemplo n.º 3
0
def _ipn_recurring_subscription_payment(params, config, session):
    user = session.query(User).filter_by(subscr_id=params['subscr_id']).first()
    assert user is not None
    payment.record_transaction(user.user_id, params['txn_id'], params, session)
    # TODO check if the user.plan matches params['item_name']
    user.sms_credits_plan = _credits_by_plan(user.plan)