本文整理汇总了PHP中Cart66Common::arrayToXml方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart66Common::arrayToXml方法的具体用法?PHP Cart66Common::arrayToXml怎么用?PHP Cart66Common::arrayToXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart66Common
的用法示例。
在下文中一共展示了Cart66Common::arrayToXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIntlRates
public function getIntlRates($zipOrigin, $countryCode, $value, $pounds = 0, $ounces = 0, $commercial = 'N', $mailType = 'Package', $container = 'VARIABLE', $size = "REGULAR", $machinable = 'true', $width = 10, $length = 15, $height = 10, $girth = 0)
{
$rateReq = 'IntlRateV2Request USERID="' . $this->_uspsUsername . '"';
$countryName = Cart66Common::getCountryName($countryCode);
$weight = $this->_convertToPoundOunces($pounds);
$pounds = $weight->pounds;
$ounces += $weight->ounces;
$data = array('Revision' => '4', 'Package ID="1"' => array('Pounds' => $pounds, 'Ounces' => $ounces, 'Machinable' => $machinable, 'MailType' => $mailType, 'ValueOfContents' => $value, 'Country' => $countryName, 'Container' => $container, 'Size' => $size, 'Width' => $width, 'Length' => $length, 'Height' => $height, 'Girth' => $girth, 'OriginZip' => $zipOrigin));
$xml = Cart66Common::arrayToXml($data, $rateReq);
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS Intl rate request xml:\n{$xml}");
$url = 'http://production.shippingapis.com/ShippingAPI.dll?API=IntlRateV2&Xml=' . urlencode($xml);
$result = Cart66Common::curl($url);
// Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] USPS Result:\n" . $result);
$this->_parseIntlResult($result);
return $this->_rates;
}
示例2: pay
/**
* Pay a spreedly invoice. The invoice token is required for payment.
* Returns the paid invoice token.
*
* @param mixed $paymentMethod Either "on-file" or a SpreedlyCreditCard object
* @param string $invoiceToken
* @return string The invoice token that was paid.
* @throws SpreedlyException on failure
*/
public function pay($paymentMethod, $invoiceToken = null)
{
$payment = array('account-type' => 'on-file');
if (get_class($paymentMethod) == 'SpreedlyCreditCard') {
if (!$paymentMethod->validate()) {
$errorDetails = print_r($paymentMethod->getErrors(), true);
throw new SpreedlyException('Spreedly Payment: Invalid credit card data trying to be used to pay a spreedly invoice: ' . $errorDetails, 66001);
}
$cardData = $paymentMethod->getCardData();
$payment = array('account-type' => 'credit-card', 'credit-card' => $cardData);
}
// Set invoice token if provided
if (isset($invoiceToken)) {
$this->setToken($invoiceToken);
}
// Make sure there is an invoice token before trying to process the payment
if (empty($this->_invoiceToken)) {
throw new SpreedlyException('Spreedly Payment: Trying to pay spreedly invoice without a valid invoice token', 66002);
}
$xml = Cart66Common::arrayToXml($payment, 'payment');
$result = SpreedlyCommon::curlRequest('/invoices/' . $this->_invoiceToken . '/pay.xml', "put", $xml);
$responseCode = $result->code;
if (!empty($responseCode)) {
if ($responseCode != 200) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Invoice Payment: Failed to pay invoice. \n Code: " . $responseCode . "\nResponse: " . $result->response . "\n Payment XML:\n{$xml}");
$errorResponse = $result->response;
throw new SpreedlyException("Spreedly Payment: Failed to pay spreedly invoice. \n\n{$errorResponse}", $responseCode);
}
try {
$invoice = new SimpleXMLElement($result->response);
$this->_invoiceToken = $invoice->token;
} catch (Exception $e) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] SpreedlyInvoice pay(): \n Unable to create SimpleXmlElement from result response: " . $result->response);
}
}
}
示例3: updateRemoteAccount
/**
* All fields are optional - any field that is not provided will not be updated.
*/
public static function updateRemoteAccount($customerId, $subscriberData)
{
$subscriberXml = Cart66Common::arrayToXml($subscriberData, 'subscriber');
$result = SpreedlyCommon::curlRequest("/subscribers/{$customerId}.xml", "put", $subscriberXml);
if ($result->code != '200') {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Spreedly Subscriber: Account information could not be updated. " . $result->response . "\nCode: {$result->code}");
throw new SpreedlyException('Spreedly Subscriber: Account information could not be updated.', $result->code);
}
}