<?php if (isset($_GET['txid'])) { ?> <?php $entry = new \OutSpokane\FlagHandle(); $timestamp = ''; $parts = explode('-', $_GET['txid']); if (count($parts) == 2) { if (is_numeric($parts[1])) { $timestamp = $parts[0]; $entry = new \OutSpokane\FlagHandle($parts[1]); } } $stripe_keys = \OutSpokane\Entry::getStripeKeys(); ?> <a name="confirmation-payment"></a> <h2>Confirmation and Payment</h2> <?php if (isset($_POST['form'])) { ?> <div class="alert alert-danger"> There was a problem processing your credit card. Please try again. </div> <?php } ?>
/** * */ public function formCapture() { if (isset($_POST['pride_export'])) { Entry::exportToCsv(); exit; } if (isset($_POST['edit_outspokane_entry'])) { switch ($_POST['form']) { case 'festival': $entry = new FestivalEntry($_POST['id']); break; case 'cruise': $entry = new CruiseEntry($_POST['id']); break; case 'parade': $entry = new ParadeEntry($_POST['id']); break; case 'donation': $entry = new Donation($_POST['id']); break; case 'flag': $entry = new FlagHandle($_POST['id']); break; case 'sponsorship': $entry = new Sponsorship($_POST['id']); break; default: $entry = new MurderMysteryEntry($_POST['id']); } $entry->setEntryYear($_POST['entry_year'])->setOrganization($_POST['organization'])->setFirstName($_POST['first_name'])->setLastName($_POST['last_name'])->setEmail($_POST['email'])->setPhone($_POST['phone'])->setAddress($_POST['address'])->setCity($_POST['city'])->setState($_POST['state'])->setZip($_POST['zip'])->setQty($_POST['qty']); if ($_POST['form'] == 'festival') { $entry->setEntryTypeId($_POST['entry_type_id'])->setIsCornerBooth($_POST['is_corner_booth'])->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty']))->setPriceForCornerBooth(preg_replace('/[^0-9\\.]/', '', $_POST['price_for_corner_booth']))->setDescription($_POST['description']); } elseif ($_POST['form'] == 'cruise') { $entry->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty'])); } elseif ($_POST['form'] == 'parade') { $entry->setEntryTypes($_POST['parade_entry_type'])->setDescription($_POST['description'])->setFloatParkingSpaces($_POST['float_parking_spaces'])->setFloatParkingSpaceCost(preg_replace('/[^0-9\\.]/', '', $_POST['float_parking_space_cost']))->setNeedsAmpedSound($_POST['needs_amped_sound'])->setGroupSize($_POST['group_size']); } elseif ($_POST['form'] == 'murder_mystery') { $entry->setIsSponsor($_POST['is_sponsor'])->setPricePerQty(preg_replace('/[^0-9\\.]/', '', $_POST['price_per_qty']))->setIsUpgraded($_POST['is_upgraded'])->setVegetarianQty($_POST['vegetarian_qty']); } elseif ($_POST['form'] == 'donation') { $entry->setDonationAmount($_POST['donation_amount']); } elseif ($_POST['form'] == 'flag') { $entry->setMessage($_POST['message'])->setColor($_POST['color']); } elseif ($_POST['form'] == 'sponsorship') { $entry->setPosition($_POST['position'])->setLocalPosition($_POST['local_position'])->setAmount($_POST['amount'])->setUrl($_POST['url'])->setLevel($_POST['level'])->setLocalFirstName($_POST['local_first_name'])->setLocalLastName($_POST['local_last_name'])->setLocalAddress($_POST['local_address'])->setLocalCity($_POST['local_city'])->setLocalState($_POST['local_state'])->setLocalZip($_POST['local_zip'])->setLocalEmail($_POST['local_email'])->setLocalPhone($_POST['local_phone']); } $entry->update(); header('Location:admin.php?page=' . $_POST['return'] . '&action=view&id=' . $entry->getId()); exit; } if (isset($_POST['pride_action'])) { if (wp_verify_nonce($_POST['_wpnonce'], 'pride-nonce')) { if ($_POST['pride_action'] == 'cc') { $parts = explode('-', $_POST['txid']); if (count($parts) == 2) { if (is_numeric($parts[1])) { switch ($_POST['form']) { case 'cruise': $entry = new CruiseEntry($parts[1]); $title = 'Pride Cruise'; break; case 'festival': $entry = new FestivalEntry($parts[1]); $title = 'Pride Festival Entry'; break; case 'murder_mystery': $entry = new MurderMysteryEntry($parts[1]); $title = 'Murder Mystery Ticket'; break; case 'donation': $entry = new Donation($parts[1]); $title = 'Donation'; break; case 'flag': $entry = new FlagHandle($parts[1]); $title = 'Flag Handle'; break; case 'sponsorship': $entry = new Sponsorship($parts[1]); $title = 'Sponsorship'; break; default: /* 'parade' */ $entry = new ParadeEntry($parts[1]); $title = 'Pride Parade Entry'; } if ($entry->getCreatedAt() !== NULL && isset($_POST['stripeToken']) && strlen($_POST['stripeToken']) > 0) { $stripe_keys = Entry::getStripeKeys(); Stripe::setApiKey($stripe_keys['secret']); Stripe::setApiVersion('2016-03-07'); try { /** @var \Stripe\Charge $charge */ $charge = Charge::create(array('amount' => round($entry->getAmountDue() * 100), 'currency' => 'usd', 'source' => $_POST['stripeToken'], 'description' => $entry->getEntryYear() . ' ' . $title)); $entry->setPaidAt(time())->setPaymentMethodId(Entry::PAYMENT_METHOD_CARD)->setPaymentAmount($entry->getAmountDue())->setPaymentConfirmationNumber($charge->id)->update(); header('Location:' . $_POST['_wp_http_referer']); exit; } catch (Card $e) { /* card was declined */ } } } } } } } }