Last active
August 29, 2015 14:22
-
-
Save pswaine/b78d70094915bd93c5ea to your computer and use it in GitHub Desktop.
Magento Soap API Test Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password'; | |
$orderIncrementId = 'order12341234'; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->salesOrderInfo([ | |
'sessionId' => $sessionId, | |
'orderIncrementId' => $orderIncrementId, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password' | |
$orderIncrementId = 'order12341234'; | |
$items = [ | |
0 => [ | |
'order_item_id' => 345, | |
'qty' => 1 | |
], | |
1 => [ | |
'order_item_id' => 347, | |
'qty' => 1 | |
], | |
]; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->salesOrderShipmentCreate([ | |
'sessionId' => $sessionId, | |
'orderIncrementId' => $orderIncrementId, | |
'itemsQty' => $items, | |
'comment' => 'Test comment', | |
'email' => 'user@example.com', | |
'includeComment' => 1, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password' | |
$shipmentIncrementId = '23452345'; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->salesOrderShipmentInfo([ | |
'sessionId' => $sessionId, | |
'shipmentIncrementId' => $shipmentIncrementId, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password' | |
$orderIncrementId = 'order12341234'; | |
$invoiceIncrementId = 123; | |
$shipping = '2.99'; | |
$items = [ | |
0 => [ | |
'order_item_id' => 345, | |
'qty' => 1 | |
], | |
1 => [ | |
'order_item_id' => 347, | |
'qty' => 0 | |
], | |
]; | |
$reasons = [ | |
0 => [ | |
'order_item_id' => 345, | |
'return_code' => 4 | |
], | |
1 => [ | |
'order_item_id' => 347, | |
'return_code' => null | |
], | |
]; | |
$creditmemoData = [ | |
'qtys' => $items, | |
'shipping_amount' => $shipping, | |
'adjustment_negative' => 0, | |
'adjustment_positive' => 0, | |
'invoice_increment_id' => $invoiceIncrementId, | |
'return_to_stock' => 1, | |
'item_reasons' => $reasons, | |
]; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->salesOrderCreditmemoCreate([ | |
'sessionId' => $sessionId, | |
'orderIncrementId' => $orderIncrementId, | |
'creditmemoData' => $creditmemoData, | |
'comment' => 'Test comment', | |
'notifyCustomer' => 0, | |
'includeComment' => 0, | |
'refundToStoreCreditAmount' => null, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password' | |
$creditmemoIncrementId = '34563456'; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->salesOrderCreditmemoInfo([ | |
'sessionId' => $sessionId, | |
'creditmemoIncrementId' => $creditmemoIncrementId, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap?wsdl=1'; | |
$options = ['trace' => 1, 'connection_timeout' => 120, 'cache_wsdl' => WSDL_CACHE_NONE]; | |
$username = 'username'; | |
$password = 'password'; | |
$productInfo = [ | |
'product_id' => '207147', | |
'sku' => '4577237909045046', | |
]; | |
$productData = [ | |
'qty' => '502', | |
'is_in_stock' => '1', | |
]; | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->catalogInventoryStockItemUpdate([ | |
'sessionId' => $sessionId, | |
'productInfo' => $productInfo, | |
'productData' => $productData, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
print_r($cli->__getLastResponse()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
ini_set('display_errors', 1); | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
ini_set('soap.wsdl_cache_ttl', '0'); | |
$url = 'https://www.example.com/api/v2_soap/?wsdl'; | |
$options = ['trace' => 1, 'connection_timeout' => 120]; | |
$username = 'username'; | |
$password = 'password'; | |
$productInfo = array( | |
0 => [ | |
'product_id' => '177567', | |
'sku' => 'H5880078807361', | |
], | |
1 => [ | |
'product_id' => '177564', | |
'sku' => 'H5880078807360', | |
], | |
); | |
$productData = array( | |
0 => [ | |
'qty' => '5011', | |
'is_in_stock' => '1', | |
], | |
1 => [ | |
'qty' => '5211', | |
'is_in_stock' => '1', | |
] | |
); | |
try { | |
$cli = new SoapClient($url, $options); | |
$session = $cli->login(['username' => $username,'apiKey' => $password]); | |
$sessionId = $session->result; | |
$result = $cli->catalogInventoryStockItemMultiUpdate([ | |
'sessionId' => $sessionId, | |
'productInfo' => $productInfo, | |
'productData' => $productData, | |
]); | |
print_r($result); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
print_r($cli->__getLastResponse()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment