Store Credit Card type/digits & other Payment Info using Payment Description

The Payment Screen will show Payment Descriptions. We can capture a lot of information in Payment Descriptions using some fairly simple JScript.

This example shows 6 different Payment Types and their Descriptions.

When we print the Bill, all of this captured information is shown:

------------------------------------------------
GC201508221549307300:             ($5.00) 100.00
2015-09-15 12:47:02.836 [Gift Certificate] (GC201508221549307300)
1111 1111-Celeste:                 ($2.50) 50.00
2015-09-15 12:47:22.280 [Customer Account] (1111 1111-Celeste)
Credit Card USD:                  ($5.00) 100.00
2015-09-15 12:47:30.908 [Credit Card USD] (VISA 1111)
Credit Card:                       ($2.50) 50.00
2015-09-15 12:47:46.681 [Credit Card] (MAST 3333)
Cash:                              ($1.00) 20.00
2015-09-15 12:48:03.955 [Cash]                  
Cash USD:                         ($5.00) 100.00
2015-09-15 12:48:14.019 [Cash USD]              
================================================
GC201508221549307300             Balance: 200.00
************************************************

Set up a Payment Processor for Credit Card

Here we set up an Execute Script Payment Processor for the Credit Card Payment Type.

Tickets > Payment Types > [Credit Card] > Payment Processors

The script we will fire is pay.UpdateDescription()

:bulb: You can add the same Payment Processor to all Payment Types to capture more information for them as well. The original screenshot at the top of this Tutorial has the same Payment Processor assigned to every Payment Type.


Build the Script

Now we configure the Script.

Automation > Scripts

Name: PaymentFunctions
Handler: pay

function UpdateDescription() {
  
  var dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
  var paymenttype = Data.Get("paymentTypeName");
  var paymentinfo = dt + " [" + paymenttype + "]";

  if (paymenttype=='Credit Card' || paymenttype=='Credit Card USD') {
     
    var cctype = dlg.AskQuestion("Choose Credit Card type","Amex=AMEX,Master Card=MAST,Visa=VISA,Discover=DISC,Other=OTHR,CANCEL=CANCEL");
    if (cctype=="CANCEL") {
      Data.Set("canContinue",false);
      dlg.ShowMessage("Payment Cancelled");
      return 1;
    }

    var ccdigits = dlg.EditValue("Last 4 CC Digits;.{4};;ON","");

    paymentinfo += " (" + cctype + " " + ccdigits + ")";

  }
  
  if (paymenttype=='Customer Account' || paymenttype=='Gift Certificate') {
    var accountname = Data.Get("accountName");
    paymentinfo += " (" + accountname + ")";
  }
  
  Data.Set("description", paymentinfo);
  
  dlg.ShowMessage("Payment Processed\r"+paymentinfo);
  
  return 0;
}

Printer Template

We use the {DESCRIPTION} tag in the [PAYMENTS] section of our Printer Template.

[PAYMENTS]
<J00>{PAYMENT NAME}: | {TENDERED}
[<L00>{DESCRIPTION}]

1 Like

Storing Payment Info in a Ticket Tag for later Recall

Now that we can store information in the Payment Description, how do we go about reading/displaying the information after a Ticket is fully Settled and Closed? We can use a Ticket Tag.

:bulb: As an addition, when we display the Payment Info, we can offer the user a choice to Reopen the Ticket and Cancel Payments. This optional setup is contained herein as well.


Automation Command - Display Payment Info

:warning: Ensure Enabled States is BLANK


Action - Update Ticket Tag

Tag Name: Payment Info
Tag Value: [:PaymentInfo]


Action - Ask Question - Display Payment Info

:bulb: You can use Show Message Action here instead, but it’s formatting/display options are limited, and you won’t be able to offer the ReOpen / Cancel Payment option.

Question: [:question]
Buttons: [:buttons]
Automation Command Name: [:AMCname]
Background Color: [:bgcolor]
Transparent Color: [:tcolor]


Action (optional) - Reopen Closed Ticket

Action (optional) - Cancel Ticket Payments


Rule - Payment Processed - Store Payment Info in Ticket Tag

PaymentInfo: {TICKET TAG:Payment Info}\r[:Description] [:ProcessedAmount]


Rule - Automation Command Executed - Show Payment Info

Message: <block 10,10,10,10 Black left><font Consolas><size 16>Payment Info ::: #{TICKET NO} ID:{TICKET ID}</size><size 13><linebreak/>{TICKET TAG:Payment Info}</size></font></block>
Buttons: OK=ok:Green;Blue,ReOpen Ticket and Cancel Payments=REOPEN:Red;Blue
AMCname: PI Close Payment Info
BGcolor: #66444444
Tcolor: #44111111


