Authorize.net (CIM) Create customer profile with ruby on rails - ruby-on-rails

Create customer payment profile using API.
Getting error:
E00003
The element 'paymentProfiles' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' cannot contain text. List of
possible elements expected: 'customerType, billTo, payment,
driversLicense, taxId, defaultPaymentProfile' in namespace
'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
Request to Authorize.net
<AuthorizeNet::API::CreateCustomerProfileRequest:0x007fc91d9e48a8 #merchantAuthentication=nil, #refId=nil, #profile=#<AuthorizeNet::API::CustomerProfileType:0x007fc91d9e4880 #merchantCustomerId="jdoe6607", #description="John2 Doe", #email="2686#mail.com", #paymentProfiles=[#<AuthorizeNet::API::CustomerPaymentProfileType:0x007fc91d9e4ab0 #customerType="individual", #billTo=#<AuthorizeNet::API::CustomerAddressType:0x007fc91d9e4c68 #firstName="Ellen", #lastName="Johnson", #company="Souveniropolis", #address="14 Main Street", #city="Pecan Springs", #state="TX", #zip="44628", #country="US", #phoneNumber="999-999-9999", #faxNumber="999-999-9999">, #payment=#<AuthorizeNet::API::PaymentType:0x007fc91d9e4d80 #creditCard=#<AuthorizeNet::API::CreditCardType:0x007fc91d9e4da8 #cardNumber="4111111111111111", #expirationDate="2020-05", #cardCode="111", #isPaymentToken=nil, #cryptogram=nil>, #bankAccount=nil, #trackData=nil, #encryptedTrackData=nil, #payPal=nil, #opaqueData=nil>, #driversLicense=nil, #taxId=nil>], #shipToList=[#<AuthorizeNet::API::CustomerAddressType:0x007fc91d9e4a60 #firstName="John", #lastName="Snow", #company="Night's Watch, Inc.", #address="Castle Black", #city="The Wall", #state="North Westeros", #zip="99499", #country="Westeros", #phoneNumber="999-999-9999", #faxNumber="999-999-9999">]>, #validationMode="liveMode">
Code:
transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
payment = PaymentType.new(CreditCardType.new)
payment.creditCard.cardNumber = '4111111111111111'
payment.creditCard.expirationDate = '2020-05'
billTo = CustomerAddressType.new
billTo.firstName = "Ellen"
billTo.lastName = "Johnson"
billTo.company = "Souveniropolis"
billTo.address = "14 Main Street"
billTo.city = "Pecan Springs"
billTo.state = "TX"
billTo.zip = "44628"
billTo.country = "US"
billTo.phoneNumber = "999-999-9999"
billTo.faxNumber = "999-999-9999"
paymentProfile = CustomerPaymentProfileType.new
paymentProfile.payment = payment
paymentProfile.billTo = billTo
shippingAddress = CustomerAddressType.new
shippingAddress.firstName = "John"
shippingAddress.lastName = "Snow"
shippingAddress.company = "Night's Watch, Inc."
shippingAddress.address = "Castle Black"
shippingAddress.city = "The Wall"
shippingAddress.state = "North Westeros"
shippingAddress.zip = "99499"
shippingAddress.country = "Westeros"
shippingAddress.phoneNumber = "999-999-9999"
shippingAddress.faxNumber = "999-999-9999"
request = CreateCustomerProfileRequest.new
request.profile = CustomerProfileType.new
request.profile.merchantCustomerId = 'jdoe' + rand(10000).to_s
request.profile.description = 'John2 Doe'
request.profile.email = rand(10000).to_s + '#mail.com'
request.profile.paymentProfiles = [paymentProfile]
request.profile.shipToList = [shippingAddress]
request.validationMode = ValidationModeEnum::LiveMode
response = transaction.create_customer_profile(request)

Related

Attemp to index a nill value

