From 4f84eb2b09bf51eabdc29b5eeec101e0260b1cb7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 28 Jul 2016 09:37:48 +0200 Subject: Braintree integration: first version --- include/offers.php | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'include/offers.php') diff --git a/include/offers.php b/include/offers.php index 2aa150d..8be7530 100644 --- a/include/offers.php +++ b/include/offers.php @@ -32,11 +32,12 @@ require('./header.php'); //------------------------------------------------------------------------------ // Check for GET variables // - // ?id= View information of the offer with id - // ?toggle_accept= Toggle the accepted status of the offer with id - // ?generate_invoice= Generate an invoice for the offer with id - // ?trash_invoice= Trash the invoice file - // ?delete= Delete the offer with id + // ?id= View information of the offer with id + // ?toggle_accept= Toggle the accepted status of the offer with id + // ?toggle_payment_eligibility= Toggle the payment eligibility of the offer with id + // ?generate_invoice= Generate an invoice for the offer with id + // ?trash_invoice= Trash the invoice file + // ?delete= Delete the offer with id //------------------------------------------------------------------------------ // The header of the page @@ -69,7 +70,7 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); $offer->accepted = !$offer->accepted; - echo "
The status offer #{$offer->id} has been set to ".($offer->accepted ? "accepted" : "unaccepted").".
"; + echo "
The status of offer #{$offer->id} has been set to ".($offer->accepted ? "accepted" : "unaccepted").".
"; } catch (PDOException $e) { echo "
The status of the offer could not be changed due to a PDO error.
"; } catch (Exception $e) { @@ -79,6 +80,27 @@ require('./header.php'); echo ""; } + // Toggle offer payment eligibility + if (isset($_GET['toggle_payment_eligibility'])) { + echo "
"; + $id = (int) $_GET['toggle_payment_eligibility']; + try { + $offer = new Offer($_pdo, $id); + if ($offer->getPaymentEligibility()) { + $offer->payment_key = null; + } else { + $offer->payment_key = Offer::getRandomPaymentKey(); + } + echo "
The offer #{$offer->id} is now ".($offer->getPaymentEligibility() ? "eligible" : "ineligible")." for online payment.
"; + } catch (PDOException $e) { + echo "
The online payment eligibility could not be changed due to a PDO error.
"; + } catch (Exception $e) { + echo "
The offer with id {$id} could not be found.
"; + } + + echo "
"; + } + // Generate invoice if (isset($_GET['generate_invoice'])) { echo "
"; -- cgit v1.2.3