36 private $_transaction;
59 private $_line_item_count;
67 $this->_line_item_count = 0;
81 $line_items = Array();
83 foreach($this->_line_items as $id => $line_item) {
84 $line_items[
"LineItem id=\"".$id.
"\""] = $line_item;
88 "NewTransactionDataset" => Array(
89 "Purchaser" => $this->_purchaser,
90 "Transaction" => $this->_transaction,
110 preg_match(
'|xmlns="(.*?)"|msi', $new_transaction_xsd, $match);
111 $xml_ns = (isset($match[1])) ? $match[1] :
'';
118 $new_transaction_dataset = str_replace(
"<NewTransactionDataset>",
"<NewTransactionDataset xmlns=\"$xml_ns\">", $new_transaction_dataset);
121 return $new_transaction_xsd.$new_transaction_dataset;
154 foreach($str as $key => $value) {
158 $xml .=
"\n<$key>".$this->_convertToXML($value).
"</".preg_replace(
'|\s.*$|',
'', $key).
">";
180 function addPurchaserRow($fname, $sname, $email, $address1, $address2, $suburb, $city, $postcode)
182 $this->_purchaser = Array(
184 "Firstname" => $fname,
186 "AddressLine1" => $address1,
192 if (!empty($email)) {
193 $this->_purchaser[0][
"Email"] = $email;
195 if (!empty($address2)) {
196 $this->_purchaser[0][
"AddressLine2"] = $address2;
198 if (!empty($suburb)) {
199 $this->_purchaser[0][
"Suburb"] = $suburb;
201 if (!empty($postcode)) {
202 $this->_purchaser[0][
"Postcode"] = $postcode;
223 function addTransactionRow($reference_id, $credit_card, $expiry_date, $card_holder_name, $merchant_id=
'', $payment_model=
'', $gst_rate=0)
225 $this->_transaction = Array(
227 "ReferenceId" => $reference_id,
228 "CreditCard" => $credit_card,
229 "ExpiryDate" => $expiry_date,
230 "CardHolderName" => $card_holder_name,
231 "GstRate" => $gst_rate,
237 if (!empty($merchant_id)) {
238 $this->_transaction[0][
'MerchantId'] = $merchant_id;
240 if (!empty($payment_model)) {
241 $this->_transaction[0][
'PaymentModel'] = $payment_model;
266 function addLineItemRow($application_username, $name, $description, $quantity, $refund_type, $refund_expiry_date, $amount, $product_code, $financial_code, $financial_values, $additional_info)
269 $reference_id = $this->_transaction[0][
'ReferenceId'].
'/'.$this->_line_item_count++;
271 $line_item_dataset = Array(
272 "ReferenceId" => $reference_id,
274 "Description" => $description,
275 "Quantity" => $quantity,
276 "RefundType" => $refund_type,
281 if (!empty($application_username)) {
282 $line_item_dataset[
"ApplicationUsername"] = $application_username;
284 if (!empty($refund_expiry_date)) {
285 $line_item_dataset[
"RefundExpiryDate"] = $refund_expiry_date;
287 if (!empty($product_code)) {
288 $line_item_dataset[
"ProductCode"] = $product_code;
290 if (!empty($financial_code)) {
291 $line_item_dataset[
"FinancialCode"] = $financial_code;
293 if (!empty($financial_values)) {
294 $line_item_dataset[
"FinancialValues"] = $financial_values;
296 if (!empty($additional_info)) {
297 $line_item_dataset[
"AdditionalInfo"] = $additional_info;
300 $this->_line_items[$reference_id] = $line_item_dataset;
315 $new_transaction_xsd = <<<XSD_CONTENT
317 <xs:schema
id=
"Transaction" targetNamespace=
"http://www.paymentgateway.co.nz/_schemas/Transaction.xsd"
318 elementFormDefault=
"qualified" attributeFormDefault=
"qualified"
319 xmlns=
"http://www.paymentgateway.co.nz/_schemas/Transaction.xsd"
320 xmlns:mstns=
"http://www.paymentgateway.co.nz/_schemas/Transaction.xsd"
321 xmlns:xs=
"http://www.w3.org/2001/XMLSchema" xmlns:msdata=
"urn:schemas-microsoft-com:xml-msdata">
322 <xs:element name=
"NewTransactionDataset" msdata:IsDataSet=
"true">
324 <xs:choice maxOccurs=
"unbounded">
325 <xs:element name=
"Purchaser">
328 <xs:element name=
"Firstname" type=
"xs:string" />
329 <xs:element name=
"Surname" type=
"xs:string" />
330 <xs:element name=
"Email" type=
"xs:string" minOccurs=
"0" />
331 <xs:element name=
"AddressLine1" type=
"xs:string" />
332 <xs:element name=
"AddressLine2" type=
"xs:string" minOccurs=
"0" />
333 <xs:element name=
"Suburb" type=
"xs:string" minOccurs=
"0" />
334 <xs:element name=
"City" type=
"xs:string" />
335 <xs:element name=
"PostCode" type=
"xs:int" minOccurs=
"0" />
339 <xs:element name=
"Transaction">
342 <xs:element name=
"ReferenceId" type=
"xs:string" />
343 <xs:element name=
"CreditCard" type=
"xs:string" />
344 <xs:element name=
"ExpiryDate" type=
"xs:string" />
345 <xs:element name=
"CardHolderName" type=
"xs:string" />
346 <xs:element name=
"MerchantId" type=
"xs:int" minOccurs=
"0" />
347 <xs:element name=
"PaymentModel" type=
"xs:string" minOccurs=
"0" />
348 <xs:element name=
"GstRate" type=
"xs:decimal" minOccurs=
"0" />
352 <xs:element name=
"LineItem">
355 <xs:element name=
"ReferenceId" type=
"xs:string" />
356 <xs:element name=
"ApplicationUsername" type=
"xs:string" minOccurs=
"0" />
357 <xs:element name=
"Name" type=
"xs:string" />
358 <xs:element name=
"Description" type=
"xs:string" />
359 <xs:element name=
"Quantity" type=
"xs:int" />
360 <xs:element name=
"RefundType" type=
"xs:string" />
361 <xs:element name=
"RefundExpiryDate" type=
"xs:dateTime" minOccurs=
"0" />
362 <xs:element name=
"Amount" type=
"xs:decimal" />
363 <xs:element name=
"ProductCode" type=
"xs:string" minOccurs=
"0" />
364 <xs:element name=
"FinancialCode" type=
"xs:string" minOccurs=
"0" />
365 <xs:element name=
"FinancialValues" type=
"xs:string" minOccurs=
"0" />
366 <xs:element name=
"AdditionalInfo" type=
"xs:string" minOccurs=
"0" />
372 <xs:key name=
"NewTransactionDatasetKey1" msdata:PrimaryKey=
"true">
373 <xs:selector xpath=
".//mstns:LineItem" />
374 <xs:field xpath=
"mstns:ReferenceId" />
376 <xs:key name=
"NewTransactionDatasetKey2" msdata:PrimaryKey=
"true">
377 <xs:selector xpath=
".//mstns:Transaction" />
378 <xs:field xpath=
"mstns:ReferenceId" />
385 return $new_transaction_xsd;