From 3f28c67f9372387f3a5bc45d5352499d6f919afc Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 1 Aug 2016 00:08:05 +0200 Subject: Payment confirmation --- include/pay.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/pay.php b/include/pay.php index 37dd1cc..69626ea 100644 --- a/include/pay.php +++ b/include/pay.php @@ -44,8 +44,10 @@ require('./header.php'); } if ($notFound || $offerKey != $_offer->payment_key) { echo "
The invoice could not be found.
"; - } elseif ($_offer->payment_key == '') { + } elseif (!$_offer->getPaymentEligibility()) { echo "
This invoice is not eligible for online payment.
"; + } elseif ($_offer->getPayment() != null) { + echo "
This invoice has already been paid.
"; } elseif (isset($_POST['payment_method_nonce'])) { $nonce = $_POST['payment_method_nonce']; $trans = Braintree_Transaction::sale([ @@ -62,13 +64,14 @@ require('./header.php'); foreach ($trans->errors->deepAll() as $error) { echo "{$error->attribute}: {$error->code} {$error->message}
"; } - echo 'Please try again, or contact us.'; + echo 'Please try again, or contact us.'; echo ''; } else { try { $payment = $_offer->createPayment(); $payment->braintree_id = $trans->transaction->id; - echo '
Thank you for your payment.
'; + $payment->send(); + echo '
Thank you for your payment. A confirmation has been sent to '.$_offer->getContact()->email.'.
'; } catch (Exception $e) { echo '
Your payment has been received, but could not be stored in our database. Please contact us.
'; } @@ -111,6 +114,7 @@ require('./header.php');
+
A confirmation will be sent to getContact()->email?>.