How to get the rate of a specific service - EasyPost ruby? - ruby

Trying to retrieve shipping rates for India Post but do not know how. I'm following the Getting Started guide.
to_address = EasyPost::Address.create(
:name => 'Dr. Steve Brule',
:street1 => 'Ravindra Nath Tagore Marg',
:city => 'Nagpur',
:zip => '440001',
:country => 'IN',
:phone => '310-808-5243'
)
from_address = EasyPost::Address.create(
:company => 'Bera',
:street1 => 'Johari Bazar 14',
:city => 'Jaipur',
:country => 'IN',
:zip => '302003',
:phone => '911800112011'
)
parcel = EasyPost::Parcel.create(
:width => 15.2,
:length => 18,
:height => 9.5,
:weight => 35.1
)
shipment = EasyPost::Shipment.create(
:to_address => to_address,
:from_address => from_address,
:parcel => parcel,
)
rate = shipment.lowest_rate(carriers = ['India Post'], services = ['First'])
Shipment do not include any rate can't figure out what is not right in this example.

Have you added an India Post carrier account through the EasyPost Dashboard. The Getting Started Guide does explain:
Note: Unless you've entered your carrier information for other carriers, you'll just receive USPS rates.
If you want a Shipment to only return rates for one carrier, pass that carrier account ID along with the Shipment.create call.
You can limit the CarrierAccounts to use for rating by passing the carrier_accounts parameter [source]
EasyPost currently only supports Tracking for IndiaPost as you can see on this page.
In the future, try emailing support#easypost.com for the best advice.

Related

ruby on rails using the paypal gem don' return the payer id

I want to user the paypal gem for ruby on rails to do the paying stuff with.
Most of the suff works fine, but I don't get the payer ID, for the last step the payment.execute() I need the payerID
my code looks like this:
##################################################################################
# Build Payment object
#payment = Payment.new({
:intent => "sale",
:payer => {
:payment_method => "paypal"
},
:redirect_urls => {
:return_url => url_for(:controller=>:movies,:action=>:play,:id=>#movie.id),
:cancel_url => url_for(:controller=>:movies,:action=>:play,:id=>#movie.id)},
:transactions => [{
:item_list => {
:items => [{
:name => #movie.movietitle,
:sku => "item",
:price => #movie.movieprice,
:currency => "USD",
:quantity => 1 }]},
:amount => {
:total => #movie.movieprice,
:currency => "USD" },
:description => "This is the payment transaction description." }]})
# Create Payment and return the status(true or false)
if #payment.create
#payment.id # Payment Id
redirect_to #payment.links[1].href
else
#payment.error # Error Hash
end
how can I get the payerID?
Thanks

Recurring payment in paypal integration with codeigniter is not working

Hello I am new to PayPal integration. I am using the Express checkout of PayPal for payment.
I wrote the code use SetExpressCheckout method then GetExpressCheckout method and then use DoExpressCheckout method. After DoExpressCheckout I am calling the CreateRecurringPaymentsProfile for recurring payment. Code as follows-
$recurringdata = array(
'TOKEN' => $token,//token id
'PayerID' => $payerid,//payer id
'PROFILESTARTDATE' => date('Y-m-d H:i:s',$time),
'DESC' => "description",
'BILLINGPERIOD' => 'Day',
'BILLINGFREQUENCY' => 1,
'AMT' =>$checkoutDetails['PAYMENTREQUEST_0_AMT'],
'TRIALBILLINGPERIOD'=>'Day',
'TRIALBILLINGFREQUENCY'=>1,
'TRIALAMT'=> 0,
'CURRENCYCODE' => 'USD',
'COUNTRYCODE' => 'US',
'MAXFAILEDPAYMENTS' =>3
);
$responserecurring = $paypal->request('CreateRecurringPaymentsProfile', $recurringdata);
This code creates the profile but I can not see that any recurring payment is done. I am not getting what actually happens. Is am I missing to pass any parameter in request.
Actually i am missing the one parameter i.e. 'TRIALTOTALBILLINGCYCLES'. This parameter is an optional so i am not used this. So my trail period goes in infinite state. So payment is not deducting from account.I pass the data like as_
$recurringdata = array(
'TOKEN' => $token,//token id
'PayerID' => $payerid,//payer id
'PROFILESTARTDATE' => date('Y-m-d H:i:s',$time),
'DESC' => "description",
'BILLINGPERIOD' => 'Day',
'BILLINGFREQUENCY' => 1,
'AMT' =>$checkoutDetails['PAYMENTREQUEST_0_AMT'],
'TRIALBILLINGPERIOD'=>'Day',
'TRIALBILLINGFREQUENCY'=>1,
'TRIALAMT'=> 0,
'TRIALTOTALBILLINGCYCLES' => 1,
'CURRENCYCODE' => 'USD',
'COUNTRYCODE' => 'US',
'MAXFAILEDPAYMENTS' =>3
);
$responserecurring = $paypal->request('CreateRecurringPaymentsProfile', $recurringdata);

Can't get value from nested pair in Omniauth hash.

I'll try to keep this simple, my previous wording was maybe a bit too verbose:
Here is the example Omniauth hash: https://github.com/mkdynamic/omniauth-facebook
I can access and save some values from this but not others. The field is writable, so I know its just my syntax (beginner, sorry!)
{
:provider => 'facebook',
:uid => '1234567',
:info => {
:nickname => 'jbloggs',
:email => 'joe#bloggs.com',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
:image => 'http://graph.facebook.com/1234567/picture?type=square',
:urls => { :Facebook => 'http://www.facebook.com/jbloggs' },
:location => 'Palo Alto, California',
:verified => true
},
:credentials => {
:token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
:expires_at => 1321747205, # when the access token expires (it always will)
:expires => true # this will always be true
},
:extra => {
:raw_info => {
:id => '1234567',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',
:link => 'http://www.facebook.com/jbloggs',
:username => 'jbloggs',
:location => { :id => '123456789', :name => 'Palo Alto, California' },
:gender => 'male',
:email => 'joe#bloggs.com',
:timezone => -8,
:locale => 'en_US',
:verified => true,
:updated_time => '2011-11-11T06:21:03+0000'
}
}
}
I can do this to get gender and save it.
location:auth.extra.raw_info["gender"]
Obviously though I dont want to save gender to location. I want to get "Palo Alto" and save it. But this doesn't work.
location.auth.extra.raw_info["location"]["name"]
What am I doing wrong? When I try it in console, I'm able to get the value.
try this
location.auth.extra.raw_info.location.name
or this
location.auth.extra.raw_info[:location][:name]
Yeah, what you suggested was what I was trying...and it turns out we were right but FB had changed how that hash was set up so it wasn't working. Lesson learned: subscribe FB's notifications next time :)

