PHP implementation for SEQR API

<?php class SEQRInvoice { private $invoice = array( 'paymentMode' => 'IMMEDIATE_DEBIT', 'acknowledgmentMode' => 'NO_ACKNOWLEDGMENT', 'issueDate' => null, 'title' => '', // Your title 'clientInvoiceId' => '', // Your invoice ID 'invoiceRows' => null, 'totalAmount' => null, 'cashierId' => '', // Your cashier ID 'footer' => '' // your footer ); private $currency = "EUR"; public function __construct($cashierId) { $this->invoice['issueDate'] = date('c', time()); $this->invoice['cashierId'] = $cashierId; } public function getInvoice($amount) { $this->invoice['invoiceRows'] = array(array('itemQuantity' => 1, 'itemTotalAmount' => array('value' => $amount, 'currency' => $this->currency))); $this->invoice['totalAmount'] = array('value' => $amount, 'currency' => $this->currency); return $this->invoice; } } class SEQRService { private $user = ""; // Your SEQR user private $userid = ""; // Your SEQR user Id private $password = ""; // Your SEQR user password private $wsdl = "https://extdev.seqr.com/soap/merchant/cashregister-2?wsdl"; private $client; private $context; public function __construct($user, $userid, $password) { $this->client = new SoapClient($this->wsdl); $this->user = $user; $this->userid = $userid; $this->password = $password; $this->context = array( 'channel' => 'WS', 'clientId' => "", // Your client ID 'clientReference' => '', // Your reference 'clientRequestTimeout' => 0, 'initiatorPrincipalId' => array( 'id' => $this->user, 'type' => 'RESELLERUSER', 'userId' => $this->userid ), 'password' => $this->password); } public function registerTerminal() { $result = $this->client->registerTerminal(array('context' => $this->context, 'externalTerminalId' => 'Your terminal id', 'password' => $this->password, 'name' => 'Your name')); if ($result->return->resultCode === 0) { return $result->return; } else { return false; } } public function assignSeqrId($terminalId) { $initiatorPrincipalId = array('id' => $terminalId, 'type' => 'TERMINALID'); $this->context['initiatorPrincipalId'] = $initiatorPrincipalId; $result = $this->client->assignSeqrId(array('context' => $this->context, 'seqrId' => $terminalId)); if ($result->return->resultCode === 0) { return $result->return; } else { return false; } } public function sendInvoice($terminalId, $invoice) { $initiatorPrincipalId = array('id' => $terminalId, 'type' => 'TERMINALID'); $this->context['initiatorPrincipalId'] = $initiatorPrincipalId; $result = $this->client->sendInvoice(array('context' => $this->context, 'invoice' => $invoice)); if ($result->return->resultCode === 0) { return $result->return; } else { return false; } } public function getPaymentStatus($terminalId, $invoice, $invoiceReference) { $initiatorPrincipalId = array('id' => $terminalId, 'type' => 'TERMINALID'); $this->context['initiatorPrincipalId'] = $initiatorPrincipalId; $result = $this->client->getPaymentStatus(array('context' => $this->context, 'invoice' => $invoice, 'invoiceReference' => $invoiceReference, 'invoiceVersion' => 0)); if ($result->return->resultCode === 0) { return $result->return; } else { return false; } } public function cancelInvoice($terminalId, $invoiceReference) { $initiatorPrincipalId = array('id' => $terminalId, 'type' => 'TERMINALID'); $this->context['initiatorPrincipalId'] = $initiatorPrincipalId; $result = $this->client->cancelInvoice(array('context' => $this->context, 'invoiceReference' => $invoiceReference)); if ($result->return->resultCode === 0) { return true; } else { return false; } } public function refundPayment($terminalId, $invoice, $ersReference) { $initiatorPrincipalId = array('id' => $terminalId, 'type' => 'TERMINALID'); $this->context['initiatorPrincipalId'] = $initiatorPrincipalId; $result = $this->client->refundPayment(array('context' => $this->context, 'ersReference' => $ersReference, 'invoice' => $invoice)); if ($result->return->resultCode === 0) { return $result->return; } else { return false; } } public function unregisterTerminal() { $result = $this->client->unregisterTerminal(array('context' => $this->context)); if ($result->return->resultCode === 0) { return true; } else { return false; } } }
PHP implementation for SEQR API

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.