I have an array of data that I want to send to a SOAP client.
It all works, but one piece of data isn't transmitted, as revealed by __getLastRequest().
Here's my code
<?php
$test_array = array(
"request" => array(
"dateTime" => "2011-12-05T11:37:06.0000000+00:00",
"brandId" => 2,
"extSysId" => 11,
"extSysPassword" => "xxxxx",
"customer" => array(
"title" => "Mr",
"firstName" => "Dec",
"lastName" => "Test-Two",
"address" => array(
"type" => "Residential",
"pafValidated" => TRUE,
"houseNumber" => "xx",
"houseName" => "",
"line1" => "xx xx",
"line2" => "",
"line3" => "xx",
"line4" => "",
"line5" => "",
"postcode" => "xxx xxx"
),
"phones" => array(
0 => array(
"type" => "Home",
"_" => "xxx xxxxxx"
),
1 => array(
"type" => "Work",
"preferred" => TRUE,
"_" => ""
),
2 => array(
"type" => "Mobile",
"preferred" => TRUE,
"_" => ""
)
),
"email" => "xxxx.xxxx#gmail.com"
),
"nextPurchase" => array(
"date" => "2014-05-01"
),
"dataProtection" => array(
"group" => FALSE,
"thirdParty" => FALSE
),
"futureContactChannels" => array(
0 => array(
"type" => "Whitemail",
"option" => FALSE
),
1 => array(
"type" => "Email",
"option" => FALSE
),
2 => array(
"type" => "Phone",
"option" => FALSE
),
3 => array(
"type" => "SMS",
"option" => FALSE
)
),
"vehicleRequests" => array(
0 => array(
"derivativeCode" => "xxxxx",
"type" => "T"
)
),
"Retailer" => array(
0 => array (
"dealerCode" => "00082"
)
),
"company" => array(
"companyName" => "",
"jobTitle" => ""
),
"campaign" => array(
"code" => "xxxxxxxxx",
"source" => 69
),
"notes" => "blah balh: ."
)
);
$client = new SoapClient("/xxx/xxxx/xxxxxx/xxxxx.wsdl", array(
"login" => "xxx",
"password" => "xxx",
"location" => "http://xxx.xxx.xxx.xxx/xxxxxx/Some.asmx",
"uri" => "urn:xmethods-delayed-quotes",
'trace' => 1,
'exceptions' => 1,
'soap_version' => 'SOAP_1_1',
'encoding' => 'UTF-8',
'features' => 'SOAP_USE_XSI_ARRAY_TYPE'
));
$client->CallComeFunction($test_array);
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "*************************************************\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";
The Retailed[0]['dealerCode'] is the only piece of info that is omitted from the sent XML.
Any ideas?
Many thanks.
As mac says, formatting the code would be nice, but one thing I notice is the 'Retailer' field is the only one that's capitalized. Not sure if the WSDL has any influence on what is sent by the client but it might.
Double check the WSDL and see if the field should be 'retailer' instead. Any chance you can share the WSDL, btw?
EDIT
After reviewing the WSDL, 'retailer' is the way to go:
<s:element minOccurs="0" maxOccurs="1" name="retailer" type="tns:Retailer"/>
The payload should be formatted differently as well, it should be
"retailer" => array(
"dealerCode" => "00082"
)
per the WSDL
<s:complexType name="Retailer">
<s:attribute name="dealerCode" type="s:string"/>
</s:complexType>
Related
I am getting an error
I want to implement payment gateway but the error is much like :
Illegal string offset 'code'
Illegal string offset 'description'
'MercadoPagoException' with message 'transaction_amount attribute can't be null
This is my array
$preference_data = array(
"items" => array(
array(
"id" => "Code",
"title" => $rest['name'],
"currency_id" => "USD",
"picture_url" =>"https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
"description" => "Description",
"category_id" => "Category",
"quantity" => 1,
"unit_price" => intval($total_price)
)
),
"payer" => array(
"name" => "APRO".$a[0],
"surname" => $a[1],
"email" => "test_user_44825516#testuser.com",
"date_created" => "2014-07-28T09:50:37.521-04:00",
"phone" => array(
"area_code" => "11",
"number" => "4444-4444"
),
"identification" => array(
"type" => "DNI",
"number" => "12345678"
),
"address" => array(
"street_name" => "Street",
"street_number" => 123,
"zip_code" => "1430"
)
),
"back_urls" => array(
"success" => "http://localhost/duncan_fooddelivery/api/success.php",
"failure" => "http://www.failure.com",
"pending" => "http://www.pending.com"
),
"auto_return" => "approved",
"payment_methods" => array(
"excluded_payment_methods" => array(
array(
"id" => "amex",
)
),
"excluded_payment_types" => array(
array(
"id" => "ticket"
)
),
"installments" => 24,
"default_payment_method_id" => null,
"default_installments" => null,
),
"shipments" => array(
"receiver_address" => array(
"zip_code" => "1430",
"street_number"=> 123,
"street_name"=> "Street",
"floor"=> 4,
"apartment"=> "C"
)
),
"token" => array (
"card_id" => NULL,
"card_number_length" => 16,
"cardholder" => array (
"identification" => array (
"number" => "11111111",
"type" => "DNI",
),
"name" => "APROARPAN BAJPAI",
),
"creation_date" => NULL,
"due_date" => NULL,
"esc" => NULL,
"expiration_month" => 6,
"expiration_year" => 2022,
"first_six_digits" => "450995",
"id" => "ad56c2e6cb4a2b17c18e632139366a7e",
"last_four_digits" => "3704",
"last_modified_date" => NULL,
"luhn_validation" => "true",
"public_key" => "TEST-1a0ffe62-165f-4e7b-b501-df15741b6d87",
"security_code_length" => 3,
"status" => "active",
"trunc_card_number" => NULL,
"used_date" => NULL,
),
"transaction_amount" => 60,
"notification_url" => "https://www.your-site.com/ipn",
"external_reference" => "Reference_1234",
"expires" => false,
"expiration_date_from" => null,
"expiration_date_to" => null,
);
I am passing "transaction_amount" => 60, But still getting same error.
Please help me I am searching from 5 Hours.
Thanks.
I tried the following code and tried to post values from android to place an order but every time i test it on chrome it give http 500 error, and Android gives volly server error. Dont know where i am messing up, serious help would be appriciated. Thank You
Ask me if you need to take a look at the android Code, but i think that doesnot matter here because i am giving hard coded values in $data.
<?php
require_once( 'lib/woocommerce-api.php' );
$pageNum=1;
$pageNum=$_GET['page_num'];
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 30,
'ssl_verify' => false,
);
try {
$client = new WC_API_Client( 'https://www.move2mart.com/', 'ck_0afa3a49305683160fe34189553a660053bd4e6239', 'cs_7dc38a7b52c3fdd34qw61e34090be636ae3364b196', $options );
//$data=array();
$data=[
'payment_method' => 'cod',
'payment_method_title' => 'Cash on Delivery',
'set_paid' => false,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'city' => 'Karachi',
'email' => 'princeali#testing.com',
'phone' => '03123121995'
], 'line_items' => [
[
'product_id' => 779,
'quantity' => 1
]
]
];
print_r($client->post('orders', $data));
if($_POST !=null) {
}
else{
echo "Null POST Request";
}
} catch ( WC_API_Client_Exception $e ) {
echo $e->getMessage() . PHP_EOL;
echo $e->getCode() . PHP_EOL;
if ( $e instanceof WC_API_Client_HTTP_Exception ) {
print_r( $e->get_request() );
print_r( $e->get_response() );
}
}
$orderData = array(
"order" => array(
"billing_address" => array(
array(
"first_name" => "",
"last_name" => "",
"company" => "",
"address_1" => "",
"address_2" => "",
"city" => "",
"state" => "",
"postcode" => "",
"country" => "",
"email" => "",
"phone" => "",
)
),
"shipping_address" => array(
array(
"first_name" => "",
"last_name" => "",
"company" => "",
"address_1" => "",
"address_2" => "",
"city" => "",
"state" => "",
"postcode" => "",
"country" => "",
)
),
"customer_id" => 1,
"line_items" => array(
array(
"product_id" => 1,
"quantity" => 1
)
)
)
);
$client->orders->create($orderData);
Would you please try above code?
Finally, I figured it out after some research. Below is working code of woocommerce checkout webservice that may Help you -
/*** Just Copy & Paste and change your varriables **/
//do your initial stuff
header('Content-type: application/json');
$json_file=file_get_contents('php://input');
$jsonvalue= json_decode($json_file,true);
$user_id = $jsonvalue['user_id'];
$product_id = $jsonvalue['product_id'];
$quantity = $jsonvalue['quantity'];
//start order data
$orderData = array(
"order" => array(
'payment_method' => 'paypal',
'payment_method_title' => 'Paypal',
'set_paid' => true,
"billing_address" => array(
"first_name" => "bfname",
"last_name" => "blname",
"company" => "testcompanybilling",
"address_1" => "sec8",
"address_2" => "e32",
"city" => "noida",
"state" => "Noida",
"postcode" => "99999",
"country" => "IN",
"email" => "test#gmail.com",
"phone" => "888899999999"
),
"shipping_address" => array(
"first_name" => "sfname",
"last_name" => "slname",
"company" => "testcompanyshipping",
"address_1" => "shakkarpur",
"address_2" => "laxminigar",
"city" => "New Delhi",
"state" => "Delhi",
"postcode" => "110092",
"country" => "IN",
"email" => "testsh#gmail.com",
"phone" => "11009999"
),
"customer_id" => $user_id,
"line_items" => array(
array(
"product_id" => $product_id,
"quantity" => $quantity
)
),
'shipping_lines' => array(
array(
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => 10
)
)
)
);
//Create order usind order data
$data = $client->orders->create($orderData);
//echo '<pre>';
//print_r($data);
$result['success']='true';
$result['error']="0";
$result['msg']='Your order has been successfully placed.';
$result['data']=$data;
echo json_encode($result); `
cheers!!!
m trying to extract data from json in mysql:
my sample mysql query is :
I already tried using below code , but its returning null vales , But i have value in database .
In the below code column_name1 and er_trading_sales is column name and table_name is the name of the table
SELECT column_name1 as column_name1,
substring(
er_trading_sales,
locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered dealers","v":"}","C3": { "type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_s ales))+70,
(locate('"},"C4',er_trading_sales,locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered dealers","v":"}","C3":{"type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_sales))) - (locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered dealers","v":"}","C3": {"type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_ sales))+70))
) as TradingAmount
from table_name
//sample json
"R10" => array(
"col_data" => array(
"CR1" => array(
"C1" => array(
"type" => "label",
"value" => "8.",
),
"C2" => array(
"type" => "complex",
"value" => array(
"m" => "label",
"k" => "Turnover of sale of goods taxable # ^d^%",
"v" => "4.5"
),
),
"C3" => array(
"type" => "textbox",
"value" => "",
"validation" => "decimal",
),
"C4" => array(
"type" => "textbox",
"value" => "",
"validation" => "decimal",
'htmlOptions' => array('readonly' => 'readonly'),
),
"C5" => array(
"type" => "",
"value" => "",
),
),
),
),
i want "value" of "C3" => array(
"type" => "textbox",
"value" => "",
"validation" => "decimal",
)
I have a array I have to post (json). But the value accountNr should either be $val_nc_iban or should be NULL depending on a certain value outside this array. So how can I either echo $val_nc_iban (is a string) or NULL (not string) inside an array depending on the outside value?
$curl_post_data_nc = array(
"person" => array(
"title" => "$val_nc_persontitle",
"nationalNr" => NULL,
"firstName" => "$val_nc_personfirstname",
"lastName" => "$val_nc_personsurname",
"birthDate" => "$new_val_nc_persondob"
),
"company" => array(
"type" => "$val_nc_companytype",
"name" => "$val_nc_companyname",
"vat" => "$val_nc_companyvat",
"nace" => "$val_nc_companynace",
"website" => NULL
),
"contact" => array(
"email" => "$val_nc_personemail",
"mobile" => "$val_nc_personphone",
"telephone" => NULL
),
"contract" => array(
"referenceDate" => "$val_nc_refdate",
"startDate" => "$val_nc_startdate"
),
"payment" => array(
"paymentMethodEmail" => false,
"paymentMethodMail" => true,
"paymentInterval" => "$val_nc_paymentbilling",
"method" => "$val_nc_paymentmethod",
"accountNr" => $val_nc_result = ($val_nc_paymentmethod == 'TRANSFER') ? NULL : "$val_nc_iban"
),
"deliveryAddress" => array(
"building" => "HOUSE",
"street" => "$val_nc_personstreet",
"streetNr" => "$val_nc_personstreetnr",
"floor" => NULL,
"boxNr" => NULL,
"localityCode" => "$val_nc_personpostcode",
"localityName" => "$val_nc_personlocality"
),
"invoiceAddress" => array(
"sameAsDelivery" => false,
"building" => "HOUSE",
"street" => "$val_nc_billstreet",
"streetNr" => "$val_nc_billstreetnr",
"floor" => NULL,
"boxNr" => NULL,
"localityCode" => "$val_nc_billpostcode",
"localityName" => "$val_nc_billlocality"
),
"gasMeter" => array(
"ean" => "$val_nc_ean",
"nr" => NULL,
"type" => "gas",
"electric" => NULL,
"gas" => array(
"usage" => $val_nc_gasusage,
"formula" => "TTF103532"
)
),
Why do you put the variables in quotes? You can use their actual value in the array!
Example:
$curl_post_data_nc = array(
"person" => array(
"title" => $val_nc_persontitle,
"nationalNr" => NULL,
"firstName" => $val_nc_personfirstname,
"lastName" => $val_nc_personsurname,
"birthDate" => $new_val_nc_persondob
),
"company" => array(
"type" => $val_nc_companytype,
"name" => $val_nc_companyname,
"vat" => $val_nc_companyvat,
"nace" => $val_nc_companynace,
"website" => NULL
),
"contact" => array(
"email" => $val_nc_personemail,
"mobile" => $val_nc_personphone,
"telephone" => NULL
),
"contract" => array(
"referenceDate" => $val_nc_refdate,
"startDate" => $val_nc_startdate
),
"payment" => array(
"paymentMethodEmail" => false,
"paymentMethodMail" => true,
"paymentInterval" => $val_nc_paymentbilling,
"method" => $val_nc_paymentmethod,
"accountNr" => $val_nc_result = ($val_nc_paymentmethod == 'TRANSFER') ? NULL : $val_nc_iban
),
"deliveryAddress" => array(
"building" => "HOUSE",
"street" => $val_nc_personstreet,
"streetNr" => $val_nc_personstreetnr,
"floor" => NULL,
"boxNr" => NULL,
"localityCode" => $val_nc_personpostcode,
"localityName" => $val_nc_personlocality
),
"invoiceAddress" => array(
"sameAsDelivery" => false,
"building" => "HOUSE",
"street" => $val_nc_billstreet,
"streetNr" => $val_nc_billstreetnr,
"floor" => NULL,
"boxNr" => NULL,
"localityCode" => $val_nc_billpostcode,
"localityName" => $val_nc_billlocality
),
"gasMeter" => array(
"ean" => $val_nc_ean,
"nr" => NULL,
"type" => "gas",
"electric" => NULL,
"gas" => array(
"usage" => $val_nc_gasusage,
"formula" => "TTF103532"
)
),
I am trying to use a Dolibarr soap web service with php
Dolibarr web service
this is what i got for the moment:
$url = "http://localhost/seko/dollibar/dolibarr-3.7.1/htdocs/webservices/server_invoice.php?wsdl";
$client = new SoapClient($url);
$authentication = array(
"dolibarrkey" => "xxxxx",
"sourceapplication" => "",
"login" => "xxxx",
"password" => "xxxxxx",
"entity" => "1"
);
$line = array(
"id" => "57",
"type" => 0,
"desc" => "SEKO",
"vat_rate" => 16.000,
"qty" => 03,
"unitprice" => 10500.00000000,
"total_net" => 10500.0000000,
"total_vat" => 1680.00000000,
"total" => 12180.0000000,
"date_start" => "",
"date_end" => "",
"payment_mode_id" => "efectivo",
"product_id" => 1,
"product_ref" => "",
"product_label" => "",
"product_desc" => ""
);
$invoice = array(
"id" => "57",
"ref" => "0007",
"ref_ext" => "test",
"thirdparty_id" => 3,
"fk_user_author" => "1",
"fk_user_valid" => "1",
"date" => date("Y-m-d"),
"date_due" => date("Y-m-d"),
"date_creation" => date("Y-m-d h:i:sa"),
"date_validation" => date("Y-m-d h:i:sa"),
"date_modification" => "",
"type" => 0,
"total_net" => 10500.00000000,
"total_vat" => 1680.00000000,
"total" => 12180.0000000,
"note_private" => "",
"note_public" => "",
"status" => 2,
"close_code" => "",
"close_note" => "",
"project_id" => "",
"lines" => $lines
);
$res = $client->createInvoice($authentication, $invoice);
var_dump($res);
I get the following error:
An uncaught Exception was encountered
Type: SoapFault
Message: looks like we got no XML document
When I use the getInvoice method of the service it works fine. But not the creatInvoice method. I am sure the problem is with my $line array but I do not know how to fix it.
According to XML documentation (open this http://localhost/seko/dollibar/dolibarr-3.7.1/htdocs/webservices/server_invoice.php?wsdl in your webbrowser)
please note that you need to remove the "payment_mode_id" field from the $line array and move it to your $invoice array
Like this :
$line = array(
"id" => "57",
"type" => 0,
"desc" => "SEKO",
"vat_rate" => 16.000,
"qty" => 03,
"unitprice" => 10500.00000000,
"total_net" => 10500.0000000,
"total_vat" => 1680.00000000,
"total" => 12180.0000000,
"date_start" => "",
"date_end" => "",
"product_id" => 1,
"product_ref" => "",
"product_label" => "",
"product_desc" => ""
);
$invoice = array(
"id" => "57",
"ref" => "0007",
"ref_ext" => "test",
"thirdparty_id" => 3,
"fk_user_author" => "1",
"fk_user_valid" => "1",
"date" => date("Y-m-d"),
"date_due" => date("Y-m-d"),
"date_creation" => date("Y-m-d h:i:sa"),
"date_validation" => date("Y-m-d h:i:sa"),
"date_modification" => "",
"payment_mode_id" => "efectivo",
"type" => 0,
"total_net" => 10500.00000000,
"total_vat" => 1680.00000000,
"total" => 12180.0000000,
"note_private" => "",
"note_public" => "",
"status" => 2,
"close_code" => "",
"close_note" => "",
"project_id" => "",
"lines" => $lines
);
Hoping help
Regards