Exit Survey popup with Volusion - volusion

I am using ResellerRatings for my exit survey popups on Volusion OrderFinished.asp.
ResellerRatings provided the following codes:
<script type="text/javascript">
var _rrES = {
seller_id: 101069,
email: "customer#home.com",
invoice: "INVOICE NUMBER",
auto: true
};
(function(w,o) {
o=o||{};w.seller_id=o.seller_id||"";w.__rr_email_pass=o.email||"";w.__rr_inv=o.invoice||"";
if(o.auto===false)w.__rr_autoEnroll=false;
var s=document.createElement('script');s.type='text/javascript';s.async=true;
s.src="https://www.resellerratings.com/popup/include/popup.js";var ss=document.getElementsByTagName('script')[0];
ss.parentNode.insertBefore(s,ss);
})(window, _rrES);
</script>
ResellerRatings instruction told me to "Please update the email: "customer#home.com" and invoice: "INVOICE NUMBER" values during implementation".
email: "customer#home.com",
invoice: "INVOICE NUMBER",
But I know these should be variables depending on each customer. I contact Volusion with an answer "no coding helps whatsoever...". So I would love to use Stackoverflow's power to help me out here. What are these variables should be and in what format? Thanks in advance.

email: Order[9],
invoice: Order[0],

Related

Insert QR code into PDF using gem receipts in Ruby on Rails

