예제 #1
0
def subscribe_company():
    company_id = request.get_json(force=True).get('company_id')

    event_id = Company.find(company_id).event_id

    Payment.make_payment(company_id, event_id)

    return jsonify({"subscription": True})
예제 #2
0
def run():
    systemLog = Log()
    threads = []
    sessions = {}
    proxy = Proxy().random_proxy()
    while 1:
        payments = Payment().get_payments()
        for p in payments:
            payment = Payment()
            payment = payment.set_payment(p)
            name = payment.get_name()
            type = payment.get_type()
            if payment.get_status() == 0:
                continue
            connector_module = 'connector.http.' + name.lower()
            if type == 'enterprise':
                connector_module += '_enterprise'
                name += 'Enterprise'
            module = importlib.import_module(connector_module)
            class_ = getattr(module, name)
            sessions[name] = Session(proxy)
            connector = class_(payment, sessions[name], proxy)
            if sessions[name].is_changing_proxy() == 1:
                systemLog.log('Need to change ' + name + ' proxy!', 'debug')
                proxy = Proxy().random_proxy()
            thread_name = "Thread " + str(
                payment.get_id()) + " " + name + " " + type
            thread = ThreadConnector(thread_name.upper(), connector, 5)
            thread.start()
            threads.append(thread)
        for t in threads:
            t.join(60)
예제 #3
0
def setup(argv):
    config = Config()
    payment = Payment()
    payment.clean()
    sections = config.get_sections()
    for section in sections:
        section_config = config.get_section_config(section)
        if section.startswith('Vietcombank') \
                or section.startswith('Msb') \
                or section.startswith('Techcombank') \
                or section.startswith('Klikbca'):
            payment.set_name(section)
            payment.set_username(section_config['username'])
            payment.save()
예제 #4
0
def payment(argv):
    name = argv[0]
    status = argv[1]
    payment = Payment()
    payment.set_name(name)
    payment.set_status(status)
    payment.update_status()
예제 #5
0
    def handlePayResult(cls, mkid, uid, goods, price,payway = configs_default['payway']['wx']):
        try:
            mkid = str(mkid)
            uid = str(uid)
            goods = str(goods)

            mk = cls.get_market(mkid)
            if mk:
                    # update database
                    newPayment = Payment()
                    newPayment.mkid = mkid
                    newPayment.userid = uid
                    newPayment.goods = goods
                    newPayment.price = int(price)
                    newPayment.time = Utils().dbTimeCreate()
                    newPayment.payway = payway
                    Dal_Payment().addPayment(newPayment)

                     #失效处理
                    goodsArray = goods.split(';')
                    for k, v in enumerate(goodsArray):
                        goodArray = v.split(':')
                        gID = goodArray[0]
                        gCount = goodArray[1]
                        mk.outDate_goods(uid,gID,gCount)
                    mk.clear_goods()  # 清空当前

                    mk.m_disDoor = False  # 放开限制
                    mk.stop_pay_timeout()
                    cls.open_door_inner(mkid,uid)

        except Exception, e:
            msg = traceback.format_exc()  # 方式1
            Utils().logMainDebug(msg)
예제 #6
0
    def create_charge(cls, token_message, community_key, plan_type):
        stripe.api_key = "sk_test_tIiaUWNgm1zeJDzjoE7WOoUO"
        payment_success = False
        amount = PlanPricing.PRO if (plan_type == PlanType.PRO) else PlanPricing.ENTERPRISE

        try:
            charge = stripe.Charge.create(amount=amount, currency="usd", source=token_message.id)
            if charge.paid and (charge.status == "succeeded"):
                payment_success = True
                from model.payment import Payment
                Payment.create(community_key, charge)
        except stripe.CardError as e:
            logging.exception("Error while charging customer: %s" % e)

        return payment_success
예제 #7
0
def payment_status():
    company_id = request.args.get('company_id')

    event_id = Company.find(company_id).event_id

    flag = Payment.check_for_payment(event_id, company_id)

    return jsonify({"payment": flag})
예제 #8
0
 def start_order(self):
     name = self.ui.login_inputs()
     town, street, number = self.ui.adress_inputs()
     customer = Customer(name)
     email = Email(name)
     adress = Adress(town, street, number)
     payment = Payment()
     self.order = Order(customer, email, payment, adress)
     self.add_to_cart()    
예제 #9
0
def status(argv):
    config = Config()
    payment = Payment()
    sections = config.get_sections()
    enabled_payments = []
    disabled_payments = []
    for section in sections:
        if section.startswith('Vietcombank') or section.startswith(
                'Msb') or section.startswith('Klikbca'):
            section_config = config.get_section_config(section)
            status = payment.check_status(section_config['username'])
            if status == 0:
                disabled_payments.append(section)
            else:
                enabled_payments.append(section)
    print('List enabled payments:')
    for payment_str in enabled_payments:
        print(payment_str)
    print('List disabled payments:')
    for payment_str in disabled_payments:
        print(payment_str)
예제 #10
0
def list_companies():
    event_id = request.args.get('event_id')

    Event.add_visitor(event_id)

    companies = Company.get_companies_sp_list(event_id)

    active_companies = []
    for company in companies:
        if Event.find(event_id).subscriptable:
            if Payment.check_for_payment(event_id, company.id):
                active_companies.append(company.to_dict())
        else:
            active_companies.append(company.to_dict())

    print(active_companies)

    return jsonify(active_companies)
