I am trying to integrate UPS SurePost API in PHP to get the Rates for SurePost services.
I have no idea where to get the API from and how to integrate it.
Any help would be greatly appreciated.
Thanks
Jayesh Vaya's answer is correct, but here is further detail. There are 4 separate service codes for SurePost rates.
92: UPS SurePost Less than 1LB
93: UPS SurePost 1LB or greater
94: UPS SurePost BPM
95: UPS SurePost Media Mail
When shipping with service code 92, the unit of measure of the package weight must be in ounces instead of pounds, rounded to the tens decimal place.
I found that the ounces unit of measure code was "OZS".
Note that your account with UPS must be enabled to ship with SurePost. The documentation for the SurePost Web Services API is available upon request from your UPS account executive.
Here is the UPS documentation for using their API:
Rating Service API
I hope this helps anyone who wasn't sure how to start, like I was yesterday! :)
Service Code 93 Is for Surepost
<AccessLicenseNumber>xxxx</AccessLicenseNumber>
<UserId>xxxx</UserId>
<Password>xxxx</Password>
</AccessRequest>
<RatingServiceSelectionRequest>
<Request>
<TransactionReference>
<CustomerContext>Bare Bones Rate Request</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>Rate</RequestAction>
<RequestOption>Rate</RequestOption>
</Request>
<PickupType>
<Code>02</Code>
</PickupType>
<Shipment>
<Shipper>
<Address>
<PostalCode>123456</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<ShipperNumber>123456</ShipperNumber>
</Shipper>
<ShipTo>
<Address>
<PostalCode>123123</PostalCode>
<StateProvinceCode>AL</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<Address>
<PostalCode>123123</PostalCode>
<StateProvinceCode>123</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>93</Code>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
</PackagingType>
<Description>Rate Shopping</Description>
<Dimensions><UnitOfMeasurement><Code>IN</Code></UnitOfMeasurement><Length>20</Length><Width>10</Width><Height>10</Height></Dimensions>
<PackageWeight><UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>20.20</Weight>
</PackageWeight>
</Package>
<RateInformation><NegotiatedRatesIndicator/></RateInformation></Shipment></RatingServiceSelectionRequest>
Update 2021
It is interesting that SurePost is out of the list of service codes in the official docs.
So the only info about the service code of this method is this topic.
Thanks for that!
🙌
The mentioned 9x codes are working now.
And yes, you need to switch from the Shop request option to the Rate to fetch rates for a needed code with additional Service block (example for the JSON API:
"Service": {
"Code": "93",
"Description": ""
}
To ship packages via UPS SurePost service, you must first have a UPS Account along with a UPS Developer Account to gain access to their XML API.
https://www.ups.com/upsdeveloperkit
The example by #ayesh is the format of the xml payload you would send with your request for Rates, which with the correct SERVICE CODES, will return SurePost specific rates (if available to your ShipTo destination).
But ...
SurePost is not normally available to low volume UPS shippers and probably wouldn't be available to new shippers (not until enough volume is determined by UPS). SurePost must be added to an existing UPS account, which is done by contacting UPS and filling out additional applications.
Hope that helps!
Related
Using JSON HTTP POST; what online service do I best use to broadcast a Bitcoin Cash transaction?
I'm looking for the equivalent of https://blockchain.info/pushtx
There are a few options to broadcast a transaction for Bitcoin and Bitcoin-Cash. The first, but also the most expensive in terms of time, is to setup a BitcoinABC node on your machine and let it sync. Once that's done you can simply call the sendrawtransaction API call and it'll get pushed to other nodes in the network.
The second option is to use Wladimir's bitcoin-submittx tool to connect to a number of nodes and submit the transaction to them. This tool was originally written for Bitcoin, but works also for Bitcoin-Cash. It requires a number of node addresses, but you can use the DNS seeds to get some:
python2 bitcoin-submittx mainnet ${TXHEX} $(dig seed-abc.bitcoinforks.org)
This should submit the TX to some random nodes in the network.
https://rest.bitcoin.com provides a REST API for broadcasting transactions. This BITBOX code example shows how to construct a BCH transaction then broadcast it using rest.bitcoin.com:
https://github.com/Bitcoin-com/bitbox-javascript-sdk/blob/master/examples/applications/wallet/send-bch/send-bch.js
In particular, look at the last few lines of the example:
// Broadcast transation to the network
const broadcast = await BITBOX.RawTransactions.sendRawTransaction(hex)
console.log(`Transaction ID: ${broadcast}`)
API documentation:
https://developer.bitcoin.com/bitbox/docs/getting-started
If you already have the raw hex and you want a manual way to broadcast it, you can go directly to the endpoint on rest.bitcoin.com, and paste in the hex:
https://rest.bitcoin.com/#/rawtransactions/sendRawTransaction
Question
Is it possible to get rates for all possible ups services in the same request?
Background
Although the UPS rates documentation states that the service element is optional
Requests with the service element defined respond successfully while requests without the element defined result in the following error:
["Error"]=>
array(3) {
["ErrorSeverity"]=>
string(4) "Hard"
["ErrorCode"]=>
string(6) "111100"
["ErrorDescription"]=>
string(58) "The requested service is invalid from the selected origin."
}
Additionally, every example and library i've seen either only desired to create requests for one type of service or creates a request for each service the user specifies they want to receive:
// optional, you can specify which rates to look for -- performs multiple requests, so be careful not to do too many
In Summary
Is there a way to return rates for all services from UPS that I am missing or must we query UPS for each service we wish to get a rate for?
You should be able to receive rates for multiple services by setting the /RateRequest/Request/RequestOption to Shop and omitting the /RateRequest/Shipment/Service element.
This is outlined in UPS's documentation for the Rate Webservice endpoints:
Can a customer compare services for a shipment using the Rating API?
Yes. Use the “Shop” value, instead of the “Rate” value, in the RequestOption element of the ../Request container to retrieve the rates for all services for the stated lane pair. The API response will return a rate for each of the available services. This is known as the Shop option.
I'm looking into integrating Apple Pay into a website using the new Apple Pay JS SDK. The documentation is currently pretty minimal, concerning just the API declarations and how to instantiate a new ApplePaySession object.
Is there any example code available yet, or has anyone actually implemented this themselves yet, showing the typical API integration flow for a web application?
The only examples I've been able to find anything for all appear to be for third-party payment providers' own SDK integrations of Apple Pay.
I've published end-to-end ApplePayJS example code on github here
https://github.com/norfolkmustard/ApplePayJS
It uses PHP for the server-side part, needed for the initial vendor validation to begin the transaction. The rest is in javascript.
ApplePayJS != cash in the bank, just a means of getting a tokenised credit card from a customer. You hand that card number off to a third-party payment processor like stripe.com, braintreepayments.com, authorize.net
Cheers
The stable release will be available this fall probably.
First thing you want to do is to ensure that API is available in your browser:
if(ApplePaySession)
ApplePaySession.canMakePayments()
Then the transaction itself:
var request = {
countryCode: 'US',
currencyCode: 'USD',
supportedNetworks: ['visa', 'masterCard'],
merchantCapabilities: ['supports3DS'],
total: { label: 'Your Label', amount: '10.00' },
}
var session = new ApplePaySession(1, request);
This is from official website how to get it started: https://developer.apple.com/reference/applepayjs/applepaysession
After you have the session, you can control it:
And you can listen to events, and change your flow based on it:
I'm working on the integration between Apple Pay JS and Stripe API right now, so I'll release draft version to GitHub this summer.
The integration I've been working on has now finally been released, and there's a blog post I've written to go along with it as well as a GitHub project with an example integration using ASP.NET Core.
I hope others doing an Apple Pay JS integration themselves find it useful.
Been doing some research on how to setup an SMS alert straight to the website owner's (our customer) phone when a website visitor fills in a form on his website. Obviously we're happy to sign up to a provider and pay a few cents for each message - not expecting this to be a freebie service.
A lot of the google results you get for this deal with bulk texting out to the many recipients which isn't what we're looking at here.
So what's the simplest small-scale way to achieve this via HTML and simple scripting?
This daniweb forum post offers clear and simple instructions using Coldfusion and that's fine but as it's 7 years old we wonder if things have moved on and are there better suggestions?
We'd be happy to script it very simply through ASP.NET or PHP or something else, but hoping to keep it lightweight, since this is a very simple website belonging to a small business.
I am working on a similar thing for my company.
We use a GSM modem such as: ZTE MF668A
It is a USB adapter which you can insert a SIM card into.
We purchased an SMS only plan, which is like $15 a month and you can send unlimited SMS. However the set up might be a bit more complicated than just using a bulk SMS service.
You can set up Diafaan SMS Server (http://www.diafaan.com/) on the computer with the GSM Modem to accept emails for a particular domain. (e.g. ours is #sms.com). Our exchange server forwards email to the Diafan Server. Diafaan will take the email and convert it to an SMS and send it using the GSM modem.
In you php code, you can use PHPMailer (http://phpmailer.worxware.com/) to construct an email and set the mail to address to be #sms.com.
You use it something like this:
ini_set("sendmail_from","user#company.com");
ini_set("SMTP","smtp.company.com");
require("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.company.com"; // specify main and backup server
$mail->SMTPAuth = false; // turn on SMTP authentication
//$mail->Username = "name"; // SMTP username
//$mail->Password = "password"; // SMTP password
$mail->From = "user#company.com";
$mail->FromName = $salesPerson;
$mail->AddAddress("user2#company.com", "Pricing");
$mail->AddReplyTo("user#company.com", "User2");
$mail->AddBcc($salesPersonEmail, $salesPerson);
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
There are also companies that offer SMS services such as PCSMS where you get 100 SMS per month for a fee. Then you just construct an email and send it to #pcsms.com.au. This is probably the easiest way to do it and is the way we used to do it, but the way we do it now is much cheaper.
Disclaimer, I do developer evangelism part time at Nexmo.
While you can setup a GSM modem to send SMS messages, it's likely easier (and depending on your usage, cheaper) to use a SMS API. Here are a few providers - pricing is in cents per message (depends on the API and destination, but hovers around a cent or two). You may be required to provision a virtual number - pricing there is generally dollars/month (again, depends on API and destination, hovers around a dollar or two).
Nexmo
Twilio
Tropo
If you're sending internationally, I think your best would be Nexmo. Or if you see any need to accept incoming messages in the future, Nexmo's pricing model will help you there.
All three APIs are straight forward REST/HTTP APIs - as long as whatever language you're using server side can make a web request, you should be able to send an SMS.
Eventually we used Esendex. Good support from them, decent code samples and plenty of mileage in the free trial (which in fact they were happy to extend when we asked).
i'm building a web crawler and i'm trying to figure out where is a web page from. I mean, i can check the domain (for example, .com.ar ar from Argentina) but there are other sites, that have other domains (.com, .net) that are argentinean too, an example of these is www.taringa.net. Is an Argentinean site but with a .net domain.
So how can i do it?
Thanks.
Geo-location by IP. Do a reverse
look-up on the IP address, and you can
get a geographical location. These
services cost money, and will only
tell you physically where the server
is hosted.
Do a whois on the domain. It will
tell you the where the website is
registered.
But remember,
There is no meaning to "where is a web page from". The web has no geographic boundaries. I can run a Spanish language site out of San Jose California, and register the domain contacts in Canada. You will have no way of knowing my site is aimed at Chilean users.
You can use a whois query on the command line - or make a request to whois.arin.net and whois.xxxx.xxx depending on the result. If I map www.taringa.net to an IP, I get this:
www.taringa.net. 300 IN A 190.210.132.53
and running whois on that:
whois 190.210.132.53
gives me a ton of output:
inetnum: 190.210.132/24
status: reallocated
owner: WIROOS SRL
ownerid: AR-WISR1-LACNIC
responsible: ALBERTO NAKAYAMA
address: GRAL MIGUEL DE AZCUENAGA, 71, 4 A
address: C1029AAA - BUENOS AIRES -
country: AR
phone: +54 011 30973059 [3059]
This should generally work for any ip.