The payment service

This service has functions that should work no matter which payment provider is in use. It includes the following functions:

def get_plan_by_code(plan_code)

def check_if_plan_and_pm_required(plan_code = None, plan_id = None)

def do_registration_plan_setup_workflow(payment_method_required, user, plan_code, payment_token_data)

def check_coupon(coupon) # Checks if the coupon is valid

def check_user_customer(user): ''' Checks if user account already is bound to customer, and create a new customer if not. '''

def create_subscription_by_plan(user, plan_code = None, plan_id = None, require_payment_info = False, coupon = None) ''' Creates a subscription by plan code. user user object, require_payment_info True or False '''

def payment_update_info(data) # Called by the triggered endpoint in a case of successful payment transaction

def payment_failed_and_update(data): # Called by the triggered endpoint in a case of failed transaction

def setup_payment_method(user, method_code, cc_token, coupon, cc_info) # Saves payment method information into the database **No credit card information saved**

def get_default_vendor() # Retrieves the default payment vendor

def init_app(app) # Called on the application initialization and creates the payment vendor instance

Note. You can change functions according to your payment logic. Remember, though, that most of the logic can be controller via environment variables, see in the payment module documentation.