I am trying to CALL WSDL FROM php
http://validator2.addressdoctor.com/addBatch/Batch.asmx?wsdl
define('ADDRESSDOCTOR_WSDL_URL','http://validator2.addressdoctor.com/addBatch/Batch.asmx?wsdl');
define('ADDRESSDOCTOR_USER_LOGIN','myaccount');
define('ADDRESSDOCTOR_USER_PASSWORD','password');
$useinfo = array(
"CustomerID"=>ADDRESSDOCTOR_USER_LOGIN,
"DepartmentID"=>0,
"Password"=>ADDRESSDOCTOR_USER_PASSWORD
);
$addressinfo = array(
"Street"=>"main st",
"Locality"=>"wayne",
"PostalCode"=>"07035",
"Province"=>"NJ",
"Country"=>"USA");
$addressinfo1 = array(
"Street"=>"100 newark tpk",
"Locality"=>"wayne",
"PostalCode"=>"07470",
"Province"=>"NJ",
"Country"=>"USA");
$array_of_add = array("Address"=>$addressinfo,"Address"=>$addressinfo1);
$client = new SoapClient(ADDRESSDOCTOR_WSDL_UR);
$function = $client->Validate(array("addBatchRequest"=>array("Authentication"=>$useinfo,"Parameters"=>$paramenters,**"AddressCount"=>2**,"Addresses"=>$array_of_add)));
$result = $function->ValidateResult;
print_r($result);
It give me error
does not match number of supplied addresses.
If I write
$function = $client->Validate(array("addBatchRequest"=>array("Authentication"=>$useinfo,"Parameters"=>$paramenters,"AddressCount"=>1,"Addresses"=>$array_of_add)));
"AddressCount"=>2 is changed to "AddressCount"=>1
It works and outputs single result for "Address"=>$addressinfo1 even though i have passed two addresses Address"=>$addressinfo,"Address"=>$addressinfo1. I can pass upto 10 count in each batch request. But I am not able to get it. Can please some one help me what I am doing wrong.
I figured it out. I had to put
$array_of_add = array($addressinfo,$addressinfo1);
instead of
$array_of_add = array("Address"=>$addressinfo,"Address"=>$addressinfo1);
Related
There is a problem over which I am puzzling for the second day.
$purchaseOrders = new PurchaseOrder();
$lists = new ItemLists();
$lists->productid->set(201);
$lists->hdnGrandTotal->set($balance);
$lists->hdnSubTotal->set($balance);
$lists->quantity->set(1);
$lists->listprice->set($balance);
$arrayDataLineItems = [];
$arrayDataLineItems[] = $lists;
$purchaseOrders->dataLineItems->set($arrayDataLineItems);
$purchaseOrders->subject->set($data['caseId']);
$purchaseOrders->purchaseorderNo->set('PO');
$purchaseOrders->vendorid->set($getVendor->id->getCrmValue());
$purchaseOrders->postatus->set('Created');
$purchaseOrders->bill_street->set($getVendor->street->getCrmValue());
$purchaseOrders->ship_street->set($getVendor->street->getCrmValue());
$purchaseOrders->productid->set(201);
$purchaseOrders->balance->set($balance);
$purchaseOrders->assignedUserId->set(6);
$purchaseOrders->conversion_rate->set(1);
$purchaseOrders->currency_id->set('21x1');
$purchaseOrders->hdnTaxType->set('group');
$purchaseOrders->terms_conditions->set('SEE FULL TERMS OF SERVICE AT https://www.salvagedata.com/about/service-terms/');
$valueMapPurchase = $purchaseOrders->toCrmMap();
$crmPurchase = $api->doCreate(PurchaseOrder::getModuleName(),$valueMapPurchase);
There is such a code. It does not add a PurchaseOrder and does not even return any errors. When I do an error check, it returns just Null. Please help, nothing in my head does not climb as it could be corrected.
Now i have database mysql 5.6
Try something like this:
$po = Vtiger_Record_Model::getCleanInstance('PurchaseOrder');
$po->set('subject', 'my po');
$po->set('assigned_user_id', 1);
//set other variables as needed...
$po->save();
The output I am trying to receive is
"The Interest Rates are:
0.0525
0.0550
0.0575"
This will continue to $InterestRate7 value. I tried to link the new array elements with the old interest rate ($InterestRate1 = 0.0525; $RatesArray[1] = $InterestRate1) but it still does not work for me.Here is my code for extra help.
<?php
$InterestRate1 = 0.0525;
$InterestRate2 = 0.0550;
$InterestRate3 = 0.0575;
$InterestRate4 = 0.0600;
$InterestRate5 = 0.0625;
$InterestRate6 = 0.0650;
$InterestRate7 = 0.0700;
$RatesArray = array(
$RatesArray[1] = "0.0525";
$RatesArray[2] = "0.0550";
$RatesArray[3] = "0.0575";
$RatesArray[4] = "0.0600";
$RatesArray[5] = "0.0625";
$RatesArray[6] = "0.0650";
$RatesArray[7] = "0.0700";);
echo $RatesArray[1];
?>
The array() construct doesn't work quite like what you have here. Try something similar to the example in the php documentation http://php.net/manual/en/language.types.array.php
$RatesArray = array(
1 => "0.0525",
2 => "0.0550",
3 => "0.0575");
I am creating customers for NetSuite from my application by using the NetSuite PHP SDK, version 2013_2.
This mostly works, but I can not set a status for new Customers. No matter what, the status will always be CUSTOMER-Won Customer, which I don't want. I can't find any documentation about this, so I basically tried whatever seemed to make sense and tried to understand the code of the SDK. Here are some of the things I tried:
$customer->entityStatus = 17;
$customer->entityStatus = new \RecordRef(array('internalId' => 17, 'type' => 'customer'));
$customer->entityStatus = new \RecordRef();
$customer->entityStatus->internalId = 17;
All of these are simply ignored. I tried different internal IDs (and of course, I made sure all of them exist in the system). I tried using strings ('17' instead of 17), but nothing helped.
Documentation has nothing about this either.
Here's my full working code:
$ns = new \NS_NetSuiteService();
$customer = new \Customer();
$customer->companyName = $company->getName();
$customer->entityStatus = 17;
$customer->email = $user->getEmail();
$request = new \AddRequest();
$request->record = $customer;
$res = $ns->add($request);
I always create the RecordRef first, then set the field. Seems to keep things in order for me:
$entityStatus = new RecordRef();
$entityStatus->internalId = 17;
$entityStatus->recordType = "customerStatus";
$customer->entityStatus = $entityStatus;
Or, take my example and shorten the code once you see it working this way.
I'm in the process of writing some code that will submit an order to Paypal Express Checkout. Unforunately I can't seem to get the whole address thing to work, and I also can't seem to find much info on it in the API docs. Here's my code so far.
$config = array (
'mode' => 'sandbox' ,
'acct1.UserName' => '****removed*****',
'acct1.Password' => '******removed*******',
'acct1.Signature' => '*********removed***********'
);
$paypalService = new PayPal\Service\PayPalAPIInterfaceServiceService($config);
$paymentDetails= new PayPal\EBLBaseComponents\PaymentDetailsType();
// Dummy shipping address
// Obviously, in the final version, this would be passed in from a form
$shipping_address = new PayPal\EBLBaseComponents\AddressType();
$shipping_address->Name = "John Smith";
$shipping_address->Street1 = "123 Market Street";
$shipping_address->Street2 = "";
$shipping_address->CityName = "Columbus";
$shipping_address->StateOrProvince = "OH";
$shipping_address->PostalCode = "43017";
$shipping_address->Country = "US";
// A dummy item
// Once again, in a final version this would be passed in
$itemDetails = new PayPal\EBLBaseComponents\PaymentDetailsItemType();
$itemDetails->Name = 'Electro Lettuce Feeders';
$itemAmount = 1250.00;
$itemDetails->Amount = $itemAmount;
$itemQuantity = 1;
$itemDetails->Quantity = $itemQuantity;
// Add all items to the list
$paymentDetails->PaymentDetailsItem[0] = $itemDetails;
// The company is in NYS, so in the final version the
// sales tax rate will be passed in (NYS is destination-based)
$sales_tax_rate = 0.07;
// Order sub-total
$itemTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$itemTotal->currencyID = 'USD';
$itemTotal->value = ($itemAmount * $itemQuantity);
// Shipping total
$shippingTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$shippingTotal->currencyID = 'USD';
$shippingTotal->value = 2.00;
// Tax total
$taxTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$taxTotal->currencyID = 'USD';
$taxTotal->value = $itemTotal->value * $sales_tax_rate;
// Order total
$orderTotal = new PayPal\CoreComponentTypes\BasicAmountType();
$orderTotal->currencyID = 'USD';
$orderTotal->value = $itemTotal->value + $taxTotal->value + $shippingTotal->value;
$paymentDetails->TaxTotal = $taxTotal;
$paymentDetails->ItemTotal = $itemTotal;
$paymentDetails->ShippingTotal = $shippingTotal;
$paymentDetails->OrderTotal = $orderTotal;
$paymentDetails->PaymentAction = 'Sale';
// ***** Is the address from this object passed to Paypal?
$paymentDetails->ShipToAddress = $shipping_address;
$setECReqDetails = new PayPal\EBLBaseComponents\SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $paymentDetails;
$setECReqDetails->CancelURL = 'https://devtools-paypal.com/guide/expresscheckout/php?cancel=true';
$setECReqDetails->ReturnURL = 'https://devtools-paypal.com/guide/expresscheckout/php?success=true';
// ***** Or is this the address that will be passed to Paypal?
$setECReqDetails->Address = $shipping_address;
// ***** And can you choose to not pass in the billing address? Or is it required? *****
$setECReqDetails->BillingAddress = $shipping_address;
// ***** If this is set to 0, will the previously provided shipping address be shown
// ***** at all? Or will it just be "modify-able" unless you set this to 1?
$setECReqDetails->AddressOverride = 1;
$setECReqType = new PayPal\PayPalAPI\SetExpressCheckoutRequestType();
$setECReqType->Version = '104.0';
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReq = new PayPal\PayPalAPI\SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
//var_dump($setECResponse);
$redirect_url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=".$setECResponse->Token;
return $app->redirect($redirect_url);
Summed up...
You'll see my questions distributed throughout the code, but here they are all summed up.
Both PaymentDetailsType() and SetExpressCheckoutRequestType() have address-ish properties. Which one will be passed on to Paypal?
Does the API require that you pass in a billing address if you pass in a shipping address?
If you don't set AddressOverride to 1, should it show the address that you passed in at all?
But in the end, I most importantly just want to know how to get address passing to work. =). Right now I can't seem to get any address to pass to Paypal no matter what I try.
It would help more to see the raw API requests getting generated as opposed to the code generating the requests. The library you're using should give you some way to see that. Then you just need to make sure the address parameters are getting passed correctly in DoExpressCheckoutPayment.
If you like, you might want to take a look at my PHP class library for PayPal. Might kinda suck to start over with another library, but it makes it very quick and easy. It has files prepared with all the parameters and everything ready to go so all you need to do is fill in the values and it'll work every time. :)
After some furious research, I was able to figure out the problem using Paypal's API explorer. As it turns out, setting ->Address on the SetExpressCheckoutRequestType() object is deprecated. The correct method is to set ->ShipToAddress for your PaymentDetailsType() object.
In my case, however, the reason that nothing was working was because I had my address wrong [slaps palm into forehead]. My zip, while in the region of Columbus, OH is technically in Dublin, OH. So, Paypal was generating an error.
Paypal wasn't showing me error information, however, so I had no way to know what in particular was causing the error. This is where the API explorer came in handy; I filled in the API explorer and tried my request--and it gave me detailed error information.
Since then, I've also found out that I can see detailed error information simply by using:
var_dump($setECResponse);
Up until yesterday I had a perfectly working budget organizer site/app working with iGoogle.
Through PHP, using the following little line
file_get_contents('http://www.google.com/ig/calculator?hl=en&q=1usd=?eur');
and similar I was able to get all I needed.
As of today, this is no longer working. When I looked into the issue, what has happened is that Google has retired iGoogle. Bummer!
Anyway, I was looking around elsewhere but I can't find anything that fits my needs. I would REALLY love to just fix it and get it running again by just switching this one line of code (i.e. changing the Google address with the address of some other currency API available) but it seems like none does.
The API from rate-exchange.appspot.com seems like it could be a iGoogle analog but, alas, it never works. I keep getting an "Over Quota" message.
(Here comes an initial question: anybody out there know of a simple, reliable, iGoogle-sort API?)
So I guess the natural thing would be to the Yahoo YQL feature (at least I suppose it is as reliable).
Yahoo's queries look like this:
http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("USDEUR", "USDJPY", "USDBGN")&env=store://datatables.org/alltableswithkeys
What I really can't figure out is how to parse this data. It outputs an XML.
What I used to have is this:
function exchange($inputAmount,$inputCurrency,$outputCurrency) {
$exchange = file_get_contents('http://www.google.com/ig/calculator?hl=en&q='.$inputAmount.$inputCurrency.'=?'.$outputCurrency);
$exchange = explode('"', $exchange);
$exchange = explode('.', $exchange['3']);
$exchange[0] = str_replace(" ", "",preg_replace('/\D/', '', $exchange[0]));
if(isset($exchange[1])){
$exchange[1] = str_replace(" ", "",preg_replace('/\D/', '', $exchange[1]));
$exchange = $exchange[0].".".$exchange[1];
} else{
$exchange = $exchange[0];
}
return $exchange;
}
So the user was able to get the exchange rate from an input currency such as "USD" and an output currency such as "EUR" on a specific amount of money. As I said, this was working swimmingly up until yesterday night.
Any ideas?
Never mind! Solved it!
For anyone interested, here's what I did to get my code to work (with the least chnges possible) with the Yahoo YQL:
// ** GET EXCHANGE INFO FROM YAHOO YQL ** //
$url = 'http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("USDEUR", "EURUSD")&env=store://datatables.org/alltableswithkeys'; //<-- Get the YQL info from Yahoo (here I'm only interested in converting from USD to EUR and vice-versa; you should add all conversion pairs you need).
$xml = simplexml_load_file($url) or die("Exchange feed not loading!"); //<-- Load the XML file into PHP variable.
$exchange = array(); //<-- Build an array to hold the data we need.
for($i=0; $i<2; $i++): //<-- For loop to get data specific to each exchange pair (you should change 2 to the actual amount of pairs you're querying for).
$name = (string)$xml->results->rate[$i]->Name; //<-- Get the name of the pair and turn it into a string (this looks like this: "USD to EUR").
$rate = (string)$xml->results->rate[$i]->Rate; //<-- Do the same for the actual rate resulting from the conversion.
$exchange[$name] = $rate; //<-- Put the data pairs into the array.
endfor; //<-- End for loop. :)
// ** WORK WITH EXCHANGE INFO ** //
$toeur = array( //<-- Create new array specific for conversion to one of the units needed.
'usd' => $exchange['USD to EUR'], //<-- Create an array key for each unit used. In this case, in order to get the conversion of USD to EUR I ask for it from my $exchange array with the pair Name.
'eur' => 1); //<-- The way I coded the app, I found it more practical to also create a conversion for the unit into itself and simply use a 1, which translates into "do not convert"
$tousd = array(
'eur' => $exchange['EUR to USD'],
'usd' => 1);
This is basically all you need to get all the exchange info you want. After that, you use it all something like this:
amount*$toxxx['coin'];
So, say I wanted to know how many Euro is 100 USD right now:
100*$toeur['usd'];
Piece of cake!
Still a very useful solution by QuestionerNo27. Since early 2015, however, Yahoo YQL apparently slightly changed the XML output of their api. 'Name' now no longer translates into a string like 'USD to EUR', but to 'USD/EUR' and should in the code above be referenced this way:
$toeur = array(
'usd' => $exchange['USD/EUR']
instead of
$toeur = array(
'usd' => $exchange['USD to EUR']
and in a similar fashion for other currency conversions.
I created a routine to convert the currency based on #QuestionerNo27 http://jamhubsoftware.com/geoip/currencyconvertor.php?fromcur=USD&tocur=EUR&amount=1 you can consume this
<?php
$fromcur = $_GET['fromcur'];
$tocur = $_GET['tocur'];
$amt = $_GET['amount'];
// ** GET EXCHANGE INFO FROM YAHOO YQL ** //
$url = 'http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("'.$fromcur.$tocur.'")&env=store://datatables.org/alltableswithkeys'; //<-- Get the YQL info from Yahoo (here I'm only interested in converting from USD to EUR and vice-versa; you should add all conversion pairs you need).
$xml = simplexml_load_file($url) or die("Exchange feed not loading!"); //<-- Load the XML file into PHP variable.
$exchange = array(); //<-- Build an array to hold the data we need.
for($i=0; $i<2; $i++): //<-- For loop to get data specific to each exchange pair (you should change 2 to the actual amount of pairs you're querying for).
$name = (string)$xml->results->rate[$i]->Name; //<-- Get the name of the pair and turn it into a string (this looks like this: "USD to EUR").
$rate = (string)$xml->results->rate[$i]->Rate; //<-- Do the same for the actual rate resulting from the conversion.
$exchange[$name] = $rate; //<-- Put the data pairs into the array.
endfor; //<-- End for loop. :)
// ** WORK WITH EXCHANGE INFO ** //
$conv = $fromcur . '/' . $tocur;
$toeur = array( //<-- Create new array specific for conversion to one of the units needed.
$tocur => $amt*$exchange[$conv], //<-- Create an array key for each unit used. In this case, in order to get the conversion of USD to EUR I ask for it from my $exchange array with the pair Name.
$fromcur => $amt,
"ex_amt" =>$amt*$exchange[$conv]); //<-- The way I coded the app, I found it more practical to also create a conversion for the unit into itself and simply use a 1, which translates into "do not convert"
echo json_encode($toeur);
?>