Rule (optional) - Automation Command Executed - Reopen Ticket and Cancel Payments

PaymentInfo: {TICKET TAG:Payment Info}\r{DATE:yyyy-MM-dd hh:mm:ss.fff} *** PAYMENTS CANCELLED ***

1 Like

Nice tutorial. Now if only we could use this along side another action which sends the total amount paying by card to the eftpos terminal itself :stuck_out_tongue: and then have samba wait for a response from terminal, then update according to decline or approved :stuck_out_tongue:

1 Like

i at this script for Payment Voucher

    if (paymenttype=='Voucher') {   
    var vnum = dlg.EditValue("Voucher Number;.{10};;OCS","");
    paymentinfo = vnum;  }

If i cancel input voucer number will display

how to solved it?

Show your full script.

  function UpdateDescription() {
  var paymenttype = Data.Get("paymentTypeName");

 if (paymenttype=='Credit Card') {
 var cctype = dlg.AskQuestion("Choose Credit Card type","BCA=BCA Card,BNI=BNI Card,MANDIRI=MANDIRI Card,MASTER=MASTER Card,VISA=VISA,CANCEL=CANCEL");
 if (cctype=="CANCEL") {
   Data.Set("canContinue",false);
   dlg.ShowMessage("Payment Cancelled");
   return 1;
 }
 var paymentinfo = cctype;
 }

 if (paymenttype=='Debit Card') {
 var dctype = dlg.AskQuestion("Choose Debit Card type","BCA=BCA,BNI=BNI,MANDIRI=MANDIRI,CANCEL=CANCEL");
 if (dctype=="CANCEL") {
   Data.Set("canContinue",false);
   dlg.ShowMessage("Payment Cancelled");
   return 1;
 }
  var paymentinfo = dctype ;
 }

if (paymenttype=='Voucher') {
var vnum = dlg.EditValue("Voucher Number;.{10};;OCS","");
paymentinfo = vnum;
}

Data.Set("description", paymentinfo);
dlg.ShowMessage("Payment Processed\r"+paymentinfo);
return 0;
 }

I reproduced it. Thank you for reporting. It will work fine on next update.

3 Likes

Hi, thanks a lot for samba, am new to samba and am trying to catch up. ok am trying to add Mpesa payment as a mode of payment:
so whenever the cashier clicks on Mpesa then a pop up appears asking (Enter the Mpesa transaction ID?)
Then there is a text box to enter the ID Which is alphanumeric
After this the Transaction ID is store in the database and printed on the ticket

Just the simple step, So can I use the javascript, I have gone through this Payment type to request for transaction code - #6 by RickH

and

but They seem to be complex for my simple task, I know am still learning Actions, Rule ans automation but Kindly put up with me and help Guys

Hi @QMcKay, first guys thanks for the tutorial. Am new to samba and am trying to catch up. Ok am trying to add Mpesa payment as a mode of payment:
so whenever the cashier clicks on Mpesa then a pop up appears asking (Enter the Mpesa transaction ID?)
Then there is a text box to enter the ID Which is alphanumeric
After this the Transaction ID is store in the database and printed on the ticket

So can I use the javascript, If yes i have gone through, but I dont know why at the payment processors, I cannot select Execute script and its description, so should i add it and from where?

Also see I have added mpesa payment from the screen shot

Heres a perfect tutorial you can adapt

1 Like

Thanks @RickH, I have tried your suggestion but dont Understand where to map and even the automation, would you be willing to help me through

Will appreciate

Im on my way to work so cant until much later tonight. That tutorial does show you exactly what to do theres not really anymore i could do

1 Like

Hi, thanks, its working but now I need to capture alphanumeric digits instead of the digits only [?Credit Card last 4 Digits;\d{4};;ON] , I have changes The ON to OS for the alphanumeric keyboard, now my problem is with \d, whats the tag for alphanumeric. Could someone help

Thanks

In the regular expression, \d is shorthand for [0-9], which means any digit. {4} limits to maximum 4 characters.

Depending on your requirements, you can put together a regular expression using one of the following:

[A-Z0-9] - uppercase alphanumberic
[A-Za-z0-9] - alphanumberic

So if you want 4 alphanumeric characters, you can use [A-Za-z0-9]{4}

NOTE: I haven’t tested this but it should work!

I found info on this and the shorthand codes here: Regexp Tutorial - Shorthand Character Classes

Also you can refer to this guide for details of custom keyboards:

1 Like

thanks, got it, Kudos guys of sambaPOS

1 Like

A post was split to a new topic: Mpesa Integration