<?php

require_once('encgateway/init.php');

//7E35FC46-C951-2D2F-FB42-7795F3D24C60
//04A6CD35-1278-B5AD-14F9-E71F0C493EE5
//9DAC990B-63AA-5C93-3826-83DAA9B13EDD

Encgateway\Apib::setApiKey("7E35FC46-C951-2D2F-FB42-7795F3D24C60");


$cartItem = array();
//productType, itemName, description, quantity, price
$cartItem[] =  array('electronics','refrigator','single door',1,100.20);
$cartItem[] =  array('electronics','refrigator 2','double door',1,50.20);


session_start();
$session_id = session_id();
$device_data = array('device_session_id' => $session_id);

/*
* START StoreCard ProcessStoreCard
*/


//$return = \Encgateway\ManageCustomer::create(array('TransType' => 'ADD','Vendor'=>'239','CustomerKey'=> '','CustomerID'=>'112','CustomerName' => 'My customer',"FirstName" => 'Jaydeep','Company' => 'test com','CardHolderName' => 'xyzcard','LastName' =>'Chauhan','Title'=>'My Title','Department'=>'My Deparment','Street1' => 'Address 1','Street2' => 'Address2','Street3' => 'Address 3','City'=> 'My city','StateID' => '23','Province' => 'my province','Zip' =>'123456', 'CountryID' => 'Can','DayPhone' => '10234','NightPhone' => '1000','Mobile'=> '10002','Fax' => '123456','Email'=>'test@gmail.com','Status'=>'Active'));



//$return = \Encgateway\StoreCard::create(array('TokenMode' => 'CARDFORMAT','CardNum' => '4111111111111111','ExpDate' => '1233','CustomerKey' => '303','NameOnCard' => 'John Doe','Street' => '123 Miami Street','Zip' => '123456','ExtData' => ''));



//$return = \Encgateway\ProcessStoredCard::create(array('TransType' => 'Auth','TokenMode' => 'CARDFORMAT','CardToken' => '4904102399176208','Amount' => '20.00','InvNum' => time(),'ExtData' => ''));

/*
* END StoreCard ProcessStoreCard
*

/*
* START CHARGE EXAMPLE
*/

/*
* for china union pay 
* Add RegisterNum => 56 
*/
//$return = \Encgateway\Charge::create(array('TransType'=>'Sale','RegisterNum' => '56','ExpDate' => '1233','Amount' => '20.34','CardNum' => '4111111111111111','orderDesc' => 'testorder','orderDate' => '1469252624','shippingFee' => '0.00','shippingDiscount' => '0.00','billingName' => 'John Doe','billingAddress1' => 'testaddress','billingAddress2' => 'address2','billingCity' => 'city','billingState' => 'state','billingPostCode' => '1234','billingCountry' => 'US','billingEMail' => 'test@email.com','billingPhone' => '134567890','deliveryName' => 'test','deliveryAddress1' => 'testaddress','deliveryAddress2' => 'address2','deliveryCity' => 'city','deliveryState' => 'state','deliveryPostCode' => '1234','deliveryCountry' => 'US','deliveryEMail' => 'test@email.com','deliveryPhone' => '134567890','remarks' => 'testremark','successUrl' => 'http://testsite1.dev/','failUrl' => 'http://testsite1.dev/'));


//$return = \Encgateway\Charge::create(array('TransType'=>'Sale', 'NameOnCard' => 'John Doe','CardNum' => '4111111111111111','ExpDate'=>'1233','CVNum'=>'123','InvNum'=>'1461322603869','RegisterNum' => '68','Zip'=>'38922','City'=>'Coffeeville','State'=>'US','Street'=>'4207 Oxford Court','Country' => 'MN','shippingZip'=>'38922','shippingCity'=>'Coffeeville','shippingState'=>'US','shippingStreet'=>'4207 Oxford Court','shippingCountry' => 'MN','MobilePhone' => '9898989898','MagData'=>'','PNRef'=>'','Amount'=>'23.00','TipAmt'=>'0','TaxAmt'=>'0','SureChargeAmt'=> '0','CashBackAmt' => '0','ExtData' => '<force>T</force>','Email'=>'test@email.com','paycertifyTransaction' => 1));