can anybody help me, please. I really don't know what to do... i tried everything,
Attemp to index a nill value (field, ?) at this line
PhoneData.Chats[NumberKey].messages = ChatMessages
RegisterNetEvent('ttpPhone:client:UpdateMessages', function(ChatMessages, SenderNumber, New)
local NumberKey = GetKeyByNumber(SenderNumber)
print(NumberKey)
if New then
PhoneData.Chats[#PhoneData.Chats+1] = {
name = IsNumberInContacts(SenderNumber),
number = SenderNumber,
messages = {},
}
NumberKey = GetKeyByNumber(SenderNumber)
PhoneData.Chats[NumberKey] = {
name = IsNumberInContacts(SenderNumber),
number = SenderNumber,
messages = ChatMessages
}
if PhoneData.Chats[NumberKey].Unread ~= nil then
PhoneData.Chats[NumberKey].Unread = PhoneData.Chats[NumberKey].Unread + 1
print(NumberKey)
else
print(NumberKey)
PhoneData.Chats[NumberKey].Unread = 1
end
if PhoneData.isOpen then
if SenderNumber ~= PhoneData.PlayerData.number then
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "New message from "..IsNumberInContacts(SenderNumber).."!",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 1500,
},
})
else
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "Messaged yourself",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 4000,
},
})
end
NumberKey = GetKeyByNumber(SenderNumber)
ReorganizeChats(NumberKey)
print(NumberKey)
Wait(100)
wrPhone.TriggerServerCallback('ttpPhone:server:GetContactPictures', function(Chats)
SendNUIMessage({
action = "UpdateChat",
chatData = Chats[GetKeyByNumber(SenderNumber)],
chatNumber = SenderNumber,
Chats = Chats,
})
end, PhoneData.Chats+1)
else
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "New message from "..IsNumberInContacts(SenderNumber).."!",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 3500,
},
})
Config.PhoneApplications['whatsapp'].Alerts = Config.PhoneApplications['whatsapp'].Alerts + 1
TriggerServerEvent('ttpPhone:server:SetPhoneAlerts', "whatsapp")
end
else
print(chats)
print(NumberKey)
---------------------------------------------------------------------------->
PhoneData.Chats[NumberKey].messages = ChatMessages
<------------------------------------------------------------------------------
if PhoneData.Chats[NumberKey].Unread ~= nil then
PhoneData.Chats[NumberKey].Unread = PhoneData.Chats[NumberKey].Unread + 1
else
PhoneData.Chats[NumberKey].Unread = 1
end
if PhoneData.isOpen then
if SenderNumber ~= PhoneData.PlayerData.number then
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "New message from "..IsNumberInContacts(SenderNumber).."!",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 1500,
},
})
else
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "Messaged yourself",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 4000,
},
})
end
NumberKey = GetKeyByNumber(SenderNumber)
ReorganizeChats(NumberKey)
Wait(100)
wrPhone.TriggerServerCallback('ttpPhone:server:GetContactPictures', function(Chats)
SendNUIMessage({
action = "UpdateChat",
chatData = Chats[GetKeyByNumber(SenderNumber)],
chatNumber = SenderNumber,
Chats = Chats,
})
end, PhoneData.Chats)
else
SendNUIMessage({
action = "PhoneNotification",
PhoneNotify = {
title = "Whatsapp",
text = "New message from "..IsNumberInContacts(SenderNumber).."!",
icon = "fab fa-whatsapp",
color = "#25D366",
timeout = 3500,
},
})
NumberKey = GetKeyByNumber(SenderNumber)
ReorganizeChats(NumberKey)
Config.PhoneApplications['whatsapp'].Alerts = Config.PhoneApplications['whatsapp'].Alerts + 1
TriggerServerEvent('ttpPhone:server:SetPhoneAlerts', "whatsapp")
end
end
end)
Dump the PhoneData table and check if the value exists, it probably doesn't and it's giving you nil.

Problems with test ads - FB Audience Network

