diff options
Diffstat (limited to 'include/pay.php')
-rw-r--r-- | include/pay.php | 10 |
1 files changed, 7 insertions, 3 deletions
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 "<div class='form-group alert alert-danger'>The invoice could not be found.</div>"; - } elseif ($_offer->payment_key == '') { + } elseif (!$_offer->getPaymentEligibility()) { echo "<div class='form-group alert alert-danger'>This invoice is not eligible for online payment.</div>"; + } elseif ($_offer->getPayment() != null) { + echo "<div class='form-group alert alert-info'>This invoice has already been paid.</div>"; } 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}<br/>"; } - echo '<b>Please try again, or <a href="mailto:'.Constants::invoice_email.'">contact us</a>.</b>'; + echo '<b>Please <a href="?id='.$_offer->id.'&key='.$_offer->payment_key.'">try again</a>, or <a href="mailto:'.Constants::invoice_email.'">contact us</a>.</b>'; echo '</div>'; } else { try { $payment = $_offer->createPayment(); $payment->braintree_id = $trans->transaction->id; - echo '<div class="form-group alert alert-success">Thank you for your payment.</div>'; + $payment->send(); + echo '<div class="form-group alert alert-success">Thank you for your payment. A confirmation has been sent to <b>'.$_offer->getContact()->email.'</b>.</div>'; } catch (Exception $e) { echo '<div class="form-group alert alert-warning">Your payment has been received, but could not be stored in our database. Please <a href="mailto:'.Constants::invoice_email.'">contact us</a>.</div>'; } @@ -111,6 +114,7 @@ require('./header.php'); </div> <form id="checkout" method="post" action=""> <div id="payment-form"></div> + <div class='form-group alert alert-info' style='margin-top:1em;'>A confirmation will be sent to <b><?=$_offer->getContact()->email?></b>.</div> <input type="submit" class="btn btn-success btn-lg pull-right" value="Pay <?=$total?>"/> </form> <?php |