Add Stripe donation flow
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
extends RefCounted
|
||||
|
||||
|
||||
static func parse_cents(value: String) -> int:
|
||||
var cleaned := value.strip_edges().trim_prefix("$").replace(",", "")
|
||||
var matcher := RegEx.new()
|
||||
matcher.compile("^[0-9]+(?:\\.[0-9]{1,2})?$")
|
||||
if matcher.search(cleaned) == null:
|
||||
return -1
|
||||
var parts := cleaned.split(".")
|
||||
var dollars := int(parts[0])
|
||||
var cents := 0
|
||||
if parts.size() == 2:
|
||||
var fraction := str(parts[1])
|
||||
cents = int(fraction) * (10 if fraction.length() == 1 else 1)
|
||||
if dollars > 10000 or (dollars == 10000 and cents > 0):
|
||||
return -1
|
||||
return dollars * 100 + cents
|
||||
Reference in New Issue
Block a user