//$return = \Encgateway\Charge::create(array('TransType'=>'Sale', 'NameOnCard' => 'John Doe','CardNum' => '4111111111111111','ExpDate'=>'1233','CVNum'=>'123','InvNum'=>'4','RegisterNum' => '68','Zip'=>'38922','Street'=>'4207 Oxford Court','Country' => 'MN','City'=>'Coffeeville','State'=>'US','Amount'=>'23.00','SureChargeAmt'=> '0','CashBackAmt' => '0','ExtData' => '<force>T</force>'));

//$return = \Encgateway\Charge::create(array('TransType'=>'Void', 'NameOnCard' => 'john doe','PNRef' => '2173703'));

//$return = \Encgateway\Charge::create(array('TransType'=>'Force', 'NameOnCard' => 'john doe','CardNum' => '4111111111111111','ExpDate'=>'0816','CVNum'=>'123','PNRef' => '2167841'));

//$return = \Encgateway\Charge::create(array('TransType'=>'Repeat', 'NameOnCard' => 'john doe','CardNum' => '4111111111111111','ExpDate'=>'0816','CVNum'=>'123','PNRef' => '2167840'));

//$return = \Encgateway\Charge::create(array('TransType'=>'Return','PNRef' => '2173710','Amount' => '23.00'));


/*
* END CHARGE EXAMPLE
*/

/*
* START MANAGE CUSTOMER
*/
//$return = \Encgateway\ManageCustomer::create(array('TransType' => 'ADD','Vendor'=>'107','CustomerID'=>'321','CustomerName' => 'My customer',"FirstName" => 'Jaydeep','LastName' =>'Chauhan','Title'=>'My Title','Department'=>'My Deparment','Street1' => 'Address 1','Street2' => 'Address2','Street3' => 'Address 3','City'=> 'My city','StateID' => '23','Province' => 'my province','Zip' =>'123456', 'CountryID' => 'Can','DayPhone' => '10234','NightPhone' => '1000','Mobile'=> '10002','Fax' => '123456','Email'=>'test@gmail.com','Status'=>'Active'));

//$return = \Encgateway\ManageCustomer::delete(array('TransType' => 'DELETE','Vendor'=>'103','CustomerKey'=> '85','CustomerID'=>'102','CustomerName' => 'My customer'));

//$return = \Encgateway\ManageCustomer::update(array('TransType' => 'UPDATE','Vendor'=>'103','CustomerKey'=> '84','CustomerID'=>'102','CustomerName' => 'My customer',"FirstName" => 'Update Jaydeep','LastName' =>'Update Chauhan','Title'=>'Update My Title','Department'=>'Update My Deparment','Street1' => 'Address 1','Street2' => 'Address2','Street3' => 'Address 3','City'=> 'My city','StateID' => '23','Province' => 'my province','Zip' =>'123456', 'CountryID' => 'Can','DayPhone' => '10234','NightPhone' => '1000','Mobile'=> '10002','Fax' => '123456','Email'=>'test@gmail.com','Status'=>'INACTIVE'));

/*
* START MANAGE CUSTOMER
*/

//$return = \Encgateway\GetCardTrx::create(array('UserName'=>'basecommmerch','Password' => 'M4sm3ljf','ExcludeVoid' => 'TRUE','BeginDt' => '2016-04-23','EndDt' => '2016-04-27', 'User' => '107','Result' => '0'));



/*
* START MANAGE CREDITCARDINFO
*/


//$return = \Encgateway\ManageCreditCardInfo::create(array('TransType' => 'ADD','Vendor'=>'107','CustomerKey'=>'303','CcAccountNum' => '4111111111111111','CcExpDate' => '0424','CcNameOnCard' => 'testing card','CcStreet' => 'my cc stret','CCZip' => '12032','ExtData' => '<data>F</data>'));

//$return = \Encgateway\ManageCreditCardInfo::update(array('TransType' => 'UPDATE','Vendor'=>'103','CustomerKey'=>'85','CardInfoKey'=> '79','CcAccountNum' => '4111111111111111','CcExpDate' => '0424','CcNameOnCard' => 'update testing card','CcStreet' => 'my cc stret','CCZip' => '12032','ExtData' => '<data>F</data>'));

