Beispiel #1
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
Beispiel #2
0
def ipn_subscription_payment(params, config, session):
    log.info('Subscription Payment')
    if not payment.is_unique_transaction(params['txn_id'], session):
        log.error('Duplicate transaction: %s', params['txn_id'])
        raise Exception('Duplicate Transaction')
    if params.has_key('custom'):
        log.debug('New subscription payment')
        _ipn_new_subscription_payment(params, config, session)
    elif params.has_key('subscr_id'):
        log.debug('Recurring subscription payment')
        _ipn_recurring_subscription_payment(params, config, session)
    else:
        log.error('Unable to process transaction, no custom or subscr_id parameter')
        raise Exception('Unable to process transaction')