Ejemplo n.º 1
0
 public function TransferToProvider()
 {
     $url = 'https://secure.chronopay.com/index_shop.cgi';
     $currency = GetDefaultCurrency();
     $currency = $currency['currencycode'];
     $hash = md5($GLOBALS['ISC_CFG']['serverStamp'] . $_COOKIE['SHOP_ORDER_TOKEN'] . $this->GetCombinedOrderId() . $this->GetValue('ProductId'));
     $billingDetails = $this->GetBillingDetails();
     $chronopayform['product_id'] = $this->GetValue('ProductId');
     $chronopayform['product_name'] = $GLOBALS['StoreName'];
     $chronopayform['product_price'] = $this->GetGatewayAmount();
     $chronopayform['product_price_currency'] = $currency;
     $chronopayform['language'] = $this->GetValue('LanguageCode');
     $chronopayform['cs1'] = $hash;
     $chronopayform['cs2'] = $_COOKIE['SHOP_ORDER_TOKEN'];
     $chronopayform['cb_url'] = $GLOBALS['ShopPath'] . '/modules/checkout/chronopaypage/chronopaypingback.php';
     $chronopayform['decline_url'] = $GLOBALS['ShopPath'] . '/finishorder.php';
     $chronopayform['cb_type'] = 'P';
     $chronopayform['f_name'] = $billingDetails['ordbillfirstname'];
     $chronopayform['s_name'] = $billingDetails['ordbilllastname'];
     $chronopayform['street'] = $billingDetails['ordbillstreet1'] . ' ' . $billingDetails['ordbillstreet2'];
     $chronopayform['city'] = $billingDetails['ordbillsuburb'];
     if ($billingDetails['ordbillcountryid'] == '38' || $billingDetails['ordbillcountryid'] == '226') {
         $chronopayform['state'] = GetStateISO2ByName($billingDetails['ordbillstate']);
     }
     $chronopayform['zip'] = $billingDetails['ordbillzip'];
     $chronopayform['country'] = GetCountryISO3ById($billingDetails['ordbillcountryid']);
     $chronopayform['phone'] = $billingDetails['ordbillphone'];
     $chronopayform['email'] = $billingDetails['ordbillemail'];
     header('Location: ' . $url . '?' . http_build_query($chronopayform));
 }
Ejemplo n.º 2
0
 protected function _ConstructPostData($postData)
 {
     // PaymentExpress accepts payments in cents
     $ccname = $postData['name'];
     $cctype = $postData['cctype'];
     $ccissueno = $postData['ccissueno'];
     $ccissuedatem = $postData['ccissuedatem'];
     $ccissuedatey = $postData['ccissuedatey'];
     $ccnum = $postData['ccno'];
     $ccexpm = $postData['ccexpm'];
     $ccexpy = $postData['ccexpy'];
     $cccvd = $postData['cccvd'];
     $currency = GetDefaultCurrency();
     $billingDetails = $this->GetBillingDetails();
     $chronoPayPostData['opcode'] = 1;
     $chronoPayPostData['product_id'] = $this->GetValue('productid');
     $chronoPayPostData['fname'] = $billingDetails['ordbillfirstname'];
     $chronoPayPostData['lname'] = $billingDetails['ordbilllastname'];
     $chronoPayPostData['cardholder'] = $ccname;
     $chronoPayPostData['zip'] = $billingDetails['ordbillzip'];
     $chronoPayPostData['street'] = $billingDetails['ordbillstreet1'] . ' ' . $billingDetails['ordbillstreet2'];
     $chronoPayPostData['city'] = $billingDetails['ordbillsuburb'];
     if ($billingDetails['ordbillcountryid'] == '38' || $billingDetails['ordbillcountryid'] == '226') {
         $chronoPayPostData['state'] = GetStateISO2ByName($billingDetails['ordbillstate']);
     }
     $chronoPayPostData['country'] = GetCountryISO3ById($billingDetails['ordbillcountryid']);
     $chronoPayPostData['email'] = $billingDetails['ordbillemail'];
     $chronoPayPostData['phone'] = $billingDetails['ordbillemail'];
     $chronoPayPostData['ip'] = $_SERVER['REMOTE_ADDR'];
     $chronoPayPostData['card_no'] = $ccnum;
     $chronoPayPostData['cvv'] = $cccvd;
     $chronoPayPostData['expirey'] = "20" . $ccexpy;
     $chronoPayPostData['expirem'] = $ccexpm;
     $chronoPayPostData['amount'] = $this->GetGatewayAmount();
     $chronoPayPostData['currency'] = $currency['currencycode'];
     $hash = md5($this->GetValue('sharedsecret') . $chronoPayPostData['opcode'] . $chronoPayPostData['product_id'] . $chronoPayPostData['fname'] . $chronoPayPostData['lname'] . $chronoPayPostData['street'] . $chronoPayPostData['ip'] . $chronoPayPostData['card_no'] . $chronoPayPostData['amount']);
     $chronoPayPostData['hash'] = $hash;
     return http_build_query($chronoPayPostData);
 }
