persisting orders and guests
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"vlucas/phpdotenv": "^3.3",
|
||||
"bramus/router": "~1.4",
|
||||
"gabordemooij/redbean": "^5.2",
|
||||
"stripe/stripe-php": "^6.30"
|
||||
"stripe/stripe-php": "^6.30",
|
||||
"ramsey/uuid": "^3.8"
|
||||
}
|
||||
}
|
||||
|
||||
129
composer.lock
generated
129
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "26887184cbb0ba67278f069df1a7a3fc",
|
||||
"content-hash": "2e797d36de3e030f472e3cf3ce1f7a3a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bramus/router",
|
||||
@@ -94,6 +94,51 @@
|
||||
],
|
||||
"time": "2018-10-26T09:06:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/random_compat.git",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*|5.*",
|
||||
"vimeo/psalm": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||
},
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||
"keywords": [
|
||||
"csprng",
|
||||
"polyfill",
|
||||
"pseudorandom",
|
||||
"random"
|
||||
],
|
||||
"time": "2018-07-02T15:55:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.5.0",
|
||||
@@ -144,6 +189,88 @@
|
||||
],
|
||||
"time": "2015-07-25T16:39:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "3.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3",
|
||||
"reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"paragonie/random_compat": "^1.0|^2.0|9.99.99",
|
||||
"php": "^5.4 || ^7.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/aspect-mock": "^1.0 | ~2.0.0",
|
||||
"doctrine/annotations": "~1.2.0",
|
||||
"goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0",
|
||||
"ircmaxell/random-lib": "^1.1",
|
||||
"jakub-onderka/php-parallel-lint": "^0.9.0",
|
||||
"mockery/mockery": "^0.9.9",
|
||||
"moontoast/math": "^1.1",
|
||||
"php-mock/php-mock-phpunit": "^0.3|^1.1",
|
||||
"phpunit/phpunit": "^4.7|^5.0|^6.5",
|
||||
"squizlabs/php_codesniffer": "^2.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "Provides support for PHP Ctype functions",
|
||||
"ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator",
|
||||
"ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator",
|
||||
"ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
|
||||
"moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).",
|
||||
"ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid",
|
||||
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marijn Huizendveld",
|
||||
"email": "marijn.huizendveld@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Thibaud Fabre",
|
||||
"email": "thibaud@aztech.io"
|
||||
},
|
||||
{
|
||||
"name": "Ben Ramsey",
|
||||
"email": "ben@benramsey.com",
|
||||
"homepage": "https://benramsey.com"
|
||||
}
|
||||
],
|
||||
"description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
|
||||
"homepage": "https://github.com/ramsey/uuid",
|
||||
"keywords": [
|
||||
"guid",
|
||||
"identifier",
|
||||
"uuid"
|
||||
],
|
||||
"time": "2018-07-19T23:38:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "stripe/stripe-php",
|
||||
"version": "v6.30.4",
|
||||
|
||||
@@ -27,15 +27,15 @@ DROP TABLE IF EXISTS `guests`;
|
||||
CREATE TABLE `guests` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_id` int(11) NOT NULL,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`email` varchar(64) NOT NULL,
|
||||
`phone` varchar(64) NOT NULL,
|
||||
`childcare` tinyint(4) NOT NULL,
|
||||
`valet` tinyint(4) NOT NULL,
|
||||
`restrictions` tinyint(4) NOT NULL,
|
||||
`table` int(11) NOT NULL,
|
||||
`paddle` int(11) NOT NULL,
|
||||
`stripe_id` varchar(64) DEFAULT NULL,
|
||||
`name` varchar(64) NULL,
|
||||
`email` varchar(64) NULL,
|
||||
`phone` varchar(64) NULL,
|
||||
`childcare` tinyint(4) NULL,
|
||||
`valet` tinyint(4) NULL,
|
||||
`restrictions` tinyint(4) NULL,
|
||||
`table` int(11) NULL,
|
||||
`paddle` int(11) NULL,
|
||||
`stripe_id` varchar(64) NULL,
|
||||
`uuid` varchar(64) NOT NULL,
|
||||
`date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
36
index.php
36
index.php
@@ -70,7 +70,18 @@ $router->post('/checkout', function () {
|
||||
// Sum the cart totals
|
||||
$cartTotal = $eventTicketPrice + $tableTicketPrice + $ticketEnhancerPrice + $additionalContribution;
|
||||
|
||||
$uuid = \Ramsey\Uuid\Uuid::uuid1();
|
||||
|
||||
// Instantiate order object
|
||||
$order = R::dispense('orders');
|
||||
|
||||
// Check if credit checkout and valid
|
||||
if ($_POST['paymentMethod'] == 0) {
|
||||
// make payment
|
||||
$order->stripe_token = '1234';
|
||||
$stripeCustomerToken = '1234'; // For Guest entry
|
||||
}
|
||||
|
||||
$order->ticket_quantity = $originalTicketQty;
|
||||
$order->ticket_cents = $eventTicketPrice + $tableTicketPrice;
|
||||
$order->enhancer_quantity = $ticketEnhancerQty;
|
||||
@@ -85,10 +96,27 @@ $router->post('/checkout', function () {
|
||||
$order->state = $_POST['state'];
|
||||
$order->zip = $_POST['zip'];
|
||||
$order->payment_type = $_POST['paymentMethod'];
|
||||
$order->stripe_token = '1234';
|
||||
$order->uuid = $_POST['firstName'];
|
||||
$id = R::store($order);
|
||||
var_dump($id);
|
||||
$order->uuid = $uuid->toString();
|
||||
$orderId = R::store($order);
|
||||
|
||||
$settings = R::load('settings', 1);
|
||||
$settings->value = $settings->value - $originalTicketQty;
|
||||
R::store($settings);
|
||||
|
||||
for ($i = 1; $i <= $originalTicketQty; $i++) {
|
||||
$uuid = \Ramsey\Uuid\Uuid::uuid1();
|
||||
$guest = R::dispense('guests');
|
||||
// First guest is the person who went through checkout
|
||||
if ($i === 1) {
|
||||
$guest->name = $_POST['firstName'] . ' ' . $_POST['lastName'];
|
||||
$guest->email = $_POST['email'];
|
||||
$guest->stripe_id = $stripeCustomerToken;
|
||||
}
|
||||
$guest->order_id = $orderId;
|
||||
$guest->uuid = $uuid->toString();
|
||||
R::store($guest);
|
||||
unset($guest, $uuid);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user