Adding address to mailchimp using Gibbon gem

Im using the gibbon 0.4.6 with ruby 1.9.3p392, and I tried to add the address of my contacts but I couldn't find the correct format of the parameters.
respuesta = gb.listSubscribe({
:id => lista_id, :email_address => email,
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => ['addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF',
'zip' => '06700', 'country' => 'MX']
}
})
Update
As Amro suggested, now Im using Gibbon 1.0, but I have the same problem:
I used this
respuesta = gb.lists.subscribe({
:id => lista_id, :email => {:email => email},
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF', 'zip' => '06700', 'country' => 'MX'},
'MMERGE4' => 'Mi nota '
}
})
But the address(MMERGE3) wasn't registered at MailChimp.
Any idea is welcome.
Your current code looks reasonable to me. Have you tried also passing "update_existing" with a value of true? If that address is already subscribed then it won't work otherwise since "update_existing" defaults to false.
Old Answer for API 1.3
I'm Gibbon's maintainer. In this case, MailChimp's docs say the type is an "array," but they mean an associative array (i.e. a Ruby hash). So try something like this:
respuesta = gb.listSubscribe({
:id => lista_id, :email_address => email,
:merge_vars => {'FNAME' => nombre, 'LNAME' => apellido,
'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF',
'zip' => '06700', 'country' => 'MX'}
}
})
Also, API 1.3 has been deprecated. I suggest upgrading to Gibbon 1.0, which hits MailChimp API 2.0. The syntax is a little different so be sure to check out the 2.0 docs and Gibbon's updated README here.

Using Typhoeus to POST an array to a URL

I'm using Typhoeus to post a hash to my API url. It's actually an array containing a set of hashes. Here's effectively what I'm doing:
companies = Array.new
company = { 'name' => 'Company 1' , 'company_url' => 'http://company.com' }
companies.push(company)
company2 = {'name' => 'Company 2' , 'company_url' => 'http://company2.com' }
companies.push(company2)
request = Typhoeus::Request.post("http://myapi.com/1.0/startups/create_batch",
:username => 'user',
:password => 'password',
:auth_method => :basic,
:params => {'companies' => companies} )
print "Create_batch response "+request.body
Once I run the script I get the output which states "Create_batch response Disallowed Key Characters.". I'm not sure what it's referencing at this point. I've looked over the text output of what print companies shows up but I don't see any strange code.
Anybody have any insights on what I should do?

Resources