I am using the php spl package for the Authorize.net SDK. I verified that SimpleXML, cURL, and JSON are all installed on the server and PHP 5.6+ is being used.
I have verified that the SDK is building the $request object $request->setTransactionRequest( $transactionRequestType);
The returned object using print_r
net\authorize\api\contract\v1\CreateTransactionRequest Object ( [transactionRequest:net\authorize\api\contract\v1\CreateTransactionRequest:private] => net\authorize\api\contract\v1\TransactionRequestType Object ( [transactionType:net\authorize\api\contract\v1\TransactionRequestType:private] => authCaptureTransaction [amount:net\authorize\api\contract\v1\TransactionRequestType:private] => 151.51 [currencyCode:net\authorize\api\contract\v1\TransactionRequestType:private] => [payment:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\PaymentType Object ( [creditCard:net\authorize\api\contract\v1\PaymentType:private] => net\authorize\api\contract\v1\CreditCardType Object ( [cardCode:net\authorize\api\contract\v1\CreditCardType:private] => [isPaymentToken:net\authorize\api\contract\v1\CreditCardType:private] => [cryptogram:net\authorize\api\contract\v1\CreditCardType:private] => [cardNumber:net\authorize\api\contract\v1\CreditCardSimpleType:private] => 4111111111111111 [expirationDate:net\authorize\api\contract\v1\CreditCardSimpleType:private] => 2038-12 ) [bankAccount:net\authorize\api\contract\v1\PaymentType:private] => [trackData:net\authorize\api\contract\v1\PaymentType:private] => [encryptedTrackData:net\authorize\api\contract\v1\PaymentType:private] => [payPal:net\authorize\api\contract\v1\PaymentType:private] => [opaqueData:net\authorize\api\contract\v1\PaymentType:private] => ) [profile:net\authorize\api\contract\v1\TransactionRequestType:private] => [solution:net\authorize\api\contract\v1\TransactionRequestType:private] => [callId:net\authorize\api\contract\v1\TransactionRequestType:private] => [authCode:net\authorize\api\contract\v1\TransactionRequestType:private] => [refTransId:net\authorize\api\contract\v1\TransactionRequestType:private] => [splitTenderId:net\authorize\api\contract\v1\TransactionRequestType:private] => [order:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\OrderType Object ( [invoiceNumber:net\authorize\api\contract\v1\OrderType:private] => 101 [description:net\authorize\api\contract\v1\OrderType:private] => Golf Shirts ) [lineItems:net\authorize\api\contract\v1\TransactionRequestType:private] => Array ( [0] => net\authorize\api\contract\v1\LineItemType Object ( [itemId:net\authorize\api\contract\v1\LineItemType:private] => Shirts [name:net\authorize\api\contract\v1\LineItemType:private] => item1 [description:net\authorize\api\contract\v1\LineItemType:private] => golf shirt [quantity:net\authorize\api\contract\v1\LineItemType:private] => 1 [unitPrice:net\authorize\api\contract\v1\LineItemType:private] => 20.95 [taxable:net\authorize\api\contract\v1\LineItemType:private] => ) ) [tax:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\ExtendedAmountType Object ( [amount:net\authorize\api\contract\v1\ExtendedAmountType:private] => 4.5 [name:net\authorize\api\contract\v1\ExtendedAmountType:private] => level 2 tax name [description:net\authorize\api\contract\v1\ExtendedAmountType:private] => level 2 tax ) [duty:net\authorize\api\contract\v1\TransactionRequestType:private] => [shipping:net\authorize\api\contract\v1\TransactionRequestType:private] => [taxExempt:net\authorize\api\contract\v1\TransactionRequestType:private] => [poNumber:net\authorize\api\contract\v1\TransactionRequestType:private] => 15 [customer:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\CustomerDataType Object ( [type:net\authorize\api\contract\v1\CustomerDataType:private] => [id:net\authorize\api\contract\v1\CustomerDataType:private] => 15 [email:net\authorize\api\contract\v1\CustomerDataType:private] => foo#example.com [driversLicense:net\authorize\api\contract\v1\CustomerDataType:private] => [taxId:net\authorize\api\contract\v1\CustomerDataType:private] => ) [billTo:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\CustomerAddressType Object ( [phoneNumber:net\authorize\api\contract\v1\CustomerAddressType:private] => [faxNumber:net\authorize\api\contract\v1\CustomerAddressType:private] => [email:net\authorize\api\contract\v1\CustomerAddressType:private] => [firstName:net\authorize\api\contract\v1\NameAndAddressType:private] => Ellen [lastName:net\authorize\api\contract\v1\NameAndAddressType:private] => Johnson [company:net\authorize\api\contract\v1\NameAndAddressType:private] => Souveniropolis [address:net\authorize\api\contract\v1\NameAndAddressType:private] => 14 Main Street [city:net\authorize\api\contract\v1\NameAndAddressType:private] => Pecan Springs [state:net\authorize\api\contract\v1\NameAndAddressType:private] => TX [zip:net\authorize\api\contract\v1\NameAndAddressType:private] => 44628 [country:net\authorize\api\contract\v1\NameAndAddressType:private] => USA ) [shipTo:net\authorize\api\contract\v1\TransactionRequestType:private] => net\authorize\api\contract\v1\NameAndAddressType Object ( [firstName:net\authorize\api\contract\v1\NameAndAddressType:private] => Bayles [lastName:net\authorize\api\contract\v1\NameAndAddressType:private] => China [company:net\authorize\api\contract\v1\NameAndAddressType:private] => Thyme for Tea [address:net\authorize\api\contract\v1\NameAndAddressType:private] => 12 Main Street [city:net\authorize\api\contract\v1\NameAndAddressType:private] => Pecan Springs [state:net\authorize\api\contract\v1\NameAndAddressType:private] => TX [zip:net\authorize\api\contract\v1\NameAndAddressType:private] => 44628 [country:net\authorize\api\contract\v1\NameAndAddressType:private] => USA ) [customerIP:net\authorize\api\contract\v1\TransactionRequestType:private] => [cardholderAuthentication:net\authorize\api\contract\v1\TransactionRequestType:private] => [retail:net\authorize\api\contract\v1\TransactionRequestType:private] => [employeeId:net\authorize\api\contract\v1\TransactionRequestType:private] => [transactionSettings:net\authorize\api\contract\v1\TransactionRequestType:private] => [userFields:net\authorize\api\contract\v1\TransactionRequestType:private] => ) [merchantAuthentication:net\authorize\api\contract\v1\ANetApiRequestType:private] => net\authorize\api\contract\v1\MerchantAuthenticationType Object ( [name:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => *******[transactionKey:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => ***********[sessionToken:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => [password:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => [impersonationAuthentication:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => [fingerPrint:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => [mobileDeviceId:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => ) [refId:net\authorize\api\contract\v1\ANetApiRequestType:private] => ref1453823618 )
The error seems to happen at:
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
Commenting either out one at a time causes the 500 error, if both removed it finishes the script.
The full script:
<?php
require '../../autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("*********");
$merchantAuthentication->setTransactionKey("******************");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber( "4111111111111111" );
$creditCard->setExpirationDate( "2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Order info
$order = new AnetAPI\OrderType();
$order->setInvoiceNumber("101");
$order->setDescription("Golf Shirts");
// Line Item Info
$lineitem = new AnetAPI\LineItemType();
$lineitem->setItemId("Shirts");
$lineitem->setName("item1");
$lineitem->setDescription("golf shirt");
$lineitem->setQuantity("1");
$lineitem->setUnitPrice(20.95);
$lineitem->setTaxable(false);
// Tax info
$tax = new AnetAPI\ExtendedAmountType();
$tax->setName("level 2 tax name");
$tax->setAmount(4.50);
$tax->setDescription("level 2 tax");
// Customer info
$customer = new AnetAPI\CustomerDataType();
$customer->setId("15");
$customer->setEmail("foo#example.com");
// PO Number
$ponumber = "15";
//Ship To Info
$shipto = new AnetAPI\NameAndAddressType();
$shipto->setFirstName("Bayles");
$shipto->setLastName("China");
$shipto->setCompany("Thyme for Tea");
$shipto->setAddress("12 Main Street");
$shipto->setCity("Pecan Springs");
$shipto->setState("TX");
$shipto->setZip("44628");
$shipto->setCountry("USA");
// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName("Ellen");
$billto->setLastName("Johnson");
$billto->setCompany("Souveniropolis");
$billto->setAddress("14 Main Street");
$billto->setCity("Pecan Springs");
$billto->setState("TX");
$billto->setZip("44628");
$billto->setCountry("USA");
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
$transactionRequestType->setAmount(151.51);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setOrder($order);
$transactionRequestType->addToLineItems($lineitem);
$transactionRequestType->setTax($tax);
$transactionRequestType->setPoNumber($ponumber);
$transactionRequestType->setCustomer($customer);
$transactionRequestType->setBillTo($billto);
$transactionRequestType->setShipTo($shipto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId);
$request->setTransactionRequest( $transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null)
{
$tresponse = $response->getTransactionResponse();
if (($tresponse != null) && ($tresponse->getResponseCode()=="1") )
{
echo "Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "\n";
echo "Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "\n";
}
else
{
echo "Charge Credit Card ERROR : Invalid response\n";
}
}
else
{
echo "Charge Credit card Null response returned";
}
?>
Thank you for any help or advice on establishing the connection properly
Related
I have an array in Sublime Text with every city in the U.S as the value and a code which includes the state abbreviation as the key. It looks a little something like this:
$array = array(
"United States of America" => array(
"USAK0001" => "Adak",
"USAK0002" => "Adak Island",
"USAK0003" => "Akiachak",
"USAK0004" => "Akiak",
"USAK0005" => "Akutan",
"USAK0006" => "Alakanuk",
"USAK0007" => "Aleknagik",
"USAK0008" => "Allakaket",
"USAL0028" => "Arlington",
"USAL0029" => "Ashford",
"USAL0030" => "Ashland",
"USAL0031" => "Ashville",
"USAL0032" => "Athens",
"USAL0033" => "Atmore",
"USAL0034" => "Attalla",
"USAL0035" => "Auburn",
"USAL0036" => "Auburn University",
"USAL0037" => "Autaugaville",
"USAL0038" => "Axis",
"USAL0039" => "Baileyton",
)
);
What I need to do is a search and replace to append the state name to the value, based on finding the two letter state abbreviation in the array key code.
So for example, a search that finds "AK" in the key and adds "Alaska" to the value, so they would look like this:
"USAK0001" => "Alaska, Adak",
"USAK0002" => "Alaska, Adak Island",
"USAK0003" => "Alaska, Akiachak",
"USAK0004" => "Alaska, Akiak",
"USAK0005" => "Alaska, Akutan",
"USAK0006" => "Alaska, Alakanuk",
Every key is 8 characters long, but I really don't even know how to begin trying to do this in Sublime Text.
Thanks to nhahtdh, I did this quite easily with a PHP script to merge it. It ended up being as simple as the below, with no need for regex! (Huzzah!)
function merge_states_into_cities( $states, $cities ) {
foreach ( $cities as $key => $array ) {
foreach ( $array as $code => $city ) {
foreach ( $states as $abbrv => $state ) {
if ( strpos( $code, $abbrv, 2 ) ) {
echo '"' . $code . '" => "' . $state . ', ' . $city . '",<br>';
}
}
}
}
}
I am using Doctrine 2 ORM, Zendframework 2
Entity attribute in Role Entity look like this
/**
*
* #ORM\Column(type="string")
*/
protected $name;
/**
*
* #ORM\OneToMany(targetEntity="\Application\Entity\Role", mappedBy="parent")
*/
protected $children;
/**
*
* #ORM\ManyToOne(targetEntity="\Application\Entity\Role", inversedBy="children")
*
*/
protected $parent;
Mysql Table look like this.
Result I am looking for is an array.
One thing is critical, Any entry in array before apprearing in value must be added as key,
So order is very important.
i.e [site-manager] => guest can't come as first entry(0 index) if [guest] => will not exist before it becaause guest(value) does not exist in array as key
so [guest] => will come first even if it is entered as second record in table
Array(
[guest] =>
[site-manager] => guest
[company-manager] => site-manager
[member] => guest
[staff] => member
[internalstaff] => member
[sales] => staff
[manager] => sales,internalstaff
[admin] => manager
)
I am running this code in my controller which is returning empty array
$qb = $objectManager->createQueryBuilder();
$qb->select('r, p')
->from('\Application\Entity\Role', 'r')
->innerJoin('r.parent','p', 'with','p.id = r.id')
//->where('b.id = ?1')
->orderBy('r.id', 'ASC');
$data = $qb->getQuery()->getArrayResult();
Any help will be appreciated
One solution could be
$qb = $objectManager->createQueryBuilder();
$qb->select('r.name', 'c.name as children')
->from('\Application\Entity\Role', 'r')
->join('r.parent','c');
$data = $qb->getQuery()->getArrayResult();
$refine = array();
foreach ($data as $v)
{
if(is_array($v))
{
if(array_key_exists($v["children"], $refine)){
$refine[$v["name"]][] = $v["children"];
} else {
$refine[$v["children"]] = array();
$refine[$v["name"]][] = $v["children"];
}
}
}
print_r($refine);
Will return following
Array
(
[guest] => Array
(
)
[site-manager] => Array
(
[0] => guest
)
[company-manager] => Array
(
[0] => site-manager
)
[member] => Array
(
[0] => guest
)
[staff] => Array
(
[0] => member
)
[internalStaff] => Array
(
[0] => member
)
[sales] => Array
(
[0] => staff
)
[manager] => Array
(
[0] => internalStaff
[1] => sales
)
[admin] => Array
(
[0] => manager
)
)
You can use implode function if you wish to flatten inner array
I am getting this type of error:
=> i am getting error in the integration of the netsuite.
In sales order add the items in the netsuite so there are some error is define in above section my code is below please see the code add how to solve this problem.
[code] => USER_ERROR
[message] => You must enter at least one line item for this transaction.
[type] => ERRORi am gatting this type of error please help me
[code] => USER_ERROR
[message] => You must enter at least one line item for this transaction.
[type] => ERROR
my code is
include('NetSuiteService.php');
$service = new NetSuiteService();
if($order_items->netsuitid > 0){
$internal_Id = $order_items->netsuitid;
$emailCustomer = $order_items->user_email;
}
else{
$customer_Info = $order->get_customer_info($order->user_id);
$customer_information = array();
foreach($customer_Info as $customer_key => $customer_value){
if($customer_value->meta_key == 'first_name'){
$customer_information['first_name'] = $customer_value->meta_value;
}
if($customer_value->meta_key == 'last_name'){
$customer_information['last_name'] = $customer_value->meta_value;
}
}
$customer_information['email'] = $customer_Info->user_email;
//Add customer into net suit integration
$service = new NetSuiteService();
$customer = new Customer();
$customer->lastName = $customer_information['last_name'];
$customer->firstName = $customer_information['first_name'];
$customer->companyName = 'Company Name';
$customer->phone = '2222222222';
$customer->email = $customer_information['email'];
$emailCustomer = $customer_information['email'];
$request = new AddRequest();
$request->record = $customer;
$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
echo "You are already Registered with Netsuit.";
}
else {
$internal_Id = $addResponse->writeResponse->baseRef->internalId;
$order->insert_Customer($internal_Id,$order->user_id);
}
//End customer into net suit integration
}
//Add Product Information
/*$items = array();
foreach ( $order_items as $item_id => $item ) {
$itemRef = new nsRecordRef(array('internalId'=>$internal_Id));
$qty = $item['qty'];
if($item['type'] == 'line_item'){
$salesOrderItemFieldArray = array(
"item" => $itemRef,
"quantity" => $qty
);
}
if($item['type'] == 'fee'){
$salesOrderItemFieldArray = array(
"item" => $itemRef,
"quantity" => $qty
);
}
$SalesOrderItem->setFields($salesOrderItemFieldArray);
$items[] = $SalesOrderItem;
}
$salesOrderItemList = new nsComplexObject("SalesOrderItemList");
$salesOrderItemList->setFields(array(
"item" => $items
));
$salesOrderFields = array(
"orderStatus" => $order->status,
"entity" => '',
"getAuth" => true,
"shippingCost" => $order->order_shipping,
"shipMethod" => $order->payment_method,
"toBeEmailed" => true,
"email" => $emailCustomer,
"itemList" => $salesOrderItemList
);*/
$so = new SalesOrder();
//created Date
//$so->createdDate = $order->order_date;
//entity
$so->entity = new RecordRef();
$so->entity->internalId = $internal_Id;
$so->entity->name = $order->order_custom_fields['_billing_company'][0];
//Transaction Id
//$so->tranId = $order->order_custom_fields['Transaction ID'][0];
//Transaction Paid Date
//$so->tranDate = $order->order_custom_fields['_paid_date'][0];
//Source
$so->source = 'littlecrate';
//Created From
$so->createdFrom = 'littlecrate.com';
//Currency Name
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->currency = $order->order_custom_fields['_order_currency'];
$so->currencyName = $geoplugin->countryName;
$so->currency = $order->order_custom_fields['_order_currency'][0];
//Discount
$so->discountRate = $order->order_custom_fields['_order_discount'][0];
//Tax
$so->taxRate = $order->order_custom_fields['_order_tax'][0];
//email
$so->email = $order->billing_email;
//Status
//$so->orderStatus = $order->status;
//Billing Address
$so->billAddressList = array(
'billFirstname' => $order->order_custom_fields['_billing_first_name'][0],
'lastname' => $order->order_custom_fields['_billing_last_name'][0],
'billAddressee' => $order->order_custom_fields['_billing_address_1'][0],
'billAddr1' => $order->order_custom_fields['_billing_address_2'][0],
'billCountry' => $order->order_custom_fields['_billing_country'][0],
'billState' => $order->order_custom_fields['_billing_state'][0],
'billZip' => $order->order_custom_fields['_billing_postcode'][0],
'billPhone' => $order->order_custom_fields['_billing_phone'][0],
'billEmail' => $order->order_custom_fields['_billing_email'][0]);
//Shipping Address
$so->shipAddressList = array(
'shipFirstname' => $order->order_custom_fields['_shipping_first_name'][0],
'shipLastname' => $order->order_custom_fields['_shipping_last_name'][0],
'shipAddressee' => $order->order_custom_fields['_shipping_address_1'][0],
'shipAddr1' => $order->order_custom_fields['_shipping_address_2'][0],
'shipCity' => $order->order_custom_fields['_shipping_city'][0],
'shipState' => $order->order_custom_fields['_shipping_state'][0],
'shipZip' => $order->order_custom_fields['_shipping_postcode'][0],
'shiplPhone' => $order->order_custom_fields['_billing_phone'][0],
'shipEmail' => $order->order_custom_fields['_billing_email'][0]);
//Ship Date
//$so->shipDate = $order->order_custom_fields['Transaction ID'][0];
//Shipping Method
$so->shipMethod = $order->shipping_method;
//Shipping Charges
$so->shippingCost = $order->order_shipping;
//Shipping Tax Rate
$so->shippingTax1Rate = $order->order_shipping_tax;
//Payment Method
$so->paymentMethod = $order->payment_method;
//Sub Total
//$so->subTotal = $order->order_total;
//Discount Total(Cart Total)
//$so->discountTotal = $order->cart_discount;
//Tax Total
//$so->taxTotal = $order->order_tax;
//Total
//$so->total = $order->order_total;
//Product Listing
$arrItemsList = array();
$i = 0;
foreach($order_items_product as $keyProduct =>$valueProduct){
if($valueProduct['type'] == 'line_item'){
//$arrItemsList[$i]['item']['internalId'] = $valueProduct['product_id'];
//$arrItemsList[$i]['item']['externalId'] = $keyProduct;
$arrItemsList[$i]['item']['name'] = $valueProduct['name'];
$arrItemsList[$i]['item']['quantity'] = $valueProduct['qty'];
$arrItemsList[$i]['item']['description'] = $valueProduct['type'];
$arrItemsList[$i]['item']['amount'] = $valueProduct['line_total'];
}
if($valueProduct['type'] == 'fee'){
//$arrItemsList[$i]['item']['internalId'] = $valueProduct['product_id'];
//$arrItemsList[$i]['item']['externalId'] = $keyProduct;
$arrItemsList[$i]['item']['name'] = $valueProduct['name'];
$arrItemsList[$i]['item']['quantity'] = $valueProduct['qty'];
$arrItemsList[$i]['item']['description'] = $valueProduct['type'];
$arrItemsList[$i]['item']['amount'] = $valueProduct['line_total'];
}
$i++;
}
//print_r($arrItemsList);
$so->itemList->item = $arrItemsList;
/*$so->itemList = new SalesOrderItemList();
$soi = new SalesOrderItem();
$soi->item = new RecordRef();
$soi->item->internalId = 15;
$soi->quantity = 3;
$soi->price = new RecordRef();
$soi->price->internalId = $id;
$soi->amount = 55.3;
$so->itemList->item = array($soi);*/
$request = new AddRequest();
$request->record = $so;
//print_r($request);
$addResponse = $service->add($request);
print_r($addResponse);
exit;
if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
+
I Complited Using The Help Of Saqib,
http://stackoverflow.com/users/810555/saqib
He is The Great Developer And Regarding Netsuite Information Please Contact To Saqib Thanks Man U Just Do It.
<?php
$order_date = date('Y-m-d H:i:s');
// create array of fields
$itemArr = array();
$i = 0;
foreach($order_items_product as $keyProduct =>$valueProduct){
//if you not have internal id of item in netsuuite then please add the item in the netsuite and try.
$netsuiteItemId = 'Your Item Internal id Which is in the Netsuite Item';
$itemArr[$i]['item']['internalId'] = $netsuiteItemId;
$itemArr[$i]['quantity'] = $valueProduct['qty'];
$i++;
}
if (!define('LF', "\n")) {
define('LF', "\n");
}
/* for use in formatting custom addresses since NetSuite converts to <br> */
//Billing Address Information
/* this example has the customer address info in a db record, just pulled into $row */
$billAddress = stripslashes($order->order_custom_fields['_billing_first_name'][0]) . ' ' . $order->order_custom_fields['_billing_last_name'][0] . LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_1'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_2'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_country'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_state'][0]) . ' - ' . $order->order_custom_fields['_billing_postcode'][0] . ', ' . LF;
$billAddress .= $order->order_custom_fields['_billing_phone'][0] . ', ' . $order->order_custom_fields['_billing_email'][0];
//Shipping Address Information
$shipAddress = stripslashes($order->order_custom_fields['_shipping_first_name'][0]) . ' ' . $order->order_custom_fields['_shipping_last_name'][0] . LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_1'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_2'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_city'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_state'][0]) . ', ' . $order->order_custom_fields['_shipping_postcode'][0] . ', ' . LF;
$shipAddress .= $order->order_custom_fields['_billing_phone'][0] .', '. $order->order_custom_fields['_billing_email'][0];
$purchaseOrderFields = array (
'entity' => array ('internalId' => $internal_Id, 'type' => 'customer'),
'shippingCost' => $order->order_shipping,
'shipMethod' => $order->payment_method,
'toBeEmailed' => true,
//'tranId' => $order->order_custom_fields['Transaction ID'][0],
//'tranDate' => date('Y-m-d H:i:s'),
'source' => 'littlecrate',
'createdFrom' => 'littlecrate.com',
'discountRate' => $order->order_custom_fields['_order_discount'][0],
'taxRate' => $order->order_custom_fields['_order_tax'][0],
'email' => $order->billing_email,
//'shipDate' => date('Y-m-d H:i:s'),
'shipMethod' => $order->shipping_method,
'shippingCost' => $order->order_shipping,
'shippingTax1Rate' => $order->order_shipping_tax,
'paymentMethod' => $order->payment_method,
//'taxTotal' => $order->order_tax,
//'total' => $order->order_total,
'billAddress' => $billAddress,
'shipAddress' => $shipAddress,
'itemList' => array (
'item' => $itemArr
)
);
$salesOrder = new nsComplexObject('SalesOrder');
$salesOrder ->setFields($purchaseOrderFields);
$addResponse = $myNSclient->add($salesOrder );
if (!$addResponse->isSuccess) {
echo "Order Information is Not Inserted Into The Netsuite. Please Contact to Administration.";
exit;
}
?>
You item List object doesn't seem in correct format. Your code should look like this
$itemArr = array();
foreach($order_items_product as $keyProduct =>$valueProduct){
$item = new SalesOrderItem();
$item->item = $valueProduct['product_id'];
$item->quantity = $valueProduct['qty'];
$itemArr[] = $item;
}
$itemList = new SalesOrderItemList();
$itemList->item = $itemArr;
$so->itemList->item = $itemList;
I'm trying the AWS Product Advertisement API in PhP.
Here is the PhP code that I've copied from net.
function callSOAPFunction($function, $array){
$timeStamp = gmdate("Y-m-d\TH:i:s\Z");
//service is always the same, $function is operation
$string = 'AWSECommerceService'.$function.$timeStamp;
$signature = base64_encode(hash_hmac("sha256", $string, 'MySecretKey', True));
$params = array('Service' => 'AWSECommerceService',
'AssociateTag' => 'Wassup?',
**'Signature' => $signature,**
'AWSAccessKeyId' => 'MyKey'
'Request' => array($array),
'Timestamp' => $timeStamp
);
$client = new
SoapClient("http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl",
array('exceptions' => 0));
return $client->__soapCall($function, array($params));
}
$array = array('Operation' => 'ItemSearchRequest',
'ItemPage' => 3,
'SearchIndex' => 'DVD',
'ResponseGroup' => 'Large',
'Keywords' => 'Karate');
$result = callSOAPFunction("ItemSearch", $array);
Although I'm including the signature parameter, I'm still getting the error.
I'm running an application that calls both the graph and fql.query for Insights information. (It happens to impersonate dozens of apps and pulls stats) I get a couple different formats back when querying and I'm wondering if there's a better way to 'normalize' results?
It would be nice to have something like this in the SDK, since Facebook formats/ data changes all the time. Where do I make an SDK request?
Code to get key-value---
[code]
public function saveResults($application = null, $result = array())
{
// graph insights are under a data key
if(isset($result['data'])) {
$this->saveResults($application, $result['data']);
}
// graph insights are under a values array
elseif(isset($result['values'])) {
foreach($result['values'] as $k => $v) {
$this->saveResult($application, $result['name'], $v['value'], $result['period'], $v['end_time']);
}
}
// fql.query results have a metric and value
elseif(isset($result['metric'])) {
$this->saveResult($application, $result['metric'], $result['value'], $result['period'], $result['end_time']);
}
// otherwise save key values
elseif(is_array($result)) {
foreach($result as $key => $val) {
if(is_numeric($key) && is_array($val)) {
$this->saveResults($application, $val);
}
else {
$this->saveResult($application, $key, $val);
}
}
}
}
[/code]
Results from fql --
=> Array
(
[0] => Array
(
[app_id] => 1248...
[api_key] => 1248...
[canvas_name] => ABC123
[display_name] => ABC123
[company_name] =>
[developers] => Array
(
)
[restriction_info] => Array
(
)
[daily_active_users] => 0
[weekly_active_users] => 0
[monthly_active_users] => 8
)
)
=> Array
(
[0] => Array
(
[metric] => application_canvas_views
[value] => 0
[period] => 86400
[end_time] => 1317538800
)
)
Results from graph --
=> Array
(
[id] => 1248...
[name] => ABC123
[picture] => https://fbcdn-profile...
[link] => http://www.facebook.com/ABC123
[likes] => 58450
[category] => Product/service
[website] => http://www.ABC123..
=> Array
(
[data] => Array
(
[0] => Array
(
[id] => ABC123.../insights/page_like_adds/day
[name] => page_like_adds
[period] => day
[values] => Array
(
[0] => Array
(
[value] => 60
[end_time] => 2011-01-01T08:00:00+0000
)
[1] => Array
(
[value] => 15
[end_time] => 2011-01-02T08:00:00+0000
)
[2] => Array
(
[value] => 2
From my experience there's no 1:1 correlation between "object properties" being returned from the FQL tables to that of the new graph API objects. There's so many more properties on the FQL tables than there are in the graph from what I've seen. Trying to get them tied together would be like giving a cat a bath. It can be done, but it's going to be painful!!
My suggestions would be to determine from the project requirements what you're trying to accomplish and then determine whether FQL or Graph API is your best route to getting to each requirement. One requirement might be easier done with the graph, and another using FQL. Good luck.