本文整理汇总了PHP中ArrayData::array_to_object方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayData::array_to_object方法的具体用法?PHP ArrayData::array_to_object怎么用?PHP ArrayData::array_to_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayData
的用法示例。
在下文中一共展示了ArrayData::array_to_object方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
/**
* Retrieve and process order data from the request
*/
public function callback($request)
{
$this->extend('onBeforeCallback');
$data = $this->request->postVars();
$status = "error";
$order_id = 0;
$payment_id = 0;
$success_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete');
$error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error');
$vars = array("SiteConfig" => SiteConfig::current_site_config(), "RedirectURL" => $error_url);
// Check if CallBack data exists and install id matches the saved ID
if (isset($data) && (isset($data['instId']) && isset($data['cartId']) && isset($data['transStatus']) && isset($data["callbackPW"])) && $this->payment_gateway->InstallID == $data['instId'] && $this->payment_gateway->ResponsePassword == $data["callbackPW"]) {
$order_id = $data['cartId'];
$payment_id = $data['transId'];
$status = $data['transStatus'];
if ($data['transStatus'] == 'Y') {
$status = 'paid';
$vars["RedirectURL"] = $success_url;
} else {
$status = 'failed';
}
} else {
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array("OrderID" => $order_id, "PaymentProvider" => "WorldPay", "PaymentID" => $payment_id, "Status" => $status, "GatewayData" => $data));
$this->setPaymentData($payment_data)->customise($vars);
$this->extend('onAfterCallback');
return $this->renderWith(array("Worldpay_callback"));
}
示例2: testArrayToObject
function testArrayToObject() {
$arr = array("test1" => "result1","test2"=>"result2");
$obj = ArrayData::array_to_object($arr);
$objExpected = new stdClass();
$objExpected->test1 = "result1";
$objExpected->test2 = "result2";
$this->assertEquals($obj,$objExpected, "Two objects match");
}
示例3: convertDataObjectSet
/**
* Generate a BSON representation of the given {@link SS_List}.
*
* @param SS_List $set
* @param null $fields
*
* @return string BSON
*/
public function convertDataObjectSet(SS_List $set, $fields = null)
{
$this->checkForBson();
$items = [];
foreach ($set as $do) {
/** @var DataObject $do */
if (!$do->canView()) {
continue;
}
$items[] = $this->convertDataObjectToJSONObject($do, $fields);
}
$serobj = ArrayData::array_to_object(["totalSize" => is_numeric($this->totalSize) ? $this->totalSize : null, "items" => $items]);
/** @noinspection PhpUndefinedFunctionInspection */
return bson_encode($serobj);
}
示例4: callback
/**
* Process the callback data from the payment provider
*/
public function callback($request)
{
$this->extend('onBeforeCallback');
$data = $this->request->postVars();
$status = "error";
$key = $this->payment_gateway->ConfigKey;
$content = file_get_contents('php://input');
// Check if CallBack data exists and install id matches the saved ID
if (isset($content)) {
$notification = new SofortLibNotification();
$transaction_id = $notification->getNotification($content);
$sofort = new SofortLibTransactionData($key);
$sofort->addTransaction($transaction_id);
$sofort->sendRequest();
switch ($sofort->getStatus()) {
case 'received':
$status = "paid";
break;
case 'loss':
$status = "failed";
break;
case 'pending':
$status = "pending";
break;
case 'refunded':
$status = "refunded";
break;
default:
$status = "error";
}
$payment_data = ArrayData::array_to_object(array("OrderID" => 0, "PaymentProvider" => "Sofort", "PaymentID" => $notification->getTransactionId(), "Status" => $status, "GatewayData" => $data));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return $this->renderWith(array("Sofort_callback", "Checkout", "Page"));
}
return $this->httpError(500);
}
示例5: callback
/**
* Retrieve and process order data from the request
*/
public function callback($request)
{
$this->extend('onBeforeCallback');
$post_data = $this->request->postVars();
$get_data = $this->request->getVars();
$data = array_merge($post_data, $get_data);
$status = "error";
$order_id = 0;
$payment_id = 0;
// Check if CallBack data exists and install id matches the saved ID
if (isset($data) && array_key_exists('STATUS', $data) && array_key_exists('orderID', $data) && array_key_exists('PAYID', $data)) {
$order_id = $data['orderID'];
$payment_id = $data['PAYID'];
switch ($data['STATUS']) {
case "5":
$status = "paid";
break;
case "1":
case "6":
case "64":
$status = "cancelled";
break;
case "84":
case "93":
$status = "failed";
break;
break;
case "2":
case "52":
$status = "failed";
break;
case "4":
case "9":
case "40":
case "91":
case "50":
case "51":
case "52":
case "59":
case "92":
case "95":
case "99":
$status = "pending";
break;
case "93":
$status = "failed";
break;
}
} else {
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array("OrderID" => $order_id, "PaymentProvider" => "Barclays EPQD", "PaymentID" => $payment_id, "Status" => $status, "GatewayData" => $data));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-checkout-barclaycard-epdq,代码行数:59,代码来源:BarclaycardEpdqHandler.php
示例6: callback
/**
* Process the callback data from the payment provider
*/
public function callback($request)
{
$this->extend("onBeforeCallback");
$data = $this->request->postVars();
$status = "error";
$order_id = 0;
$payment_id = 0;
$gateway_data = array();
if (isset($data) && array_key_exists('cd_supplier_business', $data) && array_key_exists('cd_summary', $data) && array_key_exists('cd_response', $data) && array_key_exists('payment_reference', $data) && array_key_exists('tx_response', $data) && array_key_exists('no_receipt', $data)) {
// Are our credentials correct
if ($data['cd_supplier_business'] != $this->payment_gateway->Username) {
return $this->httpError(500);
}
// Check Payment status
switch ($data['cd_summary']) {
case '0':
$status = "paid";
break;
case '1':
$status = "failed";
break;
case '3':
$status = "failed";
break;
}
$order_id = $data['payment_reference'];
$payment_id = $data['no_receipt'];
$gateway_data = array("ResponseCode" => $data["cd_response"], "ResponseSummary" => $data["cd_summary"], "ResponseDesc" => $data["tx_response"], "RecieptNo" => $data["no_receipt"]);
} else {
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array("OrderID" => $order_id, "PaymentProvider" => "PayWay", "PaymentID" => $payment_id, "Status" => $status, "GatewayData" => $data));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return;
}
示例7: index
/**
* Action that gets called before we interface with our payment
* method.
*
* This action is responsible for setting up an order and
* saving it into the database (as well as a session) and then hands
* the current request over to the relevent payment handler
* for final processing.
*
* @param $request Current request object
*/
public function index($request)
{
$cart = ShoppingCart::get();
$data = array();
$payment_data = array();
$handler = $this->payment_handler;
// If shopping cart doesn't exist, redirect to base
if (!$cart->getItems()->exists() || $this->getPaymentHandler() === null) {
return $this->redirect($cart->Link());
}
// Get billing and delivery details and merge into an array
$billing_data = Session::get("Checkout.BillingDetailsForm.data");
$delivery_data = Session::get("Checkout.DeliveryDetailsForm.data");
// If we have applied free shipping, set that up, else get
if (Session::get('Checkout.PostageID') == -1) {
$postage = Checkout::CreateFreePostageObject();
} else {
$postage = PostageArea::get()->byID(Session::get('Checkout.PostageID'));
}
// If we are using a complex checkout and do not have correct
// details redirect
if (!Checkout::config()->simple_checkout && !$cart->isCollection() && (!$postage || !$billing_data || !$delivery_data)) {
return $this->redirect(Checkout_Controller::create()->Link());
}
if ($cart->isCollection() && !$billing_data) {
return $this->redirect(Checkout_Controller::create()->Link());
}
// Create an order number
$data["OrderNumber"] = substr(chunk_split(Checkout::getRandomNumber(), 4, '-'), 0, -1);
// Setup holder for Payment ID
$data["PaymentID"] = 0;
// Set status
$data['Status'] = 'incomplete';
// Assign billing, delivery and postage data
if (!Checkout::config()->simple_checkout) {
$data = array_merge($data, $billing_data);
$data = is_array($delivery_data) ? array_merge($data, $delivery_data) : $data;
$checkout_data = Checkout::config()->checkout_data;
if (!$cart->isCollection()) {
$data['PostageType'] = $postage->Title;
$data['PostageCost'] = $postage->Cost;
$data['PostageTax'] = $postage->Tax ? $postage->Cost / 100 * $postage->Tax : 0;
}
if ($cart->getDiscount()) {
$data['Discount'] = $cart->getDiscount()->Title;
$data['DiscountAmount'] = $cart->DiscountAmount;
}
// Add full country names if needed
if (in_array("CountryFull", $checkout_data)) {
$data['CountryFull'] = Checkout::country_name_from_code($data["Country"]);
}
if (in_array("DeliveryCountryFull", $checkout_data) && array_key_exists("DeliveryCountry", $data)) {
$data['DeliveryCountryFull'] = Checkout::country_name_from_code($data["DeliveryCountry"]);
}
foreach ($checkout_data as $key) {
if (array_key_exists($key, $data)) {
$payment_data[$key] = $data[$key];
}
}
}
// Set our order data as a generic object
$handler->setOrderData(ArrayData::array_to_object($payment_data));
return $handler->handleRequest($request, $this->model);
}
示例8: convertDataObjectSet
/**
* Generate a JSON representation of the given {@link SS_List}.
*
* @param SS_List $set
* @param array $fields
* @return String XML
*/
public function convertDataObjectSet(SS_List $set, $fields = null)
{
$items = array();
foreach ($set as $do) {
if (!$do->canView()) {
continue;
}
$items[] = $this->convertDataObjectToJSONObject($do, $fields);
}
$serobj = ArrayData::array_to_object(array("totalSize" => is_numeric($this->totalSize) ? $this->totalSize : null, "items" => $items));
return Convert::raw2json($serobj);
}
示例9: callback
/**
* Process the callback data from the payment provider
*/
public function callback($request)
{
$this->extend('onBeforeCallback');
$data = $this->request->postVars();
$status = "error";
$order_id = 0;
$payment_id = 0;
$error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error');
// Check if CallBack data exists and install id matches the saved ID
if (isset($data) && isset($data['custom']) && isset($data['payment_status'])) {
$order_id = $data['custom'];
$paypal_request = 'cmd=_notify-validate';
$final_response = "";
// If the transaction ID is set, keep it
if (array_key_exists("txn_id", $data)) {
$payment_id = $data["txn_id"];
}
$listener = new IpnListener();
if (Director::isDev()) {
$listener->use_sandbox = true;
}
try {
$verified = $listener->processIpn();
} catch (Exception $e) {
error_log("Exception caught: " . $e->getMessage());
return $this->httpError(500);
}
if ($verified) {
// IPN response was "VERIFIED"
switch ($data['payment_status']) {
case 'Canceled_Reversal':
$status = "canceled";
break;
case 'Completed':
$status = "paid";
break;
case 'Denied':
$status = "failed";
break;
case 'Expired':
$status = "failed";
break;
case 'Failed':
$status = "failed";
break;
case 'Pending':
$status = "pending";
break;
case 'Processed':
$status = "pending";
break;
case 'Refunded':
$status = "refunded";
break;
case 'Reversed':
$status = "canceled";
break;
case 'Voided':
$status = "canceled";
break;
}
} else {
error_log("Invalid payment status");
return $this->httpError(500);
}
} else {
error_log("No payment details set");
return $this->httpError(500);
}
$payment_data = ArrayData::array_to_object(array("OrderID" => $order_id, "PaymentProvider" => "PayPal", "PaymentID" => $payment_id, "Status" => $status, "GatewayData" => $data));
$this->setPaymentData($payment_data);
$this->extend('onAfterCallback');
return $this->httpError(200);
}