We are trying to show rewarded video ads in our game.
But we are getting this response for the test device/user.
{
code = 1;
message = "An unknown error has occurred.";
type = OAuthException;
url = "https://graph.facebook.com/network_ads_common/";
}
Here are the logs for the request. (Ad request Parameters)
1.AFP = b4e920
2.ALLOWS_ARBITRARY_LOADS = 1
3.APPBUILD = 29
4.APPVERS = 1.0.0
5.BUNDLE = 'my game bundle'
6.COCOS2D = 0
7.COPPA = 0
8. CORE_AFP = 54351be8
9.DENSITY = 2
10.HEIGHT = 0
11.IDFA = 5E57F11A-C663-4FAB-B9F7-DE6F7246AA84
12.IDFA_FLAG = 1
13.LOCALE = en_AM
14. M_BANNER_KEY = 'some key here'
15.MAKE = Apple
16.MEDIATION_SERVICE =
17.MODEL = iPad7,2
18.NETWORK_TYPE = 1
19.NUM_ADS_REQUESTED = 1
20.ORIENTATION = 3
21.OS = iOS
22.OSVERS = 12.1.4
23.PLACEMENT_ID = VID_HD_16_9_15S_APP_INSTALL#my_live_placement_id
24.REQUEST_TIME = 1553694293.090104
25.ROOTED = 1
26.SCREEN_HEIGHT = 768
27.SCREEN_WIDTH = 1024
28.SDK = ios
29.SDK_CAPABILITY = [3,4,5,7,9,10,12,16,17]
30.SDK_VERSION = 5.1.0
31.SESSION_ID = 5268043A-BF88-4B94-A773-833396087D5D
32.SESSION_TIME = 15.50397801399231
33.TEMPLATE_ID = 400
34.TEST_MODE = 1
35.UNITY = 0
36.VOLUME = 0.5
37.WIDTH = 0
The platform is iOS.
Any suggestions about what is going wrong?
Thanks for your help.

rake db:seed_fu not populating database

I'm using the seed-fu gem and am able to get 2 files to seed the db successfully. The following file, while it produces output in the terminal, isn't populating the db:
# residents.rb
Resident.seed do |r|
r.account_id = 1
r.employee_id = 1
r.first_name = "solomon"
r.last_name = "gibsom"
r.gender = "Male"
r.dob = Date.parse("1937-02-20")
r.case_number = "H-3827-JKZ-0329"
r.veteran_status_number = "G-15 classified"
r.marital_status = "Married"
r.arrival_date = Date.today
r.religious_preferences = "None"
r.insurance_info = "Medicaid"
r.burial_provisions = "Cremation"
r.admission_weight = "121 lbs"
r.admission_height = "5ft 9in"
r.allergies = "Corn, wheat and peanut allergies"
end
Address.seed do |r|
r.account_id = 1
r.employee_id = 1
r.resident_id = 1
r.street_address = "55298 solomon hills blvd"
r.city = "Flint"
r.state = "MI"
r.zip = "48289"
end
PrimaryPhone.seed do |r|
r.account_id = 1
r.employee_id = 1
r.resident_id = 1
r.area_code = "810"
r.number = "565-0255"
end
Terminal output:
The output looks good so I check for the records in the console:
I'm sort of at a loss on where further to look to check for errors.
Here are two files that work as expected:
#accounts.rb
Account.seed do |a|
a.facility_name = "Chuck Norris AFC"
end
#admins.rb
Employee.seed do |a|
a.account_id = 1
a.is_admin = true
a.first_name = "kenneth"
a.last_name = "the paige"
a.email = "test#example.com"
a.password = "12345678"
a.password_confirmation = "12345678"
a.dob = Date.parse("1965-05-05")
a.gender = "Male"
end
Address.seed do |address|
address.account_id = 1
address.employee_id = 1
address.street_address = "123 Chuckleburger dr."
address.city = "New York"
address.state = "NY"
address.zip = "00001"
end
some background:
I'm using seed-fu ~>2.3,
residents.rb lives inside of db/fixtures/, and the rails version is 4.2
Thank you in advance for having a look!
Pay attention to the SQL queries printed in the console when you run Resident.all: they have condition WHERE resident.account_id is NULL. But in seeds file Resident has account_id = 1.
You might've set default_scope for Resident model. Try running Resident.unscoped.all or remove the default scope.

rally_api query for getting defects based on iteration

