Balanced Payments - Balanced::BankAccount and invalidation of stored accounts - ruby-on-rails

I am adding Balanced Payments (-v 0.6.0) to an existing system to enable marketplace features, and am running into an issues with the cleanup (invalidation) of a stored Bank Account when a new Bank Account is added/stored to a Customer Account (we only want sellers in marketplace to have at most one Bank Account active, to reduce complexity).
to make my question simple, here is a simple version of the what we are attempting, and the log response (error)
if (!params[:balanced_uri].blank?)
begin
#balanced_acctresponse = Balanced::Account.find(params[:balanced_uri])
bankaccts = Balanced::BankAccount.find(#balanced_acctresponse.bank_accounts_uri)
bankaccts.invalidate
rescue => e
logger.debug("Balanced Bank Account error :: #{e}")
end
this is generating the following exception
Balanced Bank Account error :: Balanced::BadRequest(400)::Bad
Request:: POST
https://api.balancedpayments.com/v1/marketplaces/xxxxxx/accounts/xxxxxx/bank_accounts?limit=10&offset=0:
request: Missing required field [name]
I'm confused as to what name field is missing. As defined here http://rubydoc.info/gems/balanced/0.6.0/Balanced/BankAccount there is no name param required for invalidate

I suggest you upgrade to the latest version of balanced-ruby (0.7.4). I recommend you then try something like:
begin
#account = Balanced::Account.find(current_user.balanced_account_uri)
#account.bank_accounts.each do |ba|
ba.invalidate
end
rescue => e
logger.debug("Balanced Bank Account error :: #{e}")
end
This will find the Account instance in Balanced, loop through its bank accounts and invalidate each of them.
NOTE: Account was deprecated about 9 months ago, superseded by Customer. Account will not be in the next API revision.
If you have any other questions, feel free to also drop by #balanced on Freenode IRC. There you can get assistance directly from developers.

Related

ActiveMerchant Cybersource Authorization Error Reason 102

I'm work on debugging an application that is currently running on Ruby 2.5.8 with ActiveMerchant 1.117.0.
I am able to create and save the subscription successfully. However, when I try to authorize the saved card I keep getting reasonCode 102. The error from the Cybersource gateway side is the subscription () could not be found.
I'm attempting to authorize with the function:
def authorize(token, amount, order_id, line_items)
response = gateway.authorize(amount, token, order_id: order_id, line_items: line_items)
if !response.success?
raise Exceptions::ChargeFailed.new(response.message, response: response)
end
response
end
The error would lead me to believe that the formatting here is not correct. Can anyone point me to some working ActiveMerchant CyberSource examples for authorizing a subscription or point out what might be wrong here?
After some digging, it appears that the logic for token assignment changed inside of the ActiveMerchant CyberSource gem
The original logic was:
if reference
_, subscription_id, _ = reference.split(";")
xml.tag! 'subscriptionID', subscription_id
end
The latest versions this shifted towards:
if reference
subscription_id = reference.split(";")[6]
xml.tag! 'subscriptionID', subscription_id
end
The application that I am working with previously had been formatting the CyberSource profile / subscription id as ;#{token};. In order to work with these latest updates the token needs to be formatted as ;;;;;;#{token}.

Error using ActiveMerchant::Billing::AuthorizeNetCimGateway with Authorize.Net's opaqueData

Feb 8, 2018
My Ruby on Rails application has been successfully using ActiveMerchant::Billing::AuthorizeNetCimGateway with the payment type :credit_card for creating a customer profile with an embedded payment profile.
I'm now in the process of migrating to Authorize.Net's Accept.js which accepts credit card info directly sent from their hosted payment form and returns a payment nounce of type COMMON.ACCEPT.INAPP.PAYMENT that can be used for one time to create a payment transaction, customer profile, etc.
I constructed a payment_profile hash with :opaque_data in place of :credit_card. For example:
> payment_profile
=> {:payment=>
{:opaque_data=>
{:data_descriptor=>"COMMON.ACCEPT.INAPP.PAYMENT",
:data_value=> "eyJjb2RlIjoiNTBfMl8wNjAwMDUzNjBDMzAwOUQ3OEUzOUQ1MDk4QTYxMjFGNzlCQ0Y3RDRGQUE4NTNCMEU3MkYyMUJBNTI3NUE0NjQ2Q0ZFQTVFNzMxMDI2Qjg5ODJGNjBFRUE2RDZFMTZCMUY5NzQ4NUJFIiwidG9rZW4iOiI5NTE4MDc3Njg5NDA4MTAwOTAzNTAyIiwidiI6IjEuMSJ9"}},
:bill_to=>{:first_name=>"Firstname", :last_name=>"Lastname", :address=>nil, :city=>nil, :state=>nil, :zip=>nil, :country=>nil, :phone_number=>"(012) 234-5678"}}
I then tried to create a customer profile with an existing code similar to the following:
response = #gateway.create_customer_profile profile: {
email: client.email,
description: client.name,
merchant_customer_id: client.id,
payment_profiles: payment_profile
}
However, I received a response which had a result_code of Error and complained about "incomplete content" for element payment as follows:
> response
=> #<ActiveMerchant::Billing::Response:0x007f9827d14900
#authorization=nil,
#avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
#cvv_result={"code"=>nil, "message"=>nil},
#emv_authorization=nil,
#error_code="E00003",
#fraud_review=nil,
#message=
"The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.",
#params=
{"messages"=>
{"result_code"=>"Error",
"message"=>
{"code"=>"E00003",
"text"=>
"The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."}}},
#success=false,
#test=true>
I have a few questions in my mind:
Does ActiveMerchant::Billing::AuthorizeNetCimGateway even support Accept.js' :opaque_data in place of :credit_card?
If ActiveMerchant::Billing::AuthorizeNetCimGateway does support :opaque_data, what's may be wrong with the above payment_profile and what other content that I'd need to provide for payment element?
I'd appreciate any help in resolving this issue.
While this question is over 4 years old, and I'm assuming you have either found a solution or abandoned your effort, I ran into this same issue recently, and thought it would be helpful to add my findings in case someone else runs into this.
the AuthorizeNetCimGateway does not currently support Accept.js' opaqueData. In looking at the sourcecode for the active_merchant gem, specifically in /lib/active_merchant/billing/gateways/authorize_net_cim.rb, there is ultimately a method add_payment_profile that gets called. In that method, specifically on lines 759-761, you can see that the options are either a credit_card, bank_account, or drivers_license. A tokenized payment is not currently supported.
That being said, there is an open PR#2422 that adds support for this. At the time of writing this, it appears to be failing some rubocop specs, but hopefully it can get deployed in the near future!

