Module: PurchasesHelper

Defined in:
app/helpers/purchases_helper.rb

Overview

The PurchasesHelper module.

Class Method Summary (collapse)

Class Method Details

+ (Object) validate_purchase_id(purchase_id)

Valid a given purchase id.

Parameters:

  • purchase_id (String)

    The purchase it which should be validated.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/purchases_helper.rb', line 9

def self.validate_purchase_id(purchase_id)
  if purchase_id.size != 36
    # check if upgrade id
    reg_upgrade = /^upgrade[0-9]{4}$/

    return (reg_upgrade.match(purchase_id)) ? true : false
  end

  reg = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/

  return (reg.match(purchase_id)) ? true : false
end