I'm trying to create this XML in a SOAP call
<ns1:NameID type="INTERNAL">831392</ns1:NameID>
<ns1:NameMembership primary="true" displaySequence="1">
<ns2:membershipType>PFS</ns2:membershipType>
<ns2:membershipNumber>222222E</ns2:membershipNumber>
<ns2:membershipLevel>SILVER</ns2:membershipLevel>
<ns2:memberName>Luis Fernandez </ns2:memberName>
</ns1:NameMembership>
I don't know how to add the primarykey and displaySequence` attributes. I trying to create something like this:
$parameters = array("NameID" => array("_" => "831392", "type" => "INTERNAL"),
"NameMembership" => array("_" => array(
"membershipLevel" => "SILVER",
"memberName" => "Luis Fernandez",
"membershipType" => "PFS",
"membershipNumber" => "222222E"), "primary" => true, "displaySequence" => 1
));
But it doesn't work. It returns this code:
<ns1:InsertGuestCardRequest>
<ns1:NameID type="INTERNAL">831392</ns1:NameID>
<ns1:NameMembership primary="true" displaySequence="1"/>
</ns1:InsertGuestCardRequest>
Can anyone help me to find what am I doing wrong?
I got it! Thanks!
$parameters = array("NameID" => array("_" => "831392", "type" => "INTERNAL"),
"NameMembership" => array(
"membershipLevel" => "SILVER",
"memberName" => "Luis Fernandez",
"membershipType" => "PFS",
"membershipNumber" => "222222E",
"primary" => true,
"displaySequence" => 1
));
Related
I got a curl request that calling external API and i got to save the response from it. I already saved the previous results and now i want to create a cronjob that calls the function everyday to update the data from our api source. But when i replace insert into updateOrInsert method by laravel's querybuilder, It leads me to
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
Here is my controller.
public function getProjectList(){
$this->getToken();
$request_time = Carbon::now()->format('YmdHis');
$sign = md5($this->token.$request_time);
$url = 'https://cgi.singmap.com/project/queryProject?request_time='.$request_time.
'&token='.$this->token.'&sign='.$sign.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);
$trimmed = $response['datas'];
// dd($trimmed);
foreach ($trimmed as $res){
$inserts[]=[
'projectId' => $res['projectId'],
'projectName' => $res['projectName'],
'country' => $res['country'],
'location' => $res['location'],
'propertyGroup' => $res['propertyGroup'],
'latitude' => $res['country'],
'longitude' => $res['country'],
'unitsNum' => $res['unitsNum'],
'launchDate' => $res['launchDate'],
'launchDateAltText' => $res['launchDateAltText'],
'mainImage' => $res['mainImage'],
'min_price' => $res['min_price'],
'max_price' => $res['max_price'],
'streetAddress' => $res['streetAddress'],
'tenure' => $res['tenure'],
'developer' => $res['developer'],
'streetAddress' => $res['streetAddress'],
];
}
// \DB::table('xp_ecoprop_projectlist')->insert($inserts);
\DB::table('xp_ecoprop_projectlist')->updateOrInsert($inserts);
dd('Data Inserted');
}
Response example
array:3 [▼
"code" => "0"
"msg" => "SUCCESS"
"datas" => array:127 [▼
0 => array:21 [▼
"propertyGroup" => "D09, D10, D11, D21"
"country" => "Singapore"
"launchDateAltText" => "Launched"
"latitude" => "1.30509901046753"
"galleryLatitude" => "1.30492997169495"
"relationId" => "175"
"launchDate" => "1555689600000"
"galleryLongitude" => "103.828666687012"
"unitsNum" => 154
"mainImage" => "https://img.singmap.com/upload/broke/2029c11d79004b5e915809fbd6e19f7b/0275d26811574de68834663514ee2878/imgs/ffc6d2435f5c43828eb9d2200c6186ff.png"
"max_price" => 35000000.0
"min_price" => 0.0
"streetAddress" => "86, 88 Orchard Boulevard"
"location" => "D10 - Tanglin / Holland"
"completionDate" => "1640966400000"
"developer" => "Granmil Holdings Pte Ltd"
"projectName" => "Boulevard 88 (D10)"
"projectId" => "0275d26811574de68834663514ee2878"
"tenure" => "Freehold"
"projectTitle" => "Boulevard 88 (D10)"
"longitude" => "103.827575683594"
]
I am trying to insert products on Google Merchant Center. I am currently using Google API PHP client, and I am unable to find toSimpleObject function in any of the class and class extending it.
$this->service = new Google_Service_ShoppingContent($client);
$product = array("batchId" => $batchID,
"merchantId" => $this->googleapi->merchantID,
"method" => "insert",
"product" => array(
"kind" => "content#product",
"offerId" => $skuDetails['SKU'],
"title" => $skuDetails['TITLE'],
"description" => $skuDetails['DESCRIPTION'],
"imageLink" => $skuDetails['IMAGE'],
"contentLanguage" => "en",
"targetCountry" => "US",
"channel" => "online",
"availability" => ($skuDetails['QUANTITY'] > 0)?'in stock':'out of stock',
"brand" => $skuDetails['BRAND'],
"condition" => $skuDetails['CONDITION'],
"minHandlingTime" => $skuDetails['HANDLING_TIME'],
"ageGroup" => 'adult',
"maxHandlingTime" => ($skuDetails['HANDLING_TIME'] + 2),
"googleProductCategory" => (empty($skuDetails['CATEGORYID']))?$skuDetails['CATEGORYPATH']:$skuDetails['CATEGORYID'],
"price" => [
"value" => $price['lp'],
"currency" => "USD"
]
)
);
$productObject = new Google_Service_ShoppingContent_ProductsCustomBatchRequest();
$productObject->setEntries($product);
$result = $this->service->products->custombatch($productObject);
Error:
An uncaught Exception was encountered
Type: Error
Message: Call to undefined method Google_Service_ShoppingContent_ProductsCustomBatchRequest::toSimpleObject()
Line Number: 108
Backtrace:
File: vendor/google/apiclient-services/src/Google/Service/ShoppingContent/Resource/Products.php
Line: 40
Function: call
You should be using Google_Service_ShoppingContent_Product to insert data to your product instance then you can use custombatch to upload it
$product = new Google_Service_ShoppingContent_Product();
$product->setId($id);
$product->setTitle($title);
i want to send a soap request using php but i found a problem here is what i have to send as XML format.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:getImpayee>
<tem:tocken>reererer</tem:tocken>
<tem:CodeCreancier>1013</tem:CodeCreancier>
<tem:CodeCreance>01</tem:CodeCreance>
<tem:crVals>
<tem:CreancierVals>
<tem:nomChamp>montant</tem:nomChamp>
<tem:ValeurChamp>45</tem:ValeurChamp>
</tem:CreancierVals>
<tem:CreancierVals>
<tem:nomChamp>ND</tem:nomChamp>
<tem:ValeurChamp>0663143327</tem:ValeurChamp>
</tem:CreancierVals>
</tem:crVals>
</tem:getImpayee>
</soap:Body>
</soap:Envelope>
but the problem is that there is multiple "tem:CreancierVals" when i use this
$client->__setLocation(url_PaiementWS);
$result = $client->getImpayee(
array(
'tocken' => $_SESSION['tocken'],
'CodeCreancier' => $CodeCreancier,
'CodeCreance' => $CodeCreance,
'crVals' => array (
'CreancierVals' => array(
'nomChamp' => 'montant',
'ValeurChamp' => $montant
),
'CreancierVals' => array(
'nomChamp' => 'ND',
'ValeurChamp' => $ND
)
)
)
);
it doesnt work
its like reseting the "CreancierVals" val
is there a solution in which i can send pure xml using php ? or just a dynamic method that doesn't reseting the "CreancierVals" val but add one to the other as an array for example. thanks
Try this:
$result = $client->getImpayee(
[
'tocken' => $_SESSION['tocken'],
'CodeCreancier' => $CodeCreancier,
'CodeCreance' => $CodeCreance,
'crVals' => [
'CreancierVals' => [
[
'nomChamp' => 'montant',
'ValeurChamp' => $montant,
],
[
'nomChamp' => 'ND',
'ValeurChamp' => $ND,
],
],
],
]
);
Using the Chronopost Web Services.
When using this post HTTP request in a web browser (account number and password are hidden there, so you can't test yourself unless you have a Chronopost ID) :
https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS/shippingWithReservationAndESDWithRefClientPC?subAccount=000&accountNumber=ACCOUNT_NUMBER&password=PASSWORD&shipperCivility=E&shipperName=DELBET&shipperName2=RICHARD&shipperAdress1=1%20rue%20des%20accents&shipperZipCode=28500&shipperCity=Ste%20Gemme%20Moronval&shipperCountry=FR&shipperCountryName=France&shipperContactName=Richard%20Delbet&shipperEmail=richard.delbet#telintrans.fr&shipperPhone=0123456789&shipperMobilePhone=0601020304&recipientCivility=E&recipientName=MALKA&recipientName2=DAVID&recipientAdress1=1%20rue%20des%20essais&recipientZipCode=75001&recipientCity=Paris&recipientCountry=FR&recipientCountryName=France&recipientContactName=David%20Malka&recipientEmail=david.malka#telintrans.fr&recipientPhone=0222426789&recipientMobilePhone=0622220304&shipperRef=CMD1&recipientRef=ART1&productCode=01&shipDate=27/07/2010%2010:00:00&shipHour=10&weight=2&service=0&objectType=MAR&modeRetour=1&mode=PDF
I have a valid response with all the correct datas.
When using SoapClient with exactly the same parameters :
$client = new \SoapClient("http://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl");
$data = [
'subAccount' => '000',
'accountNumber' => ACCOUNT_NUMBER,
'password' => PASSWORD,
'shipperCivility' => 'E',
'shipperName' => 'DELBET',
'shipperName2' => 'RICHARD',
'shipperAdress1' => '1%20rue%20des%20accents',
'shipperZipCode' => '28500',
'shipperCity' => 'Ste%20Gemme%20Moronval',
'shipperCountry' => 'FR',
'shipperCountryName' => 'France',
'shipperContactName' => 'Richard%20Delbet',
'shipperEmail' => 'richard.delbet#telintrans.fr',
'shipperPhone' => '0123456789',
'shipperMobilePhone' => '0601020304',
'recipientCivility' => 'E',
'recipientName' => 'MALKA',
'recipientName2' => 'DAVID',
'recipientAdress1' => '1%20rue%20des%20essais',
'recipientZipCode' => '75001',
'recipientCity' => 'Paris',
'recipientCountry' => 'FR',
'recipientCountryName' => 'France',
'recipientContactName' => 'David%20Malka',
'recipientEmail' => 'david.malka#telintrans.fr',
'recipientPhone' => '0222426789',
'recipientMobilePhone' => '0622220304',
'shipperRef' => 'CMD1',
'recipientRef' => 'ART1',
'productCode' => '01',
'shipDate' => '27/07/2010%2010:00:00',
'shipHour' => '10',
'weight' => '2',
'service' => '0',
'objectType' => 'MAR',
'modeRetour' => '1',
'mode' => 'PDF',
];
$response = $client->__soapCall("shippingWithReservationAndESDWithRefClientPC", array($data));
I have an error returned :
object(stdClass)#531 (1) { ["return"]=> object(stdClass)#537 (2) {
["errorCode"]=>
int(1)
["errorMessage"]=>
string(3112) " fr.chronopost.soap.shipping.exception.ValidateException at
fr.chronopost.soap.shipping.util.PopulateUtils.populateSkybill(PopulateUtils.java:355)
at
fr.chronopost.soap.shipping.cxf.ShippingServiceWS.shippingWithReservationAndESDWithRefClientPC(ShippingServiceWS.java:615)
at sun.reflect.GeneratedMethodAccessor1258.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)
at
org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:54)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:285)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:168)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:175)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Thread.java:744) " } }
Unfortunately, the error code "1" is described in the documentation as "system error".
One proabably can't help me directly about the Chronopost Web Services, but maybe I'm missing something into the PHP SoapClient object.
Why do I have a correct response when using a web browser and some kind of ValidateException error when using SoapClient ?
When making a SOAP call, you don't need to include URL encoded data strings. Php soapclient encodes the data into XML automatically. So the problem is most likely the validation the service is performing on your data, and it's choking on the % characters. Try changing
'shipDate' => '27/07/2010%2010:00:00'
to
'shipDate' => '27/07/2010 10:00:00'
On my classes/PaymentModule.php I have declared '{message}' => $customer_message (between other vars) but still my customers see Wiadomość: {message}
in mails which they recieved.
What do I wrong? Maybe declare {message} var in PaymentModule.php is not enough?
UDPATE:
this is standard PaymentModule.php code in Prestashop 1.6.2.1 with added {message} variable:
$customer_message = $order->getFirstMessage();
$data = array(
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{email}' => $this->context->customer->email,
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,
'{delivery_city}' => $delivery->city,
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_firstname}' => $invoice->firstname,
'{invoice_lastname}' => $invoice->lastname,
'{invoice_address2}' => $invoice->address2,
'{invoice_address1}' => $invoice->address1,
'{invoice_city}' => $invoice->city,
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => $order->getUniqReference(),
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
'{payment}' => Tools::substr($order->payment, 0, 32),
'{products}' => $product_list_html,
'{products_txt}' => $product_list_txt,
'{discounts}' => $cart_rules_list_html,
'{discounts_txt}' => $cart_rules_list_txt,
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
'{message}' => $customer_message,
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));
In order_conf.html:
...
Wiadomość: {message}
....
ou should use below function if not already using it.
Example:
$id_lang = (int)$this->context->language->id;
$heading = Mail::l('Message Received', (int)$id_lang);
Mail::Send(
(int)$id_lang,
'order_conf',
$heading,
$data,
$this->context->customer->email,
null,
null,
$this->context->shop->name,
null,
null,
_PS_MODULE_DIR_.'mymodule/mail/',
false,
1
);
mail template should be located in 'mymodule/mail/en/order_conf.html' make languages directories according to your languages like /en , /fr, /nl
With Prestashop 1.7, I’ve tested with
'{message}' => 'hello',
And it displays in email : hello
Are you sure you have something in $customer_message ?
It can be more complicated with some variables. Have a look at $product_list_html
You will see it is an array and there is :
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
It uses an other template to build the list of product (order_conf_product_list.tpl)
I know that post is 3 years old but the solution is not using
$customer_message
but
$customer_message->message