[freeside-commits] branch FREESIDE_4_BRANCH updated. 7e28826efeda93775671b85f559e77b75aabaa17

Ivan Kohler ivan at freeside.biz
Fri Dec 1 18:31:11 PST 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  7e28826efeda93775671b85f559e77b75aabaa17 (commit)
      from  1eb23cef095341f9138f81035cf35de73d3b205d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7e28826efeda93775671b85f559e77b75aabaa17
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Dec 1 18:31:10 2017 -0800

    add card processing to example self-service, RT#75279

diff --git a/fs_selfservice/wordpress/elements/card.php b/fs_selfservice/wordpress/elements/card.php
new file mode 100644
index 000000000..eb29aef6c
--- /dev/null
+++ b/fs_selfservice/wordpress/elements/card.php
@@ -0,0 +1,53 @@
+<TR>
+  <TD ALIGN="right">Card number</TD>
+  <TD COLSPAN=6>
+    <TABLE>
+      <TR>
+        <TD>
+          <INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<?php echo $payinfo ?>"> </TD>
+        <TD>Exp.</TD>
+        <TD>
+          <SELECT NAME="month">
+            <?php $months = array( '01', '02', '03' ,'04', '05', '06', '07', '08', '09', '10', '11', '12' );
+               foreach ( $months AS $m ) {
+            ?>
+                 <OPTION <?php if ($m == $month) { echo 'SELECTED'; } ?>><?php echo $m; ?>
+            <?php } ?>
+          </SELECT>
+        </TD>
+        <TD> / </TD>
+        <TD>
+          <SELECT NAME="year">
+            <?php $years = array( '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023' );
+               foreach ( $years as $y ) {
+            ?>
+                  <OPTION <?php if ($y == $year ) { echo 'SELECTED'; } ?>><?php echo $y; ?>
+            <?php } ?>
+          </SELECT>
+        </TD>
+      </TR>
+    </TABLE>
+  </TD>
+</TR>
+<?php  if ( $withcvv ) { ?>
+  <TR>
+    <TD ALIGN="right">CVV2 (<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD>
+    <TD><INPUT TYPE="text" NAME="paycvv" VALUE="" SIZE=4 MAXLENGTH=4></TD>
+  </TR>
+<?php } ?>
+<TR>
+  <TD ALIGN="right">Exact name on card</TD>
+  <TD COLSPAN=6><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<?php echo $payname; ?>"></TD>
+</TR>
+
+<?php $lf = $freeside->mason_comp(array(
+           'session_id'     => $_COOKIE['freeside_session_id'],
+           'comp'       => '/elements/location.html',
+           'args'       => [
+                             'no_asterisks'   , 1,
+                             #'address1_label' , 'Card billing address',
+                             'address1_label' , 'Card billing address',
+                           ],
+         ));
+   echo $lf['output'];
+?>
diff --git a/fs_selfservice/wordpress/example_selfservice.php b/fs_selfservice/wordpress/example_selfservice.php
index d753f2d55..c503f380d 100644
--- a/fs_selfservice/wordpress/example_selfservice.php
+++ b/fs_selfservice/wordpress/example_selfservice.php
@@ -60,6 +60,7 @@ get_header();
 <p><a href="view_invoice.php?invnum=<?php echo $max_invnum ?>">View my Bill</a></p>
 <p><a href="change_bill.php">Change Bill Deliver Options</a></p>
 <p><a href="services_new.php">Order a new service</a></p>
+<p><a href="payment_cc.php">Credit card payment</a></p>
 <p><a href="process_logout.php">Logout</a></p>
 
 
diff --git a/fs_selfservice/wordpress/payment_cc.php b/fs_selfservice/wordpress/payment_cc.php
new file mode 100644
index 000000000..ba5cd88d9
--- /dev/null
+++ b/fs_selfservice/wordpress/payment_cc.php
@@ -0,0 +1,117 @@
+<?php
+
+require( dirname( __FILE__ ) . '/wp-blog-header.php' );
+
+$freeside = new FreesideSelfService();
+
+if ( isset($_POST['amount']) && $_POST['amount'] ) {
+
+  $payment_results = $freeside->process_payment(array(
+    'session_id' => $_COOKIE['freeside_session_id'],
+    'payby'      => 'CARD',
+    'amount'     => $_POST['amount'],
+    'payinfo'    => $_POST['payinfo'],
+    'paycvv'     => $_POST['paycvv'],
+    'month'      => $_POST['month'],
+    'year'       => $_POST['year'],
+    'payname'    => $_POST['payname'],
+    'address1'   => $_POST['address1'],
+    'address2'   => $_POST['address2'],
+    'city'       => $_POST['city'],
+    'state'      => $_POST['state'],
+    'zip'        => $_POST['zip'],
+    'country'    => $_POST['country'],
+    'save'       => $_POST['save'],
+    'auto'       => $_POST['auto'],
+    'paybatch'   => $_POST['paybatch'],
+    //'discount_term' => $discount_term,
+  ));
+
+  if ( $payment_results['error'] ) {
+    $_REQUEST['freeside_error'] = $payment_results['error'];
+  } else {
+    $receipt_html = $payment_results['receipt_html'];
+  }
+
+}
+
+if ( $receipt_html ) { ?>
+
+  Your payment was processed successfully.  Thank you.<BR><BR>
+  <?php echo $receipt_html; ?>
+
+<?php } else {
+
+  $payment_info = $freeside->payment_info( array(
+    'session_id' => $_COOKIE['freeside_session_id'],
+    'payment_payby' => 'CARD',
+  ) );
+
+  if ( isset($payment_info['error']) && $payment_info['error'] ) {
+    $error = $payment_info['error'];
+    wp_redirect('example_login.php?freeside_error='. urlencode($error));
+    die();
+  }
+
+  extract($payment_info);
+
+  $tr_amount_fee = $freeside->mason_comp(array(
+      'session_id' => $_COOKIE['freeside_session_id'],
+      'comp'       => '/elements/tr-amount_fee.html',
+      'args'       => [ 'amount',  $balance ],
+  ));
+  //$tr_amount_fee = $tr_amount_fee->{'error'} || $tr_amount_fee->{'output'};
+  $tr_amount_fee = $tr_amount_fee['output'];
+
+  ?>
+
+  <?php include('elements/error.php'); ?>
+
+  <FORM NAME="OneTrueForm" METHOD="POST" ACTION="payment_cc.php" onSubmit="document.OneTrueForm.process.disabled=true">
+
+  <TABLE>
+  <TR>
+    <TD ALIGN="right">Amount Due</TD>
+    <TD COLSPAN=7>
+      <TABLE><TR><TD>
+        $<?php echo sprintf("%.2f", $balance) ?>
+      </TD></TR></TABLE>
+    </TD>
+  </TR>
+
+  <?php echo $tr_amount_fee; ?>
+
+  <TR>
+    <TD ALIGN="right">Card type</TD>
+    <TD COLSPAN=7>
+      <SELECT NAME="card_type"><OPTION></OPTION>
+        <?php foreach ( $card_types AS $ct ) { ?>
+          <OPTION <?php if ( $card_type == $ct ) { echo 'SELECTED'; } ?>
+                  VALUE="<?php echo $ct; ?>"><?php echo $ct; ?>
+        <?php } ?>
+      </SELECT>
+    </TD>
+  </TR>
+
+  <?php include('elements/card.php'); ?>
+
+  <TR>
+    <TD COLSPAN=8>
+      <INPUT TYPE="checkbox" <?php if ( ! $save_unchecked ) { echo 'CHECKED'; } ?> NAME="save" VALUE="1">
+      Remember this card and billing address
+    </TD>
+  </TR><TR>
+    <TD COLSPAN=8>
+      <INPUT TYPE="checkbox" <?php if ( $payby == 'CARD' ) { echo ' CHECKED'; } ?> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
+      Charge future payments to this card automatically
+    </TD>
+  </TR>
+  </TABLE>
+  <BR>
+  <INPUT TYPE="hidden" NAME="paybatch" VALUE="<?php echo $paybatch ?>">
+  <INPUT TYPE="submit" NAME="process" VALUE="Process payment"> <!-- onClick="this.disabled=true"> -->
+  </FORM>
+
+<?php } ?>
+
+<?php get_footer(); ?>

-----------------------------------------------------------------------

Summary of changes:
 .../wordpress}/elements/card.php                   | 24 +++++-----
 fs_selfservice/wordpress/example_selfservice.php   |  1 +
 .../wordpress}/payment_cc.php                      | 53 ++++++++++------------
 3 files changed, 38 insertions(+), 40 deletions(-)
 copy {ng_selfservice => fs_selfservice/wordpress}/elements/card.php (66%)
 copy {ng_selfservice => fs_selfservice/wordpress}/payment_cc.php (63%)




More information about the freeside-commits mailing list