require_once dirname(dirname(dirname(__FILE__))) . '/stripe-php/lib/Stripe.php'; Stripe::setApiKey($settings['api_key']); try { $charge = Stripe_Charge::create(array('card' => $state['card'], 'amount' => $amount, 'currency' => 'usd', 'description' => $description)); if ($charge->paid && true === $charge->paid) { setcookie(STRIPE_COOKIE); $next = AppletInstance::getDropZoneUrl('success'); if (!empty($next)) { $response->redirect($next); } $response->respond(); die; } } catch (Exception $e) { $error = $e->getCode(); $response->addSay($e->getMessage()); if (array_key_exists($error, $card_errors)) { $state[STRIPE_ACTION] = $card_errors[$error]; $response->redirect(); } else { setcookie(STRIPE_COOKIE); $next = AppletInstance::getDropZoneUrl('fail'); if (!empty($next)) { $response->redirect($next); } $response->respond(); die; } } } setcookie(STRIPE_COOKIE, json_encode($state), time() + 5 * 60);
require_once "twilio.php"; $twiml = new TwimlResponse(); $parts = explode('/', $_SERVER["PHP_SELF"]); $config['filename'] = $parts[count($parts) - 1]; switch ($_GET['page']) { case "gather": // handle routing to a roommate or to the secret code prompt $index = $_REQUEST['Digits'] - 1; if ($config['secret'] && $_REQUEST['Digits'] == '9') { // secret code is enabled and they accessed the secret menu, prompt for the code $gather = $twiml->addGather(array("action" => $config['filename'] . "?page=secret", "numDigits" => strlen($config['secret']), "method" => "POST")); $gather->addSay("Please enter the secret code now.", array("voice" => $config['voice'])); } elseif (isset($config['roommates'][$index])) { // entered the digit for a valid roommate, forward the call $roommate = $config['roommates'][$index]; $twiml->addSay("Connecting you to " . $roommate['name'], array("voice" => $config['voice'])); $twiml->addDial($roommate['number']); } // not a valid input, send back to the menu $twiml->addRedirect($config['filename']); break; case "secret": // handle the secret code entry if ($config['secret'] && $_REQUEST['Digits'] == $config['secret']) { // secret code matches, buzz the caller in $twiml->addSay("Buzzing you in now.", array("voice" => $config['voice'])); $twiml->addPlay("http://www.dialabc.com/i/cache/dtmfgen/wavpcm8.300/" . $config['gate_code'] . ".wav"); } // either the feature is disabled or they didn't enter the proper code, send back to the menu $twiml->addRedirect($config['filename']); break;