예제 #11
0
    def parse(self):
        for sale in self.sales['orders']:
            self.sale = Sale(self.db)
            self.line = Line(self.db)
            self.payment = Payment(self.db)
            self.address = Address(self.db)
            self.transaction = Transaction(self.db)

            order_id = sale['orderId'].split('!')[0]
            self.sale.setOrderId(order_id)
            self.line.setOrderId(order_id)
            self.address.setOrderId(order_id)
            self.sale.setLastUpdated(sale['lastModifiedDate'])

            if self.syncNeeded():
                self.sale.setLegacyOrderId(sale['legacyOrderId'])
                self.sale.setSaleDate(sale['creationDate'])
                self.sale.setBuyerUsername(sale['buyer']['username'])
                self.sale.setStatus(sale['orderAddressStatus'])
                self.sale.add()

                self.fee = Fee(self.db)
                self.fee.setOrderId(order_id)
                self.fee.setFinalValueFee(sale['totalMarketplaceFee']['value'])
                self.fee.addEbayFee()

                for line_items in sale['lineItems']:
                    self.line_item_id = line_items['lineItemId']
                    self.line.setItemId(line_items['legacyItemId'])
                    self.line.setLineItemId(self.line_item_id)
                    self.line.setTitle(line_items['title'])
                    self.line.setSaleFormat(line_items['soldFormat'])
                    self.line.setQuantity(line_items['quantity'])
                    self.line.setAddressStatus(
                        line_items['lineItemAddressStatus'])
                    self.line.add()

                    self.payment.setLineItemId(self.line_item_id)
                    self.payment.setCurrency(
                        line_items['lineItemCost']['convertedFromCurrency'])
                    self.payment.setItemCost(
                        line_items['lineItemCost']['convertedFromValue'])
                    self.payment.setPostageCost(
                        line_items['deliveryCost']['shippingCost']
                        ['convertedFromValue'])

                for payment in sale['paymentSummary']['payments']:
                    self.transaction.setProcessorName(payment['paymentMethod'])
                    self.transaction.setProcessorId(
                        sale['salesRecordReference'])
                    self.transaction.setTransactionDate(payment['paymentDate'])
                    self.transaction.setUpdateDate(payment['paymentDate'])
                    self.transaction.setTransactionAmount(
                        sale['pricingSummary']['total']['value'])
                    self.transaction.setTransactionCurrency(
                        sale['pricingSummary']['total']['currency'])
                    self.transaction.setFeeAmount(0)
                    self.transaction.setFeeCurrency(
                        sale['pricingSummary']['total']['currency'])
                    self.transaction.setTransactionStatus('S')

                    if not self.transaction.alreadyExists():
                        transaction_id = self.transaction.add()

                    self.payment.setPaymentDate(payment['paymentDate'])
                    self.payment.setPaymentStatus(payment['paymentStatus'])
                    self.payment.setTransactionId(transaction_id)
                    self.payment.add()

                for shipping in sale['AddressStartInstructions']:
                    ship_to = shipping['shippingStep']['shipTo']
                    self.address.setBuyerName(ship_to['fullName'])
                    self.address.setAddressLine1(
                        ship_to['contactAddress']['addressLine1'])
                    self.address.setCity(ship_to['contactAddress']['city'])

                    try:
                        self.address.setCounty(
                            ship_to['contactAddress']['stateOrProvince'])
                    except KeyError:
                        self.address.setCounty("")

                    self.address.setPostCode(
                        ship_to['contactAddress']['postalCode'])
                    self.address.setCountryCode(
                        ship_to['contactAddress']['countryCode'])
                    self.address.add()
    logger.info('#### T0.TRANSACTION BEGIN ####')

    # T1.Initiate User model
    logger.info('#### T1.INITIATE USER MODEL ####')
    user = db.session.query(User).first()
    logger.info(pformat(user.to_json()))

    # T2.Initiate Inventory model
    logger.info('#### T2.INITIATE INVENTORY MODEL ####')
    item = db.session.query(Inventory).first()
    logger.info(pformat(item.to_json()))

    # T3.Initiate Payment model
    logger.info('#### T3.INITIATE PAYMENT MODEL ####')
    payment = Payment(pay_type='credit_card',
                      user_id=user.user_id,
                      allowed=fake.boolean(),
                      date=utcnow())
    logger.info(pformat(payment.to_json()))
    db.session.add(payment)
    # db.session.commit()

    # T4.Initiate Order model
    logger.info('#### T4.INITIATE ORDER MODEL ####')
    ordered_item_qty = fake.random_int(1, 100)
    order = Order(user_id=user.user_id,
                  item_id=item.item_id,
                  item_qty=ordered_item_qty,
                  date=utcnow(),
                  deliver_phone=fake.phone_number(),
                  deliver_address=fake.address(),
                  total_price=fake.random_int(100, 1000000))
def fx_payment_success(fx_user):
    return Payment(pay_type='credit_card',
                   user_id=fx_user.user_id,
                   allowed=True,
                   date=utcnow())
예제 #14
0
def remove(argv):
    payment = Payment()
    payment.clean()