Hello I am creating a wordpress website for a client using WooCommerce. The site is complete but the client wants the ability to create shipments from the shop_order page. I have most of this figured out, the problem is my XML request to the UPS API. I have checked and recheck, and I cant seem to find the error:
<ShipmentConfirmResponse><Response><ResponseStatusCode>0</ResponseStatusCode><ResponseStatusDescription>Failure</ResponseStatusDescription><Error><ErrorSeverity>Hard</ErrorSeverity><ErrorCode>10002</ErrorCode><ErrorDescription>The XML document is well formed but the document is not valid</ErrorDescription></Error></Response></ShipmentConfirmResponse>
Below is my xml mark up with sensitive info hidden.
<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>******</AccessLicenseNumber>
<UserId>********</UserId>
<Password>********</Password>
</AccessRequest>
<?xml version="1.0" ?>
<ShipConfirmRequest xml:lang='en-US'>
<Request>
<TransactionReference>
<CustomerContext>Customer Context</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<RequestAction>ShipConfirm</RequestAction>
<RequestOption>validate</RequestOption>
</Request>
<Shipment>
<Shipper>
<ShipperNumber>*******</ShipperNumber>
<Name>Canyon Werks, LLC</Name>
<Address>
<AddressLine>2941 Brookspark Drive</AddressLine>
<AddressLine></AddressLine>
<City>North Las Vegas</City>
<StateProvinceCode>NV</StateProvinceCode>
<PostalCode>89030</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<Phone>
<Number>7022552222</Number>
</Phone>
</Shipper>
<ShipTo>
<Name>Justin Walker</Name>
<Address>
<AddressLine>2675 Windmill Pkwy</AddressLine>
<AddressLine>3024</AddressLine>
<City>Henderson</City>
<StateProvinceCode>NV</StateProvinceCode>
<PostalCode>89074</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<Phone>
<Number>7024609485</Number>
</Phone>
</ShipTo>
<ShipFrom>
<Name>Canyon Werks, LLC</Name>
<Address>
<AddressLine>2941 Brookspark Drive</AddressLine>
<AddressLine></AddressLine>
<City>North Las Vegas</City>
<StateProvinceCode>NV</StateProvinceCode>
<PostalCode>89030</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<Phone>
<Number>7022552222</Number>
</Phone>
</ShipFrom>
<PaymentInformation>
<ShipmentCharge>
<Type>01</Type>
<BillShipper>
<AccountNumber>*******</AccountNumber>
</BillShipper>
</ShipmentCharge>
</PaymentInformation>
<Service>
<Code>03</Code>
</Service>
<Package>
<Packaging>
<Code>02</Code>
<Description>Customer Supplied</Description>
</Packaging>
<Dimensions>
<UnitOfMeasurement>
<Code>IN</Code>
</UnitOfMeasurement>
<Length>16</Length>
<Width>12</Width>
<Height>6</Height>
</Dimensions>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>6.07</Weight>
</PackageWeight>
</Package>
</Shipment>
<LabelSpecification>
<LabelImageFormat>
<Code>GIF</Code>
</LabelImageFormat>
</LabelSpecification>
</ShipConfirmRequest>
I am almost there on this, but I am stuck at this road block. If anyone can shed some light into this it would be much appreciated.
It was the service code container it must be included in the package container. I had it before it. Took me quite a while to figure out this dumb mistake on my part.
Before:
...
<Service>
<Code>03</Code>
</Service>
<Package>
...
After:
...
<Package>
<Service>
<Code>03</Code>
</Service>
...
Thanks for the help, and yes UPS requires a strange XML format.
The XML processing instruction appears twice:
<?xml version="1.0" ?>
This indicates the presence of two distinct XML documnents:
<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>******</AccessLicenseNumber>
<UserId>********</UserId>
<Password>********</Password>
</AccessRequest>
and
<?xml version="1.0" ?>
<ShipConfirmRequest xml:lang='en-US'>
<Request>
<TransactionReference>
<CustomerContext>Customer Context</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<RequestAction>ShipConfirm</RequestAction>
<RequestOption>validate</RequestOption>
</Request>
<!-- ... -->
</ShipConfirmRequest>
Related
How get FEDEX_ONE_RATE API using php
I tried to get by JeremyDunn/php-fedex-api-wrapper
but not use standard rates comes good, when I tried to 'FEDEX_ONE_RATE' nothing change.
Try 1
$rateRequest->ShipmentSpecialServicesRequested->SpecialServiceTypes = 'FEDEX_ONE_RATE';
Try 2
$rateRequest->VariableOptions = array(SimpleType\ServiceOptionType::_FEDEX_ONE_RATE);
The above both method it's request are appended the parameter but results are nothing changed.
Any one help me.
Difficult to say without looking at your exact request, but assuming that your are submitting a RateRequest, then you need to:
Specify FEDEX_ONE_RATE as a ServiceOptionType in the RateRequest.VariableOptions.
Specify one of the supported Packaging Types (FEDEX_SMALL_BOX, FEDEX_MEDIUM_BOX, FEDEX_LARGE_BOX, FEDEX_EXTRA_LARGE_BOX, FEDEX_PAK, FEDEX_TUBE, FEDEX_ENVELOPE).
Specify a U.S. origin and a U.S. destination.
See the FedEx documentation for all the details.
For example, using the following request:
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>...</Key>
<Password>...</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>...</AccountNumber>
<MeterNumber>...</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<VariableOptions>FEDEX_ONE_RATE</VariableOptions>
<RequestedShipment>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<Shipper>
<Address>
<StateOrProvinceCode>TN</StateOrProvinceCode>
<PostalCode>38017</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Shipper>
<Recipient>
<Address>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>90028</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>...</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>10.00</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
The corresponding response would be (I've omitted a lot of the details in order to highlight the important parts):
<RateReply>
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>crs</Source><Code>0</Code>
<Message>Request was successfully processed. </Message>
<LocalizedMessage>Request was successfully processed. </LocalizedMessage>
</Notifications>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<RateReplyDetails>
<ServiceType>FIRST_OVERNIGHT</ServiceType>
...
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<DestinationAirportId>BUR</DestinationAirportId>
<ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
<RatedShipmentDetails>
...
</RatedShipmentDetails>
</RateReplyDetails>
<RateReplyDetails>
<ServiceType>FIRST_OVERNIGHT</ServiceType>
...
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<AppliedOptions>FEDEX_ONE_RATE</AppliedOptions>
<DestinationAirportId>BUR</DestinationAirportId>
<ActualRateType>PAYOR_ACCOUNT_PACKAGE</ActualRateType>
<RatedShipmentDetails>
<ShipmentRateDetail>
<SpecialRatingApplied>FEDEX_ONE_RATE</SpecialRatingApplied>
...
</ShipmentRateDetail>
...
</RatedShipmentDetails>
</RateReplyDetails>
</RateReply>
I.e. for each ServiceType (e.g. FIRST_OVERNIGHT) two set of rates are returned: one without and one with the FEDEX_ONE_RATE applied (as highlighted by the presence of the AppliedOptions and SpecialRatingApplied elements in the RateReplyDetails).
Finally I got Resolved
This is the working code for postman (SOAP Request)
$url = 'https://ws.fedex.com:443/web-services/rate'; //SAND BOX
$url = 'https://wsbeta.fedex.com:443/web-services/rate'; // LIVE
$xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v28"> <SOAP-ENV:Body>
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>.....</Key>
<Password>....</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>....</AccountNumber>
<MeterNumber>....</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>28</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<VariableOptions>FEDEX_ONE_RATE</VariableOptions>
<RequestedShipment>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>FEDEX_SMALL_BOX</PackagingType>
<Shipper>
<Address>
<StateOrProvinceCode>TN</StateOrProvinceCode>
<PostalCode>38017</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Shipper>
<Recipient>
<Address>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>90028</PostalCode>
<CountryCode>US</CountryCode>
<Residential>false</Residential>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>.....</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>LB</Units>
<Value>10.00</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
I have 2 xml string, which come from below 2 functions :
1) $accessRequestXML = $accessRequesttXML->asXML();
It products this xml string :
<?xml version="1.0"?>
<AccessRequest>
<AccessLicenseNumber>7D54A69331203795</AccessLicenseNumber>
<UserId>peterfelts</UserId>
<Password>abc123</Password>
<AccessRequest>
2)
$rateRequestXml = $rateRequestXML->asXML();
It products this xml string :
<?xml version="1.0"?>
<RatingServiceSelectionRequest>
<Request>
<RequestAction>Rate</RequestAction>
<RequestOption>Rate</RequestOption>
</Request>
<Shipment>
<Shipper>
<Name>Name</Name>
<ShipperNumber></ShipperNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Corado</City>
<PostalCode>00646</PostalCode>
<CountryCode>PR</CountryCode>
</Address>
</Shipper>
<ShipTo>
<CompanyName>Company Name</CompanyName>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Corado</City>
<PostalCode>00646</PostalCode>
<CountryCode>PR</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<CompanyName>Company Name</CompanyName>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Boca Raton</City>
<StateProvinceCode>FL</StateProvinceCode>
<PostalCode>33434</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>02</Code>
<Description>2nd Day Air</Description>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
<Description>UPS Package</Description>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>15.2</Weight>
</PackageWeight>
</Package>
</Shipment>
</RatingServiceSelectionRequest>
I want to add RatingServiceSelectionRequest this node to AccessRequest
I want result like this :
<?xml version="1.0"?>
<AccessRequest>
<AccessLicenseNumber>7D54A69331203795</AccessLicenseNumber>
<UserId>peterfelts</UserId>
<Password>abc123</Password>
<RatingServiceSelectionRequest>
<Request>
<RequestAction>Rate</RequestAction>
<RequestOption>Rate</RequestOption>
</Request>
<Shipment>
<Shipper>
<Name>Name</Name>
<ShipperNumber></ShipperNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Corado</City>
<PostalCode>00646</PostalCode>
<CountryCode>PR</CountryCode>
</Address>
</Shipper>
<ShipTo>
<CompanyName>Company Name</CompanyName>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Corado</City>
<PostalCode>00646</PostalCode>
<CountryCode>PR</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<CompanyName>Company Name</CompanyName>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>Boca Raton</City>
<StateProvinceCode>FL</StateProvinceCode>
<PostalCode>33434</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>02</Code>
<Description>2nd Day Air</Description>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
<Description>UPS Package</Description>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>15.2</Weight>
</PackageWeight>
</Package>
</Shipment>
</RatingServiceSelectionRequest>
</AccessRequest>
Can anyone please help me how can i do this ?
IMHO - the best way to do this is to import the XML into DOM which allows you more flexible ways of adding nodes and moving them around.
This code loads the access request as the start of the DOM document and then imports the second XML as a new node, it then appends it to the end of the existing XML...
$dom = new DOMDocument();
$dom->loadXML($accessRequestXML->asXML());
$importrr = dom_import_simplexml($rateRequestXml);
$domImportRR = $dom->importNode($importrr, true);
$dom->documentElement->appendChild($domImportRR);
echo $dom->saveXML();
Anyone knows how to read ADF file from the URL in PHP and render it and save it in MySQL table?
When I use function like
$xml=simplexml_load_file($_REQUEST['adfpath']) or die("Error: Cannot create object");
it's showing
Error: Cannot create object
Below is the ADF File Sample:
<?ADF VERSION "1.0"?>
<?XML VERSION "1.0"?>
<adf>
<prospect>
<requestdate>2010-11-18</requestdate>
<vehicle>
<year></year>
<make></make>
<model></model>
</vehicle>
<customer>
<contact>
<name part="first">Test11</name>
<name part="last">mctester</name>
<address type ="home">
<street line ="1">1722 W test test RD</street>
<city></city>
<state>AZ</state>
<postalcode></postalcode>
</address>
<phone type="voice"></phone>
</contact>
</customer>
<vendor>
<vendorname>
Test vender
</vendorname>
</vendor>
<provider>
<name part='full'>test11 test22 </name>
<service>Leads - </service>
<url>test</url>
<email>test</email>
<phone>800-123-4567</phone>
<contact primarycontact='1'>
<name part='full'>Dennys Test11</name>
<email>test</email>
<phone type='voice' time='day'></phone>
<phone type='fax' time='day'></phone>
<address>
<street line='1'>Apple </street>
<street line='2'>K Mart </street>
<city></city>
<regioncode></regioncode>
<postalcode></postalcode>
<country>US</country>
</address>
</contact>
</provider>
</prospect>
</adf>
Any help is greatly appreciated..
i get an error, 520002 - Internal Error from PayPal, when I try to create and send an invoice.
I can do it with ci-merchant but no with angelleye (for codeigniter). When I try to create it I get this errors:
<?xml version="1.0" encoding="utf-8"?>
<CreateAndSendInvoiceRequest xmlns="http://svcs.paypal.com/types/ap">
<requestEnvelope xmlns="">
<detailLevel>ReturnAll</detailLevel>
<errorLanguage>en_US</errorLanguage>
</requestEnvelope>
<invoice xmlns="">
<merchantEmail xmlns="">lalanzaos#gmail.com</merchantEmail>
<payerEmail xmlns="">oscar73#gmail.com</payerEmail>
<itemList xmlns="">
<item xmlns="">
<name xmlns="">Clases de idiomas (Español)</name>
<description xmlns="">Dia/s: 2014-08-08</description>
<date xmlns="">2014-08-22</date>
<quantity xmlns="">1</quantity><unitPrice xmlns="">11.00</unitPrice>
</item>
</itemList>
<currencyCode xmlns="">USD</currencyCode>
<invoiceDate xmlns="">2014-08-22</invoiceDate>
<dueDate xmlns="">2014-08-22</dueDate>
<referrerCode xmlns="">AngellEYE_PHPClass</referrerCode>
</invoice>
</CreateAndSendInvoiceRequest>
<?xml version='1.0' encoding='UTF-8'?>
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/pt">
<responseEnvelope>
<timestamp>2014-08-22T04:12:25.170-07:00</timestamp>
<ack>Failure</ack>
<correlationId>87f10d36a1e29</correlationId>
<build>11737381</build>
</responseEnvelope>
<error>
<errorId>520002</errorId>
<domain>PLATFORM</domain>
<subdomain>Application</subdomain>
<severity>Error</severity>
<category>Application</category>
<message>Internal Error</message>
</error>
</ns3:FaultMessage>
It seems that the date format is not being correctly passed . It should be like below :
<invoiceDate xmlns="">2014-08-23T22:33:35</invoiceDate>
<dueDate xmlns="">2014-08-24T22:33:35</dueDate>
It should be working fine with this formatting .
Does Authorize.net ARP API accept XML data if the data field is empty ? Do we need to have the data on all the XML elements ?
I used the following XML for updating the subscription.
<?xml version="1.0" encoding="utf-8"?>
<ARBUpdateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>435345345345</name>
<transactionKey>sdfsdfsdfsdf</transactionKey>
</merchantAuthentication>
<refId>155969e50PGj</refId>
<subscriptionId>234324</subscriptionId>
<subscription>
<amount>75</amount>
<customer>
<id>155969</id>
<email></email>
<phoneNumber></phoneNumber>
</customer>
<billTo>
<firstName></firstName>
<lastName></lastName>
<company></company>
<address></address>
<city></city>
<state></state>
<zip></zip>
<country></country>
</billTo>
<shipTo>
<firstName></firstName>
<lastName></lastName>
<company></company>
<address></address>
<city></city>
<state></state>
<zip></zip>
<country></country>
</shipTo>
</subscription>
</ARBUpdateSubscriptionRequest>
I got the following error :
<?xml version="1.0" encoding="utf-8"?>
<ARBUpdateSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<refId>155969e50PGj</refId>
<messages>
<resultCode>Error</resultCode>
<message>
<code>E00014</code>
<text>Bill-To First Name is required.</text>
</message>
<message>
<code>E00014</code>
<text>Bill-To Last Name is required.</text>
</message>
</messages>
</ARBUpdateSubscriptionResponse>
ARBUpdateSubscriptionRequest is required other XML in request
<?xml version="1.0" encoding="utf-8"?>
<ARBUpdateSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>mytestacct</name>
<transactionKey>112223344</transactionKey>
</merchantAuthentication>
<refId>Sample</refId>
<subscriptionId>100748</subscriptionId>
<subscription>
<payment>
<creditCard>
<cardNumber>4111111111111111</cardNumber>
<expirationDate>2010-08</expirationDate>
</creditCard>
</payment>
</subscription>
</ARBUpdateSubscriptionRequest>