Fedex address validation failed

I am using rails 2.3.17, I have used fedex .
I have used the plugin https://github.com/kdonovan/fedex
I have a customer who has account in fedex. But while shipping from the site , I am getting the error as
Fedex address validation failed. Check address details. Error messages: MODIFIED_TO_ACHIEVE_MATCH. Delivery Point: UNAVAILABLE. Residential Status: BUSINESS
Any guess why this is happening ?
Thanks
EDIT
address_request_details: AvenueStateOrProvinceCodeWICityWausauWebAuthenticationDetailUserCredentialPasswordhTJxEaH7fXDqYtNaPFsPIDAy6KeyXl4QkKWZbZpxhzaIVersionMajor2ServiceIdavalIntermediate0Minor0
process_address_request: #<SOAP::Mapping::Object:0x346dedc
{http://fedex.com/ws/addressvalidation/v2}HighestSeverity="SUCCESS"
{http://fedex.com/ws/addressvalidation/v2}Notifications=#<SOAP::Mapping::Object:0x346d4f0
{http://fedex.com/ws/addressvalidation/v2}Severity="SUCCESS" {http://fedex.com/ws/addressvalidation/v2}Source="wsi">
{http://fedex.com/ws/addressvalidation/v2}Version=#<SOAP::Mapping::Object:0x3469bac {http://fedex.com/ws/addressvalidation/v2}ServiceId="aval"
{http://fedex.com/ws/addressvalidation/v2}Major="2"
{http://fedex.com/ws/addressvalidation/v2}Intermediate="0" {http://fedex.com/ws/addressvalidation/v2}Minor="0"> {http://fedex.com/ws/addressvalidation/v2}ReplyTimestamp="2014-04-21T04:25:59.044-05:00" {http://fedex.com/ws/addressvalidation/v2}AddressResults=#<SOAP::Mapping::Object:0x3464508
{http://fedex.com/ws/addressvalidation/v2}ProposedAddressDetails=#<SOAP::Mapping::Object:0x3463f54 {http://fedex.com/ws/addressvalidation/v2}Score="58" {http://fedex.com/ws/addressvalidation/v2}
Changes="MODIFIED_TO_ACHIEVE_MATCH" {http://fedex.com/ws/addressvalidation/v2}ResidentialStatus="BUSINESS" {http://fedex.com/ws/addressvalidation/v2}
DeliveryPointValidation="UNAVAILABLE" {http://fedex.com/ws/addressvalidation/v2}Address=#<SOAP::Mapping::Object:0x345f4b8 {http://fedex.com/ws/addressvalidation/v2}StreetLines="1000 S 17TH AVE"
{http://fedex.com/ws/addressvalidation/v2}City="WAUSAU" {http://fedex.com/ws/addressvalidation/v2}StateOrProvinceCode="WI" {http://fedex.com/ws/addressvalidation/v2}PostalCode="54401-5741" {http://fedex.com/ws/addressvalidation/v2}CountryCode="US"> {http://fedex.com/ws/addressvalidation/v2}RemovedNonAddressData="">>>
Per the edit, FedEx is not returning an error - you are getting back SUCCESS.
MODIFIED_TO_ACHIEVE_MATCH is very common in a FedEx response - it means that the user entered an address which required some changes. Compare the original data to the response and determine if you want to overwrite it or keep as-is. Alliteratively, many sites are coded to show the original address and the standardized address side by side so the user can "update" to the standardized version. Be aware that FedEx (and UPS) validation can be destructive at times.

Getting error 87 at payment Authorize.net in Rails 3

I have created a test account with Authorize.net. My development environment is rails 3 and I am trying to implement the Server Integration Method (SIM) by using static IP. But I am getting an error:
"3,1,87,(TESTMODE) Transactions of this market type cannot be processed on this system.,000000,P,0,,,199.00,,auth_capture,,,,,,,,,,,,,,,,,,,,,,,,,,D3EA25CA1DF97765286A48C6B22287F4,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,✓,uSIUUgX0d++dIheYjcHdlztlViD/r4YDUP9rEuEy9U8=,Purchase" when send request to "AuthorizeNet::SIM::Transaction::Gateway::TEST" gateway.
I also found this link: others got similar type error
But not helpful. Any suggestions how to resolve this error? I wrote following codes in the action.
#amount = 10.00
#sim_transaction = AuthorizeNet::SIM::Transaction.new('API Login ID', 'Transaction Key', #amount, :hosted_payment_form => true)
#sim_transaction.set_hosted_payment_receipt(AuthorizeNet::SIM::HostedReceiptPage.new(:link_method => AuthorizeNet::SIM::HostedReceiptPage::LinkMethod::GET, :link_text => 'Continue', :link_url => payments_thank_you_url(:only_path => false)))
Since you are dealing with credit card transactions through web applications, you need to make sure your Sandbox account is of "Card Not Present" type. If you don't remember which type you set it to, it is a good idea to create a new account and make sure to select "Card Not Present" option. Otherwise, you will get this error message.
I hope this helps.

Google Federated OAuth/OpenID with Tornado: why is it ignoring my scopes?

I'm trying to use Tornado's library for federated login to authenticate users and get access to their calendar, contacts, and mail. However, when I get the "mydomain.dyndns.info is asking for some information from your Google Account" message, the only bullet point listed is "Email Address". Subsequently, when I check the returned user object after I approve the request, the user object doesn't have an 'access_token' property.
Here's the code:
def get(self):
scope_list = ['https://mail.google.com/','http://www.google.com/m8/feeds/','http://www.google.com/calendar/feeds/']
...
self.authorize_redirect(scope_list, callback_uri=self._switch_command('auth_callback'), ax_attrs=["name","email"])
def _on_auth(self, user):
print 'in on auth'
if user:
self.set_the_user(user['email'])
session.set_data('usertoken_' + user['email'], user['access_token'])
self.redirect('/')
The uri that this spits out is:
https://www.google.com/accounts/o8/ud
?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.return_to=http%3A%2F%2Fmydomain.dyndns.info%3A333%2Fauth%2Fauth_callback%3Fperms%3Dgmail%26perms%3Dcontacts%26perms%3Dcalendar
&openid.realm=http%3A%2F%2Fmydomain.dyndns.info%3A333%2F
&openid.mode=checkid_setup
&openid.ns.oauth=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Foauth%2F1.0
&openid.oauth.consumer=mydomain.dyndns.info
&openid.oauth.scope=https%3A%2F%2Fmail.google.com%2F+http%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F+http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.ax.type.fullname=http%3A%2F%2Faxschema.org%2FnamePerson
&openid.ax.type.lastname=http%3A%2F%2Faxschema.org%2FnamePerson%2Flast
&openid.ax.type.firstname=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffirst
&openid.ax.mode=fetch_request
&openid.ax.type.email=http%3A%2F%2Faxschema.org%2Fcontact%2Femail
&openid.ax.required=firstname%2Cfullname%2Clastname%2Cemail
Ideas: 1. maybe this has something to do with the fact I'm running on a local machine behind a dyndns forwarder? 2. Tornado's documentation says "No application registration is necessary to use Google for authentication or to access Google resources on behalf of a user" -- but maybe that's not true anymore?
If anyone has thoughts, I'd really appreciate it -- this is driving me a little batty!
Figured it out. You have to set the application properties google_consumer_key and google_consumer_secret.
application = tornado.web.Application(urlhandlers, cookie_secret=cookie_secret, google_consumer_key=google_consumer_key, google_consumer_secret=google_consumer_secret)
You get them by going here: https://www.google.com/accounts/ManageDomains

Resources