I am trying to use Ruby on Rails to create a SOAP request to the EchoSign API but I am getting an error saying one of the fields is blank:
{http://dto14.api.echosign}RecipientRole: cannot accept ''
This is the code I am using:
require 'soap/wsdlDriver'
require 'base64'
filename = 'quote'
recipient = 'martin#domain.co.uk'
quote_id = params[:id]
$S = SOAP::WSDLDriverFactory.new("https://secure.echosign.com/services/EchoSignDocumentService16?wsdl").create_rpc_driver
r = $S.sendDocument(
:apiKey => 'XXXXXXXXXXX',
:senderInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:documentCreationInfo => {
:fileInfos => [{
:file => RAILS_ROOT + '/pdfs/' + quote_id + '.pdf',
:fileName => filename,
}],
:recipients =>
[{ :RecipientInfo => [{
:email => 'martin#domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}]
}],
:message => "This is neat.",
:name => "Test from SOAP-Lite: " + filename,
:reminderFrequency => "WEEKLY_UNTIL_SIGNED",
:signatureFlow => "SENDER_SIGNATURE_NOT_REQUIRED",
:signatureType => "ESIGN",
:callbackInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:ccs => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:externalId => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:securityOptions => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
}
)
There must obviously be something wrong with the way I am doing the
:recipients =>
[{ :RecipientInfo => [{
:email => 'martin#domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}]
}],
but I am finding it extremely difficult to find what just from the documentation, I think it will be something silly but can't spot it.
update
after looking more closely at the example request I tried the following but it made no difference:
require 'soap/wsdlDriver'
require 'base64'
filename = 'quote'
quote_id = params[:id]
$S = SOAP::WSDLDriverFactory.new("https://secure.echosign.com/services/EchoSignDocumentService16?wsdl").create_rpc_driver
r = $S.sendDocument(
:apiKey => 'XXXXXXXXXXX',
:senderInfo => SOAP::SOAPNil.new,
:documentCreationInfo => {
:fileInfos => {
:FileInfo => {
:file => RAILS_ROOT + '/pdfs/' + quote_id + '.pdf',
:fileName => filename
}
},
:recipients => {
:RecipientInfo => {
:email => 'martin#domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}
},
:mergeFieldInfo => SOAP::SOAPNil.new,
:tos => SOAP::SOAPNil.new,
:message => "This is neat.",
:name => "Test from SOAP-Lite: " + filename,
:reminderFrequency => "WEEKLY_UNTIL_SIGNED",
:signatureFlow => "SENDER_SIGNATURE_NOT_REQUIRED",
:signatureType => "ESIGN",
:callbackInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:ccs => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:externalId => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:securityOptions => SOAP::SOAPNil.new # we need to explicitly set elements to nil
}
)
Can you please try to pass the value SIGNER with double quotations like "SIGNER". Just like you have for "ESIGN" and some other parameters.
Also, if sending for ESIGN, Fax should not need to be nil . Try to not defining :Fax at all.
You should change the email address and the role to have double quotes instead of single quotes.
:RecipientInfo => {
:email => "martin#domain.co.uk",
:fax => SOAP::SOAPNil.new,
:role => "SIGNER" change
Same as you have done for
:reminderFrequency => "WEEKLY_UNTIL_SIGNED",
:signatureFlow => "SENDER_SIGNATURE_NOT_REQUIRED",
Related
I am trying to add a bank account using Ruby stripe API. but it gives the stripe error "Missing required param: type".
I am using following ruby code:
account = Stripe::Account.create({
:country => 'US',
:managed => true,
:transfer_schedule => {
:interval => 'weekly',
:weekly_anchor => 'friday'
},
:legal_entity => {
:dob => {
:day => birthday.day,
:month => birthday.month,
:year => birthday.year
},
:first_name => first_name,
:last_name => last_name,
:type => 'individual'
},
:tos_acceptance => {
:date => Time.now.to_i,
:ip => request.remote_ip
}
})
You are not passing the proper parameters to the API.
Please check this document for the proper request and response returned by Stripe.
https://stripe.com/docs/api?lang=ruby#create_account
require "stripe"
Stripe.api_key = "sk_test_bcd1234"
Stripe::Account.create(
:type => 'standard',
:country => 'US',
:email => 'bob#example.com'
)
To point out you are not passing :type param in the outer hash. You need to move it to the first level.
account = Stripe::Account.create(
{
:country => 'US',
:managed => true,
:type => 'individual', # Move this from nested to first level
:transfer_schedule => {
:interval => 'weekly',
:weekly_anchor => 'friday'
},
:legal_entity => {
:dob => {
:day => birthday.day,
:month => birthday.month,
:year => birthday.year
},
:first_name => first_name,
:last_name => last_name
},
:tos_acceptance => {
:date => Time.now.to_i,
:ip => request.remote_ip
}
}
)
I would like to know how to obtain the country and state, from the billing address, in a paypal transaction.
So far I can get a transaction object via the code below:
# ...
def self.paypal_transaction_details(txn_id)
#api = PayPal::SDK::Merchant.new
get_transaction_details = #api.build_get_transaction_details({:TransactionID => txn_id })
response = #api.get_transaction_details(get_transaction_details)
end
Is it possible to get the location info? Or should I use geocoder to get the country and state from the ip address?
Reference: https://github.com/paypal/merchant-sdk-ruby
Response:
response.PaymentTransactionDetails.PayerInfo.Address
=> #<PayPal::SDK::Merchant::DataTypes::AddressType:0x007fd58f604660 #AddressOwner="PayPal", #AddressStatus="None">
Thanks in advance
I am not sure if you are using this gem 'paypal-sdk-rest'
but if you are, when you Create Payment
you can do
require 'paypal-sdk-rest'
include PayPal::SDK::REST
PayPal::SDK::REST.set_config(
:mode => "sandbox", # "sandbox" or "live"
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM")
# Build Payment object
#payment = Payment.new({
:intent => "sale",
:payer => {
:payment_method => "credit_card",
:funding_instruments => [{
:credit_card => {
:type => "visa",
:number => "4567516310777851",
:expire_month => "11",
:expire_year => "2018",
:cvv2 => "874",
:first_name => "Joe",
:last_name => "Shopper",
:billing_address => {
:line1 => "52 N Main ST",
:city => "Johnstown",
:state => "OH",
:postal_code => "43210",
:country_code => "US" }}}]},
:transactions => [{
:item_list => {
:items => [{
:name => "item",
:sku => "item",
:price => "1",
:currency => "USD",
:quantity => 1 }]},
:amount => {
:total => "1.00",
: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
else
#payment.error # Error Hash
end
I hope that this helps.
ps.
you have to request the info first, if not there would be nil or '' when you want to get them back
Quick ruby question regarding the manipulation of a Hash in Ruby.
I actually have the following hash:
[2] project(#<V1::UsersController>) » error.info
=> {
:id => "914a24888-5e71-4d12-b9b0-10e2d98f516b",
:game => "vampotron",
:data => {
"private" => {
"name" => "Jean",
"logins" => 2300,
"foo" => "bar"
}
},
:revision => 1
}
I want the hash to become:
[2] project(#<V1::UsersController>) » error.info
=> {
:id => "914a24888-5e71-4d12-b9b0-10e2d98f516b",
:game => "vampotron",
:data => {
"name" => "Jean",
"logins" => 2300,
"foo" => "bar"
},
:revision => 1
}
I would like to remove the 'private' key by keeping the existing k,v pairs in my 'data' hash.
Thanks for your help,
M
The easiest way
hash[:data] = hash[:data]['private']
I'm creating an Rails application that must make use Paypal MassPayment API (adaptive payments is Not a option in our case).
I'm using the 'paypal-sdk-merchant' https://github.com/paypal/merchant-sdk-ruby
Following the sample suggested in
https://paypal-sdk-samples.herokuapp.com/merchant/mass_pay
I'm able to create a "mass payment" with ONE receiver:
#api = PayPal::SDK::Merchant::API.new
# Build request object
#mass_pay = #api.build_mass_pay({
:ReceiverType => "EmailAddress",
:MassPayItem => [{
:ReceiverEmail => "enduser_biz#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "3.00" } }] })
# Make API call & get response
#mass_pay_response = #api.mass_pay(#mass_pay)
# Access Response
if #mass_pay_response.success?
else
#mass_pay_response.Errors
end
The problem is: how can I build a mass pay object with multiple receiver?
Following the documentation, I tried the following code with a number of variations, but Paypal seems to considers only the last item:
#api = PayPal::SDK::Merchant::API.new
# Build request object
#mass_pay = #api.build_mass_pay({
:ReceiverType0 => "EmailAddress",
:MassPayItem0 => [{
:ReceiverEmail => "enduser_biz#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "3.00" } }],
:ReceiverType1 => "EmailAddress",
:MassPayItem1 => [{
:ReceiverEmail => "enduser_biz1#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "5.00" } }]
}
)
(...)
Also, I have an array of emails and values, so I need to all them in the mass pay, how can it be done?
Ideally, I would like something:
#mass_pay = build_mass_pay_with_array_of_email_and_values([ARRAY_OF_EMAILS_AND_VALUES_HERE])
The syntax is sort of like JSON would be. [] is an array, you would add more members to that MassPayItem array:
:MassPayItem => [{
:ReceiverEmail => "enduser_biz#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "3.00"
}
},
{
:ReceiverEmail => "enduser_biz2#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "1.00"
}
}]
ending up with:
require 'paypal-sdk-merchant'
#api = PayPal::SDK::Merchant::API.new
# Build request object
#mass_pay = #api.build_mass_pay({
:ReceiverType => "EmailAddress",
:MassPayItem => [{
:ReceiverEmail => "enduser_biz#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "3.00"
}
},
{
:ReceiverEmail => "enduser_biz2#gmail.com",
:Amount => {
:currencyID => "EUR",
:value => "1.00"
}
}]
})
# Make API call & get response
#mass_pay_response = #api.mass_pay(#mass_pay)
# Access Response
if #mass_pay_response.success?
else
#mass_pay_response.Errors
end
require 'paypal-sdk-merchant'
#api = PayPal::SDK::Merchant::API.new
#make an array of members
member_list = []
member_list << {
:ReceiverEmail => 'someone#example.com',
:Amount => {
:currencyID => "USD",
:value => 1.6
}
}
member_list << {
:ReceiverEmail => 'someone2#example.com',
:Amount => {
:currencyID => "USD",
:value => 1.6
}
}
# Build request object
#mass_pay = #api.build_mass_pay(member_list)
# Make API call & get response
#mass_pay_response = #api.mass_pay(#mass_pay)
# Access Response
if #mass_pay_response.success?
else
#mass_pay_response.Errors
end
I want ElasticSearch (Tire gem to be specific) to return the result based on the number of times a keyword appears in the fields. For example, I index the field title in a model called Article. I have two objects, the first object has the title value 'Funny Funny subject' while the second object has the title value 'Funny subject'. I want to index in such a way that if I search for the keyword 'Funny', the first object will return first since it has two 'Funny' words appearing in the title. Is it possible to do this via Tire? What is the indexing method called as well?
Here a working sample, the key factor here is the boostvalue that has to be high enough and you can't use wildcharts in the query.
require 'tire'
require 'yajl/json_gem'
articles = [
{ :id => '0', :type => 'article', :title => 'nothing funny'},
{ :id => '1', :type => 'article', :title => 'funny'},
{ :id => '2', :type => 'article', :title => 'funny funny funny'}
]
Tire.index 'articles' do
import articles
end
Tire.index 'articles' do
delete
create :mappings => {
:article => {
:properties => {
:id => { :type => 'string', :index => 'not_analyzed', :include_in_all => false },
:title => { :type => 'string', :boost => 50.0, :analyzer => 'snowball' },
:tags => { :type => 'string', :analyzer => 'keyword' },
:content => { :type => 'string', :analyzer => 'snowball' }
}
}
}
import articles do |documents|
documents.map { |document| document.update(:title => document[:title].downcase) }
end
refresh
end
s = Tire.search('articles') do
query do
string "title:funny"
end
end
s.results.each do |document|
puts "* id:#{ document.id } #{ document.title } score: #{document._score}"
end
gives
* id:2 funny funny funny score: 14.881571
* id:1 funny score: 14.728935
* id:0 nothing funny score: 9.81929