I'm using gem 'receipts' by Chris Oliver, and I want to insert QRcode with payment details (to the footer section for example).
Models: Partner and Charge.
I want QR code to contain model attributes, like these: charge.partner.iban, charge.amount and something like that.
Charge.rb has method receipt:
def receipt
Receipts::Invoice.new(
details: [
["Receipt Number", "123"],
["Date paid", Date.today],
["Payment method", "ACH super long super long super long super long super long"]
],
company: {
name: "Example, LLC",
address: "123 Fake Street\nNew York City, NY 10012",
email: "support#example.com",
logo: File.expand_path("./app/assets/images/logo.png")
},
recipient: [
self.partner.name,
self.partner.address,
"City, State Zipcode",
nil,
"customer#example.org"
],
line_items: [
["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
["Subscription", "$19.00", "1", "$19.00"],
[nil, nil, "Subtotal", "$19.00"],
[nil, nil, "Tax", "$1.12"],
[nil, nil, "Total", "$20.12"],
[nil, nil, "<b>Amount paid</b>", "$20.12"],
[nil, nil, "Refunded on #{Date.today}", "$5.00"]
],
footer: "Thanks for your business. Please contact us if you have any questions."
)
end
charges_controller has:
def show
respond_to do |format|
format.html
format.json
format.pdf { send_pdf }
end
end
private
def send_pdf
send_data #charge.receipt.render,
filename: "#{#charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
type: "application/pdf",
disposition: :inline # or :attachment to download
end
charges/show.html.erb:
<%= link_to "View invoice", charge_path(#charge, format: :pdf) %>
I tried using prawn-qrcode, but couldn't make it.
Maximum what I get is something as line of text in the footer.
When I put this in receipts method:
qrcode = RQRCode::QRCode.new(self.partner.ico.to_s)
png = qrcode.as_png(
resize_gte_to: false,
resize_exactly_to: false,
fill: 'white',
color: 'black',
size: 120,
border_modules: 4,
module_px_size: 6,
file: nil # path to write
)
and this in the footer:
footer: ActionController::Base.helpers.image_tag(png.to_data_url)
What should I do to insert QRcode with desired data? Is there any examples of similar task?
Thanks
Note: This is untested as-is but should work based on the documentation of the libraries themselves.
receipts uses prawn to generate pdfs.
Someone has created a QR Code renderer for prawn called prawn-qrcode which uses rqrcode so you may be able to use this as a simple bridge between the 2 libraries.
Theoretical Example:
def send_pdf
receipt = #charge.receipt
qr_code = RQRCode::QRCode.new(self.partner.ico.to_s)
receipt.render_qr_code(qr_code, extent: 72)
send_data receipt.render,
filename: "#{#charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
type: "application/pdf",
disposition: :inline # or :attachment to download
end
Additional Notes:
You may have to play around with positioning e.g. render_qr_code(qr_code, pos: [x,y])
I am not sure what self.partner.ico.to_s generates

Authorize.net : This transaction has been declined

CreditCard Model
def charge_cents!(cents)
begin
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new($installation[:authorize])
response = nil
Timeout::timeout(120.seconds) {
response = gateway.purchase(cents, self.to_am_creditcard, {
:order_id => self.customer.contract_number[1..-1],
:cust_id => self.customer.contract_number[1..-1]
}.merge(self.am_billing_address_hash))
}
return response
rescue
return response = nil
end
end
to_am_creditcard
def to_am_creditcard
ActiveMerchant::Billing::CreditCard.new({
:number => self.number,
:month => self.month,
:year => self.year,
:first_name => self.first_name,
:last_name => self.last_name,
})
end
am_billing_address_hash
def am_billing_address_hash
{:billing_address => self.to_hash }
end
Now, Take last credit card
1.9.3p484 :003 > #card = CreditCard.last
=> #<CreditCard id: 17263, crypted_number: "uXHr8wFYPvlaLWkB7hMltzex60ZtINOMH7EDB+/uSZU=\n", last_4: "4242", first_name: "test3", last_name: "test4", phone: "1234567890", customer_id: 66837, month: 7, year: 2017, address_id: 230222, created_at: "2014-07-11 03:36:21", updated_at: "2014-07-11 03:36:21">
and Now, use charge_cents method
1.9.3p484 :006 > response = #card.charge_cents!(amount * 100.0)
=> #<ActiveMerchant::Billing::Response:0xbac6ce0 #params={"response_code"=>2, "response_reason_code"=>"2", "response_reason_text"=>"This transaction has been declined.", "avs_result_code"=>"U", "transaction_id"=>"6328764577", "card_code"=>"", "authorization_code"=>"", "cardholder_authentication_code"=>"", "action"=>"AUTH_CAPTURE"}, #message="This transaction has been declined", #success=false, #test=false, #authorization="6328764577", #fraud_review=false, #avs_result={"code"=>"U", "message"=>"Address information unavailable.", "street_match"=>nil, "postal_match"=>nil}, #cvv_result={"code"=>nil, "message"=>nil}>
See : response_reason_text : Getting This transaction has been declined
I don't know why I am getting this error, It's working on test mode but when I remove a test mode then getting this error.
or, If any other way to integrate auth.net with ruby on rails 3.2 then please help for this with code.
Update
I am passing this data:
CC Number : 4242424242424242
ExpireDate : 11/2015
Please Help Me.
Thanks, In Advance.
First, when you specify Test Mode, the gateway only checks if the API Login and Transaction Key are correct and returns success if valid. This is true for both the sandbox or production. You should never use test mode in the sandbox.
Try using 4111111111111111 in the sandbox with test mode=false to test a transaction.

Ember-Data beta 3 and saving hasMany relationships and additonally one record with Rails

I am using Rails 4, Ember 1.2.0 and Ember Data 1.0.0-beta.3 and DS.ActiveModelSerializer.
I have trouble saving a new record with a 'has many' relationship. Two model records should be created but only by one POST request.
I have 2 models which looks like this:
Lingohub.SupportCase = DS.Model.extend({
subject: DS.attr('string'),
status: DS.attr('string'),
created_at: DS.attr('date'),
supportCaseMessages: DS.hasMany('supportCaseMessage')
});
Lingohub.SupportCaseMessage = DS.Model.extend({
supportCase: DS.belongsTo('supportCase'),
text: DS.attr('string'),
created_at: DS.attr('date')
});
My NEW route creates support case and support case massage:
Lingohub.SupportCasesNewRoute = Ember.Route.extend({
model: function() {
var support_case = this.store.createRecord('supportCase');
support_case.get('supportCaseMessages').createRecord();
return support_case;
}
});
My new form looks like this: (I don't know if you can bind an child attribute easier?)
<form {{action 'create' this on="submit"}} id="new_support_case">
{{input value=subject}}
{{!-- {{supportCaseMessages.0.text}} --}}
{{#each supportCaseMessages}}
{{textarea value=text}}
{{/each}}
<input type="submit">
</form>
'create' action in the controller:
Lingohub.SupportCasesNewController = Ember.ObjectController.extend({
actions: {
create: function(supportCase) {
var message = supportCase.get('supportCaseMessages.content')[0];
console.log(message.get('text'))
supportCase.save();
}
}
});
The POST Request to the Server only sends the 'support case'!!
{"support_case"=>{"subject"=>"aaaaaa", "status"=>nil, "created_at"=>nil}}
How can I send the additional record 'support case message' and the relationship ?
I try to answer my own question. If I do the following I get "support_case_messages" embedded in "support_case", is this really the best way to send 'two models' in one POST request?
Lingohub.SupportCaseSerializer = DS.ActiveModelSerializer.extend({
serializeHasMany: function(record, json, relationship) {
var key, jsonKey;
key = relationship.key;
jsonKey = Ember.String.underscore(key);
json[jsonKey] = [];
record.get(key).forEach(function(item) {
return json[jsonKey].push(item);
});
console.log(json)
return json;
}
});

How to get user fields in Ember js with has many associations

I have two models User and Recipe. I want to get user fields on recipe page and username in each recipe on user page. I don't know how to do it. In rails i have two has many association between User and Recipe. I added examples of my json arrays that I'm getting from rails.
My json user array
user: {
id: 1,
name: "ejiqpep",
email: "ejiqpep#gmail.com",
recipe_ids: [
1,
2
],
box_recipe_ids: [
1,
2
]
}
My json recipe array
recipe: {
id: 1,
title: "recipe01",
about: "about01",
ingredients: "ingredients01",
steps: "steps01",
visibility_type: true,
slug: "recipe01",
user: {
id: 1,
name: "ejiqpep",
email: "ejiqpep#gmail.com",
recipe_ids: [
1,
2
],
box_recipe_ids: [
1,
2
]
}
}
user.js.coffee
App.User = DS.Model.extend
name: DS.attr('string')
email: DS.attr('string')
recipes: DS.hasMany('App.Recipe')
box_recipes: DS.hasMany('App.Recipe')
recipe.js.coffee
App.Recipe = DS.Model.extend
user: DS.belongsTo('App.User')
title: DS.attr('string')
user.handlebars (I want to get user name in each recipe)
<h1>{{name}}</h1>
<p><b>Email:</b> {{email}}</p>
<h3>User recipes</h3>
{{#each recipe in recipes}}
<div>
<span>{{recipe.id}}</span>
<span>!!!I want to show username here!!!</span>
<span>{{#linkTo recipe recipe}} {{recipe.title}} {{/linkTo}}</span>
</div>
{{/each}}
<h3>User box_recipes</h3>
{{#each fav in box_recipes}}
<div>
<span>{{fav.id}}</span>
<span>!!!I want to show username here!!!</span>
<span>{{#linkTo recipe fav}} {{fav.title}} {{/linkTo}}</span>
</div>
{{/each}}
recipe.handlebars
<h1>{{title}}</h1>
<p>User {{user.name}}</p> # I want to show username here!!!
i donĀ“t know exactly if it works ... but give it a try :
update:
{{#each recipes}}
<div>
<span>{{id}}</span>
<span>{{../name}}!!!I want to show username here!!!</span>
<span>{{#linkTo recipe this}} {{title}} {{/linkTo}}</span>
</div>
{{/each}}

ASP.NET MVC JsonResult and handlebars, no grip?

I'm looking at example of using hadlebars.js, where template processing looks like:
var source = $("#some-template").html();
var template = Handlebars.compile(source);
var data = { users: [
{username: "alan", firstName: "Alan", lastName: "Johnson", email: "alan#test.com" },
{username: "allison", firstName: "Allison", lastName: "House", email: "allison#test.com" },
{username: "ryan", firstName: "Ryan", lastName: "Carson", email: "ryan#test.com" }
]};
$("#content-placeholder").html(template(data));
and template is:
<tbody>
{{#users}}
<tr>
<td>{{username}}</td>
<td>{{firstName}} {{lastName}}</td>
<td>{{email}}</td>
</tr>
{{/users}}
</tbody>
Now I have JSON result from ASP.NET MVC and I can't think the way I should descripbe my template, because it does not have "users" property, it looks like:
{[{username: "alan", firstName: "Alan", lastName: "Johnson", email: "alan#test.com" }]}
Can I somehow affect JsonResult to output what I need, or there is a way to fix template without touching the controller code?
In your controller replace:
return Json(users);
with:
return Json(new { users = users });
Alternatively, without introducing the anonymous object with the users property, you can change your template like so:
<tbody>
{{#each this}}
<tr>
<td>{{username}}</td>
<td>{{firstName}} {{lastName}}</td>
<td>{{email}}</td>
</tr>
{{/each}}
</tbody>

Resources