//$return = \Encgateway\ManageCreditCardInfo::delete(array('TransType' => 'DELETE','Vendor'=>'107','CustomerKey'=>'45','CardInfoKey'=> '32'));

/*
* END MANAGE CREDITCARDINFO
*/


/*
* END MANAGE CHECKINFO
*/

//$return = \Encgateway\ManageCheckInfo::create(array('TransType' => 'ADD','Vendor'=>'107','CustomerKey'=>'303','CheckType' => 'PERSONAL','AccountType' => 'CHECKING','AccountNum' => '4111111111111111','TransitNum' => '234','CheckNum' => '012345','MICR' => 'Magnetic Ink Check Reader data line.','SS' => '2323','DOB' => '22041990','BranchCity' => 'perth','DL' => '234234234434','StateCode' => 'SL','NameOnCheck' => 'Testing name','Email' => 'testing@rmai.com','DayPhone' => '3242342342','Street1' => 'address 1','Street2' => 'sdfsdf', 'Street3' => 'three street','City' => 'city','StateID' => 'DE','Province'=> 'Province','PostCode' => '234234','CountryID' => 'CAN','ExtDate' => 12051990));


//$return = \Encgateway\ManageCheckInfo::update(array('TransType' => 'UPDATE','Vendor'=>'103','CustomerKey'=>'85','CheckInfoKey'=>'80', 'CheckType' => 'PERSONAL','AccountType' => 'CHECKING','AccountNum' => '4111111111111111','TransitNum' => '234','CheckNum' => '012345','MICR' => 'update Magnetic Ink Check Reader data line.','SS' => '2323','DOB' => '22041990','BranchCity' => 'u perth','DL' => '234234234434','StateCode' => 'SL','NameOnCheck' => 'update Testing name','Email' => 'testing@rmai.com','DayPhone' => '3242342342','Street1' => 'address 1','Street2' => 'sdfsdf', 'Street3' => 'three street','City' => 'city','StateID' => 'DE','Province'=> 'Province','PostCode' => '234234','CountryID' => 'CAN','ExtDate' => 12051990));

//$return = \Encgateway\ManageCheckInfo::delete(array('UserName'=>'test_emp','Password' => '123456','TransType' => 'DELETE','Vendor'=>'107','CustomerKey'=>'45','CheckType' => 'PERSONAL','CheckInfoKey'=>'37','AccountType' => 'CHECKING','AccountNum' => '4111111111111111','TransitNum' => '234'));

/*
* END MANAGE CHECKINFO
*/


/*
* START MANAGE CONTRACT
*/
//$return = \Encgateway\ManageContract::create(array('UserName'=>'basecommmerch','Password' => 'M4sm3ljf','TransType' => 'ADD','Vendor'=>'107','CustomerKey'=> '303','CustomerID'=>'321','BillAmt' => '12.0000','PaymentInfoKey' => '142','PaymentType' => 'CARD','StartDate' => '09122016','EndDate' => '12122016','BillingPeriod' => 'WEEK','BillingInterval' => '2','ContractId' => '0001','ContractName' => 'My contract','TaxAmt' => '0.00','TotalAmt' => '0.00','MaxFailures' => 1,'FailureCount'=>'2','status' => 'ACTIVE','EmailMerchant'=>'1','EmailMerchantFailure'=>'1','EmailCustomer'=>'1','EmailCustomerFailure'=>'1'));


//$return = \Encgateway\ManageContract::delete(array('TransType' => 'DELETE','Vendor'=>'103','CustomerKey'=> '85','CustomerID'=>'102','PaymentInfoKey' => '79','ContractKey' => '23','PaymentType' => 'CARD'));

//$return = \Encgateway\ManageContract::update(array('TransType' => 'UPDATE','Vendor'=>'103','CustomerKey'=> '85','ContractKey'=>23,'CustomerID'=>'102','BillAmt' => '12.00','PaymentInfoKey' => '79','PaymentType' => 'CARD','StartDate' => '09122016','EndDate' => '12122016','BillingPeriod' => 'WEEK','BillingInterval' => '2','ContractId' => '0001','ContractName' => 'update1 My contract ','TaxAmt' => '0.00','TotalAmt' => '0.00','MaxFailures' => 1,'FailureCount'=>'2','status' => 'ACTIVE','EmailMerchant'=>'1','EmailMerchantFailure'=>'1','EmailCustomer'=>'1','EmailCustomerFailure'=>'1'));

