I have code from paypal website to allow me to check if a user is verified as a paypal user. I want to add this to my edit table and make some input boxes with email, firstName, and LastName. Iv created model in my db and added the code from paypal... I want to check the input boxes before I push the submit button for user input. How could I use ajax, jquery any thing to do this.. I want the user to type this in and click either checkVerification or after updating the text box. Then I can display a message that says this paypal account has been verified/is invalid. Before submitting the edit user page. Thank you!!
Here is what I have so far but It's not working! Maybe someone could help me fix this!! thanks!!
UserController:
# Paypal Verification
def paypal_verification
require 'paypal-sdk-adaptiveaccounts'
@api = PayPal::SDK::AdaptiveAccounts::API.new( :device_ipaddress => "127.0.0.1" )
# Build request object
@get_verified_status = @api.build_get_verified_status({
:emailAddress => "Pemail",
:matchCriteria => "NAME",
:firstName => "PfirstName",
:lastName => "PlastName" })
# Make API call & get response
@get_verified_status_response = @api.get_verified_status(@get_verified_status)
# Access Response
if @get_verified_status_response.success?
@get_verified_status_response.accountStatus
@get_verified_status_response.countryCode
@get_verified_status_response.userInfo
else
@get_verified_status_response.error
end
params.permit!
status = params[:accountStatus]
if status == "VERIFIED"
@Pverified = "true";
else
@Pverified = "false";
end
end
EditUser:
<!-- Paypal Verification -->
<div class="row">
<%= f.email_field :paypal_email, :class => 'form-control', :placeholder => "Paypal Email", id: 'Pemail' %>
<%= f.email_field :paypal_fname, :class => 'form-control', :placeholder => "Paypal FirstName", id: 'PfirstName' %>
<%= f.email_field :paypal_lname, :class => 'form-control', :placeholder => "Paypal LastName", id: 'PlastName' %>
<%= f.text_field :paypal_verified, :class => 'form-control', id: 'Pverified'%>
<script>
function UpdateInfo()
{
var Pemail = $('#Pemail').val();
var PfirstName = $('#PfirstName').val();
var PlastName = $('#PlastName').val();
var Pverified = <%= @Pverified %>;
$('#Pverified').val(Pverified);
}
</script>
</div>
Aucun commentaire:
Enregistrer un commentaire