cancel
Showing results for 
Search instead for 
Did you mean: 

ruby sdk API for encrypted data

I am using the sdk-ruby gem 'authorizenet' in my rails app that integrates with a mobile app. I need to write code that will create a transaction with encrypted data which is going to be passed to my api by the mobile app (through swipe card reader).

I was looking at the authorizenet gem documentation and found this:

 

https://github.com/AuthorizeNet/sdk-ruby

 

Apple pay example

 

require 'rubygems'
  require 'authorizenet'

  include AuthorizeNet::API

  transaction = Transaction.new('5KP3u95bQpv', '4Ktq966gC55GAX7S', :gateway => :sandbox)
  request = CreateTransactionRequest.new
  request.transactionRequest = TransactionRequestType.new
  request.transactionRequest.amount = 39.55

  request.transactionRequest.payment = PaymentType.new
  request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.APPLE.INAPP.PAYMENT','eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYX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ScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=') 

  request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction

  response = transaction.create_transaction(request)

  if response.messages.resultCode == MessageTypeEnum::Ok
    puts "Successfully made a purchase (authorization code: #{response.transactionResponse.authCode})"
  else
    raise "Failed to make purchase."
  end

How do I write similar code for encrypteddata. Does the new model mentioned on the github site support encrypted data? If not, do I have to create the xml request as per the AIM documentation.

 

I tried this

 

request.transactionRequest.payment.encrypteTypeData =EncryptedData.new(...)

 

and got an error.

 

Help on this is much appreciated! TIA

 

sa_jiva
Member
7 REPLIES 7

Hello @sa_jiva 

 

I've reported this to the API team and they are looking at creating some sample code for you.  As soon as it's available, I'll post it here.

 

I would recommend subscribing to this topic so that you'll be alerted via email if anyone from the community is able to respond with any comments. To subscribe, click Topic Options at the top of this thread and then select Subscribe. You'll then receive an email once anyone replies.

Thanks,

Richard

RichardH
Administrator Administrator
Administrator

Thanks! Looking forward to seeing the sample code.

Hi there,

 

See the sample code and also notes on pulling the latest SDK code, here: https://github.com/AuthorizeNet/sdk-ruby/issues/38

 

Thanks,

 

Brian

Hi Brian,

 

Thanks so much for posting the solution. I tried this with the sample data in the documentation and was able to make a successful transaction. However, when I hook it to the encrypted data coming back from a third party app, I get a response that says "E00027 The transaction was unsuccessful.". The error code is 6 and error text says "The credit card number is invalid". Will only the sample data work for a transaction in a sandbox account ?

 

Thanks

 Can you confirm the encrypted data is coming from a certified card reader?  This needs to be a sandbox-specific reader e.g. http://authorizenet.posportal.com/idtech-shuttle-for-authorize-net-developers-id-80110010-004-new-bl...

 

Thanks,

 

Brian

Yes the app is using

IDTech Shuttle for Authorize.Net Developers

 

Was just wondering, should I be using the same sandbox as the app thats swiping the card?

Yes, it should be the same sandbox merchant account.