Ejemplo n.º 3
0
 public function setdestinationstate($StateName)
 {
     $this->_destination_state['state_name'] = $StateName;
     $this->_destination_state['state_iso'] = GetStateISO2ByName($StateName);
 }
Ejemplo n.º 4
0
 /**
  * Generate the XML to be sent to UPS to calculate shipping quotes.
  *
  * @return string The generated XML.
  */
 private function GenerateRateXML()
 {
     $shipFromCity = GetConfig('CompanyCity');
     $shipFromState = GetStateISO2ByName(GetConfig('CompanyState'));
     $shipFromZip = GetConfig('CompanyZip');
     $shipFromCountry = GetCountryISO2ByName(GetConfig('CompanyCountry'));
     // Build the XML for the shipping quote
     $xml = new SimpleXMLElement("<AccessRequest xml:lang='en-US'/>");
     $xml->addChild('AccessLicenseNumber', $this->GetValue('accesslicenseno'));
     $xml->addChild('UserId', $this->GetValue('accessuserid'));
     $xml->addChild('Password', $this->GetValue('accesspassword'));
     $accessRequest = $xml->asXML();
     $xml = new SimpleXMLElement('<RatingServiceSelectionRequest/>');
     $request = $xml->addChild('Request');
     // Add in the transaction reference
     $transRef = $request->addChild('TransactionReference');
     $transRef->addChild('CustomerContext', 'Rating and Service');
     $transRef->addChild('XpciVersion', '1.0');
     $request->addChild('RequestAction', 'Rate');
     $request->addChild('RequestOption', 'Shop');
     // Add in the pickup type we'll be using
     $xml->addChild('PickupType')->addChild('Code', $this->GetValue('pickuptypes'));
     // Provide information about the shipment
     $shipment = $xml->addChild('Shipment');
     // Add the information about the shipper
     $shipper = $shipment->addChild('Shipper');
     $shipperNumber = $this->GetValue('upsaccount');
     if ($shipperNumber) {
         $shipper->addChild('ShipperNumber', $shipperNumber);
     }
     $address = $shipper->addChild('Address');
     $address->addChild('City', $shipFromCity);
     $address->addChild('StateProvinceCode', $shipFromState);
     $address->addChild('PostalCode', $shipFromZip);
     $address->addChild('CountryCode', $shipFromCountry);
     // Now add the information about the destination address
     $address = $shipment->addChild('ShipTo')->addChild('Address');
     //$address->addChild('City', 'Sydney');
     if ($this->_destination_state['state_iso']) {
         $state = $this->_destination_state['state_iso'];
     } else {
         $state = $this->_destination_state['state_name'];
     }
     $address->addChild('StateProvinceCode', $state);
     $address->addChild('PostalCode', $this->_destination_zip);
     $address->addChild('CountryCode', $this->_destination_country['country_iso']);
     // Add in the location we're shipping from
     $shipFrom = $shipment->addChild('ShipFrom');
     $address = $shipFrom->addChild('Address');
     $address->addChild('City', $shipFromCity);
     $address->addChild('StateProvinceCode', $shipFromState);
     $address->addChild('PostalCode', $shipFromZip);
     $address->addChild('CountryCode', $shipFromCountry);
     // Add in the package information
     $package = $shipment->addChild('Package');
     $package->addChild('PackagingType')->addChild('Code', $this->GetValue('packagingtype'));
     $packageWeight = $package->addChild('PackageWeight');
     switch (strtolower($shipFromCountry)) {
         case 'us':
         case 'lr':
         case 'mm':
             $weightCode = 'LBS';
             $dimensionsCode = 'IN';
             break;
         default:
             $weightCode = 'KGS';
             $dimensionsCode = 'CM';
     }
     $packageWeight->addChild('UnitOfMeasurement')->addChild('Code', $weightCode);
     $weight = ConvertWeight($this->_weight, $weightCode);
     if ($weightCode == 'LBS' && $weight < 0.1) {
         $weight = 0.1;
     }
     $packageWeight->addChild('Weight', $weight);
     $shipmentDimensions = $this->GetCombinedShipDimensions();
     if ($shipmentDimensions['width'] + $shipmentDimensions['height'] + $shipmentDimensions['length'] > 0) {
         $dimensions = $package->addChild('Dimensions');
         $dimensions->addChild('UnitsOfMeasurement')->addChild('Code', $dimensionsCode);
         $dimensions->addChild('Length', number_format(ConvertLength($shipmentDimensions['length'], $dimensionsCode), 2, '.', ''));
         $dimensions->addChild('Width', number_format(ConvertLength($shipmentDimensions['width'], $dimensionsCode), 2, '.', ''));
         $dimensions->addChild('Height', number_format(ConvertLength($shipmentDimensions['height'], $dimensionsCode), 2, '.', ''));
     }
     $combinedXML = $accessRequest . $xml->asXML();
     //print_R($combinedXML);
     return $combinedXML;
 }
