Payments with myPOS .NET SDK

This guide walks you through handling transaction responses and performing key payment operations like purchases, refunds, pre-authorizations, and receipt printing.

Handling Transaction Responses

When a response is received from the myPOS Terminal, an event is raised. To process this, you should subscribe to the event and handle the result accordingly.

1. Define an Event Handler

       protected void ProcessResult(ProcessingResult r)
       {
	       // handle the response here
            if (r.TranData != null)
            {
		          // transaction response
            }
 		   }
       

2. Subscribe to the Event
Attach your handler in the form constructor:

   public Form1()
    {
         InitializeComponent();

         terminal.ProcessingFinished += ProcessResult;
    }  

Making a Payment

Once your terminal is initialized and connected, you can process a card payment like this:

RequestResult r = terminal.Purchase(Amount, cur, txtReference.Text);
  • Amount: The total to be charged.
  • cur: The currency.
  • txtReference.Text: Optional reference (can be null or empty).

Issuing a Refund

Refund a previous payment to the customer's card:

RequestResult r = terminal.Refund(Amount, cur, txtReference.Text);

Pre-Authorization

To lock a specific amount on the customer’s card without capturing it immediately:

RequestResult r = t.Preauthorization(Amount, cur, txtReference.Text);

Completing a Pre-Authorization

When you're ready to capture the funds from a pre-auth:

RequestResult r = t.CompletePreauth(strPreauthCode, Amount);
  • strPreauthCode: Use the code from the original pre-auth.
  • Amount: Must be equal to or less than the pre-authorized amount.

Canceling a Pre-Authorization

To release the locked amount from a pre-authorization:

RequestResult r = t.CancelPreauth(strPreauthCode);

Use the original pre-auth code as the parameter.

Reprinting the Last Receipt

Need to reprint the last transaction slip?

RequestResult r = terminal.ReprintReceipt();

Printing a Custom Receipt

You can print a custom-formatted receipt using special delimiters:

  • \ - Escape symbol

  • \n - New line

  • \L - Logo

  • \l - Left-align

  • \c - Center-align

  • \r - Right-align

  • \W - Double width

  • \w - Normal width

  • \H - Double height

  • \h - Normal height

Example

terminal.PrintExternal(txtPrintData.Text);

Just pass your custom-formatted string from txtPrintData.