/*
* END MANAGE CONTRACT
*/

/*
* START MANAGE CONTRACT ADDDAYSTONEXTBILLDATE
*/

//$return = \Encgateway\ManageContractAddDaysToNextBillDt::create(array('Vendor' => '103','CustomerKey' => '85','ContractKey' => '24','NumOfDays' => 10,'ExtData' => ''));

/*
* END MANAGE CONTRACT ADDDAYSTONEXTBILLDATE
*/

/*
$return = \Encgateway\CaptureReceipt::create(array('Amount'=>'23.00','AuthCode' => '2173710','AuthTime' => '20160823090325','PNRef' => time(),'CardEaseReference' => '0220e919-4b69-e611-8e66-0050569228c2','CardHash' => 'ExN/uBaDWTa6QkPRlU26rqfKuDU=','CardReference' => '98642dfd-6737-e411-a99d-001422187e37','CardType' => 'VISA DEBIT','ExpireDate' => '1712','MerchantName' => 'Standard Test Merchant', 'PanMasked'=>'476173******0211', 'PanSequence' => '01', 'Receipt' => '<?xml version="1.0" encoding="utf-8"?><ReceiptData version="1.0.0"><ReceiptEntries><ReceiptEntry><ReceiptEntryId>MerchantName</ReceiptEntryId><Value>Standard Test Merchant</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>1</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>PanMasked</ReceiptEntryId><Value>************0211</Value><Label>Card</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>4</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TransactionType</ReceiptEntryId><Value>SALE</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>8</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>AuthReference</ReceiptEntryId><Value>96a343ab-cd83-4d9d-868f-2b931c3c6593</Value><Label>Ref</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>18</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>MerchantIdMasked</ReceiptEntryId><Value>*****67897</Value><Label>MID</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>19</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TerminalIdMasked</ReceiptEntryId><Value>****2913</Value><Label>TID</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>20</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>AuthDateTime</ReceiptEntryId><Value>2016/08/23 09:03:25</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>22</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>RetentionMessage</ReceiptEntryId><Value>Please retain for your records</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>23</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TransactionResult</ReceiptEntryId><Value>APPROVED</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>15</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>AuthCode</ReceiptEntryId><Value>DE758D</Value><Label>Auth Code</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>17</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>CardholderVerification</ReceiptEntryId><Value>PIN VERIFIED</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>13</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TotalAmount</ReceiptEntryId><Value>USD1.00</Value><Label>TOTAL</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>11</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TransactionSource</ReceiptEntryId><Value>ICC</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>6</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>PanSequence</ReceiptEntryId><Value>01</Value><Label>PAN Seq No</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>5</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>Aid</ReceiptEntryId><Value>A0000000031010</Value><Label>AID</Label><ReceiptItemType>Mandatory</ReceiptItemType><Priority>2</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>CardScheme</ReceiptEntryId><Value>VISA DEBIT</Value><Label /><ReceiptItemType>Mandatory</ReceiptItemType><Priority>3</Priority></ReceiptEntry><ReceiptEntry><ReceiptEntryId>TransactionSeqNumber</ReceiptEntryId><Value>00000047</Value><Label>Transaction Seq. No</Label><ReceiptItemType>Optional</ReceiptItemType><Priority>21</Priority></ReceiptEntry></ReceiptEntries></ReceiptData>', 'Reference' => '96a343ab-cd83-4d9d-868f-2b931c3c6593', 'Result' => 'APPROVED', 'SignatureCaptured' => 'False', 'SignatureRequired' => 'False', 'TransSource' =>'ICC', 'TransType' => 'Sale', 'TransVerification' => 'PIN VERIFIED', 'DeviceModel' => 'Ingenico-iPP350-RBA', 'DeviceId' => '2214324PT012653' ));
*/
/*
$return = \Encgateway\CaptureReceipt::delete(array('LogKey' => '1507'));
*/

/*
* -:: RESPONSE ::-
*/
echo "<pre>";
print_r($return);
/*
* -:: RESPONSE ::-
*/


