def lambda_handler(event, context): logger.info('OrderReject() event: {}'.format(event)) order_event = extract_order(event) try: reject_order(order_event) test_state_machine(order_event) order_event = set_error_message(order_event) return order_event except ErrorOrderUpdate as e: raise ErrorOrderReject except Exception as e: logger.error(e) raise ErrorOrderReject
def lambda_handler(event, context): logger.info('Payment Credit: event: {}'.format(event)) order_event = extract_order(event) try: payment = credit_payment(order_event) test_state_machine(order_event) order = set_payment_attributes(order_event, payment) logger.info('PaymentCredit() Event: {}'.format(order)) return order except ErrorPaymentCredit as e: raise e except ErrorPaymentException as e: raise e except Exception as e: logger.error(e) raise ErrorPaymentException
def lambda_handler(event, context): logger.info('OrderApprove() event: {}'.format(event)) order_event = extract_order(event) try: approve_order(order_event) test_state_machine(order_event) logger.info('OrderApproval APPROVED ' 'event: {}'.format(order_event)) return order_event except ErrorOrderUpdate as e: raise e except Exception as e: logger.error(vars(e)) raise ErrorOrderApprove
def lambda_handler(event, context): logger.info('Inventory Reserve: event: {}'.format(event)) order_event = extract_order(event) try: inventory = reserve_inventory(order_event) test_state_machine(order_event) order_event = set_inventory_attributes(order_event, inventory) logger.info('InventoryReserve() event: {}'.format(order_event)) return order_event except InventoryRanShort as e: raise e except ErrorInventoryReserve as e: raise e except Exception as e: logger.error(e) raise ErrorInventoryReserve
def lambda_handler(event, context): logger.info('OrderCreate() event: {}'.format(event)) order_event = extract_event(event) try: create_order(order_event) test_state_machine(order_event) logger.info('OrderCreated APPROVED_PENDING ' 'event: {}'.format(order_event)) # raise ErrorOrderCreate return order_event except AlreadyRunning as e: raise e except ErrorOrderCreate as e: raise e except Exception as e: logger.exception('Order Create Exception: {}'.format(vars(e))) raise ErrorOrderCreate
def lambda_handler(event, context): logger.info('Inventory Release: event: {}'.format(event)) order_event = extract_order(event) try: inventory = release_inventory(order_event) test_state_machine(order_event) release_transaction = dict(order_id=inventory.order_id, transaction_id=inventory.transaction_id) order_event['Inventory'] = json.dumps(release_transaction) logger.info('inventory release - _order_json: {}'.format(order_event)) return order_event except ErrorInventoryRelease as e: raise e except ErrorPaymentException as e: raise e except Exception as e: logger.error(e) raise ErrorPaymentException