Ejemplo n.º 5
0
 private function GetQuote()
 {
     // The following array will be returned to the calling function.
     // It will contain at least one ISC_SHIPPING_QUOTE object if
     // the shipping quote was successful.
     $fx_quote = array();
     // Connect to FedEx to retrieve a live shipping quote
     $items = "";
     $result = "";
     $valid_quote = false;
     $fx_url = "https://gateway.fedex.com/GatewayDC";
     $weight = number_format(max(ConvertWeight($this->_weight, 'lbs'), 0.1), 1);
     // If we're shipping from US or Canada, originstate is required
     if (GetConfig('CompanyCountry') == "United States" || GetConfig('CompanyCountry') == "Canada") {
         $this->_originstate = GetStateISO2ByName(GetConfig('CompanyState'));
     }
     // If we're shipping to the US or Canada, deststate is required, otherwise it isn't - based off post codes
     if ($this->_destcountry != "US" && $this->_destcountry != "CA") {
         $this->_deststate = '';
     }
     if ($this->_ratetype == "account") {
         $listRate = "false";
     } else {
         $listRate = "true";
     }
     $fx_xml = sprintf("<" . "?" . "xml version=\"1.0\" encoding=\"UTF-8\" " . "?" . ">\n\t\t\t\t<FDXRateRequest xmlns:api=\"http://www.fedex.com/fsmapi\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FDXRateRequest.xsd\">\n\t\t\t\t\t<RequestHeader>\n\t\t\t\t\t\t<CustomerTransactionIdentifier>Express Rate</CustomerTransactionIdentifier>\n\t\t\t\t\t\t<AccountNumber>%s</AccountNumber>\n\t\t\t\t\t\t<MeterNumber>%s</MeterNumber>\n\t\t\t\t\t\t<CarrierCode>%s</CarrierCode>\n\t\t\t\t\t</RequestHeader>\n\t\t\t\t\t<DropoffType>%s</DropoffType>\n\t\t\t\t\t<Service>%s</Service>\n\t\t\t\t\t<Packaging>%s</Packaging>\n\t\t\t\t\t<WeightUnits>LBS</WeightUnits>\n\t\t\t\t\t<Weight>%s</Weight>\n\t\t\t\t\t<OriginAddress>\n\t\t\t\t\t\t<StateOrProvinceCode>%s</StateOrProvinceCode>\n\t\t\t\t\t\t<PostalCode>%s</PostalCode>\n\t\t\t\t\t\t<CountryCode>%s</CountryCode>\n\t\t\t\t\t</OriginAddress>\n\t\t\t\t\t<DestinationAddress>\n\t\t\t\t\t\t<StateOrProvinceCode>%s</StateOrProvinceCode>\n\t\t\t\t\t\t<PostalCode>%s</PostalCode>\n\t\t\t\t\t\t<CountryCode>%s</CountryCode>\n\t\t\t\t\t</DestinationAddress>\n\t\t\t\t\t<Payment>\n\t\t\t\t\t\t<PayorType>SENDER</PayorType>\n\t\t\t\t\t</Payment>\n\t\t\t\t\t<PackageCount>1</PackageCount>\n\t\t\t\t\t<ListRate>%s</ListRate>\n\t\t\t\t</FDXRateRequest>\n\t\t\t", $this->_accountno, $this->_meterno, $this->_carriercode, $this->_dropofftype, $this->_service, $this->_packagingtype, $weight, $this->_originstate, $this->_originzip, $this->_origincountry, $this->_deststate, $this->_destzip, $this->_destcountry, $listRate);
     $result = PostToRemoteFileAndGetResponse($fx_url, $fx_xml);
     if ($result === false) {
         $valid_quote = false;
     } else {
         $valid_quote = true;
         $xml = @simplexml_load_string($result);
     }
     if (!$valid_quote || !is_object($xml)) {
         $this->SetError(GetLang('FedExBadResponse') . ' ' . isc_html_escape(print_r($result, true)));
         return false;
     }
     $netCharge = 0;
     if ($this->_ratetype == "list" && isset($xml->EstimatedCharges->ListCharges->NetCharge)) {
         $netCharge = $xml->EstimatedCharges->ListCharges->NetCharge;
     } elseif ($this->_ratetype == "account" && isset($xml->EstimatedCharges->DiscountedCharges->NetCharge)) {
         $netCharge = $xml->EstimatedCharges->DiscountedCharges->NetCharge;
     }
     if ($netCharge != 0) {
         $serviceType = $this->_deliverytypes[$this->_deliverytype] . ", " . $this->_servicetypes[$this->_service];
         $quote = new ISC_SHIPPING_QUOTE($this->GetId(), $this->GetDisplayName(), (double) $netCharge, $serviceType);
         return $quote;
     } else {
         $Error = true;
         if (isset($xml->Error->Message)) {
             $this->SetError((string) $xml->Error->Message);
             return false;
         } else {
             $this->SetError(GetLang('FedExBadResponse') . ' ' . print_r($result, true));
             return false;
         }
     }
 }