I am using rally_api gem in Ruby. Could any one suggest me how to write query that gets all the defects under a particular iteration?
require 'rally_api'
headers = RallyAPI::CustomHttpHeader.new()
headers.version = "1.0"
config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "mvcmxb"
config[:password] = "kjkjk"
config[:workspace] = "Persons"
config[:project] = "Business he does"
config[:headers] = headers
#rally = RallyAPI::RallyRestJson.new(config)
test_query = RallyAPI::RallyQuery.new()
test_query.type = "defect"
test_query.fetch = true
results = #rally.find(test_query)
Here is a code example when defects are queried by iteration and their description is updated. You may either query by iteration name:
query.query_string = "(Iteration.Name = \"i10\")"
or iteration ref:
query.query_string="(Iteration = /iteration/13589769934)"
Names are not unique, but the query is also bound by the project:
rally = RallyAPI::RallyRestJson.new(config)
query = RallyAPI::RallyQuery.new()
query.type = :defect
query.fetch = "Name,FormattedID,Iteration,Description"
query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/12352608219.js" }
query.project_scope_up = false
query.project_scope_down = false
query.order = "Name Asc"
#query.query_string = "(Iteration.Name = \"i10\")"
query.query_string="(Iteration = /iteration/13589769934)"
results = rally.find(query)
results.each do |d|
puts "FormattedID: #{d["FormattedID"]}, Iteration: #{d["Iteration"]["Name"]}"
d.read
fieldUpdates = { "Description" => "bad defect"}
d.update(fieldUpdates)
end

Wrong Number of Arguments

I understand what causes the wrong number of arguments error but my code doesn't pass any parameters to initialize any of the classes so I'm not sure at all why my code is giving me this error. I'm also pretty new to Ruby on Rails so that doesn't help things. My code is below:
def create_google_file
#products = Product.find(:all)
file = File.new('dir.xml','w')
doc = REXML::Document.new
root = REXML::Element.new "rss"
root.add_attribute("xmlns:g", "http://base.google.com/ns/1.0")
root.add_attribute("version", "2.0")
channel = REXML::Element.new "channel"
root.add_element channel
title = REXML::Element.new "title"
title.text = "Sample Google Base"
channel.add_element title
link = REXML::Element.new "link"
link.text = "http://base.google.com/base/"
channel.add_element link
description = REXML::Element.new "description"
description.text = "Information about products"
channel.add_element description
#products.each do |y|
item = channel.add_element("item")
id = item.add_element("g:id")
id.text = y.id
title = item.add_element("title")
title.text = y.title
description = item.add_element("description")
description.text = y.description
googlecategory = item.add_element("g:google_product_category")
googlecategory.text = y.googlecategory
producttype = item.add_element("g:product_type")
producttype.text = y.producttype
link = item.add_element("link")
link.text = y.link
imglink = item.add_element("g:image_link")
imglink.text = y.imglink
condition = item.add_element("condition")
condition.text = y.condition
availability = item.add_element("g:availability")
availability.text = y.availability
price = item.add_element("g:price")
price.text = y.price "USD"
gtin = item.add_element("g:gtin")
gtin.text = y.gtin
brand = item.add_element("g:brand")
brand.text = y.brand
mpn = item.add_element("g:mpn")
mpn.text = y.mpn
expirationdate = item.add_element("g:expiration_date")
expirationdate.text = y.salepricedate
end
doc.add_element root
file.puts doc
file.close
end
The error I'm getting is:
ArgumentError in ProductsController#create_google_file
wrong number of arguments (1 for 0)
At the request of the poster, I am putting my comments in to an answer:
Based purely on the consistency of the other lines, but without knowing which line is actually failing, it may be this part: price.text = y.price "USD". Is y.price a method that takes in a parameter? Is it defined as def price(type) or something? If not, if it doesn't take any parameters, then it's because you're not supposed to send any parameters to that method. It looks like it's just a getter.
#FranklinJosephMoormann As I suspected, that's the line. Were you trying to make a string like "4.50 USD"? Then you probably wanted: price.text = "#{y.price} USD". That will take the result of y.price and put it in a string, and allow you to keep typing more in the string. It's called string interpolation.

Resources