Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Ruby API Library for Vesta's vSafe Payment Gateway.

License

NotificationsYou must be signed in to change notification settings

listia/vsafe-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusGem Version

Installation

Add this line to your application's Gemfile:

gem'vsafe-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install vsafe-ruby

Configuration

VSafe.configuredo |config|config.account_name="YOUR VESTA ACCOUNT"config.password="YOUR VESTA PASSWORD"config.sandbox=true# Sandbox mode, Default to trueconfig.request_timeout=20# Request timeout, default to 20end

Config can also be overridden when initializing a request client:

client=VSafe::Client.newdo |config|config.sandbox= !Rails.env.production?config.request_timeout=3end

Vesta URLs

All four Vesta URLs can be specified in config:

VSafe.configuredo |config|config.sandbox_url='https://my.sandbox.url/GatewayV4Proxy/Service'config.sandbox_jsonp_url='https://my.sandboxtoken.url/GatewayV4ProxyJSON/Service'config.production_url='https://my.production.url/GatewayV4Proxy/Service'config.production_jsonp_url='https://my.production.url/GatewayV4ProxyJSON/Service'end

Logging

The logger passed to HTTParty can be specified in config:

VSafe.configuredo |config|config.logger=Rails.loggerend

Request & Response

First, Setup a client for making request:

client=VSafe::Client.new
Heartbeat request

Check if VSafe API is up or not.

client.heartbeat.success?
Get vesta session tags

Get web session id forWEB charge source.

response=client.get_session_tags# => #<VSafe::Responses::GetSessionTags ...># Response attributesresponse.org_idresponse.web_session_id
Authorize charge

Authorize a credit card charge attempt for later confirm usage.

auth_params={TransactionID:"...",ChargeAccountNumberToken:"...",ChargeAmount:10,WebSessionID:"100_000000000",# Fingerprint generated by get_session_tags as part of ChargeSource::WEB transactionPaymentDescriptor:"...",ChargeSource:VSafe::ChargeSource::WEB,# Or VSafe::ChargeSource::PPD/VSafe::ChargeSource::TELRiskInformation:"...",# XML string for the transactionIsTempToken:false,CardHolderFirstName:"Foo",CardHolderLastName:"Bar",CardHolderAddressLine1:"...",CardHolderAddressLine2:"...",CardHolderCity:"...",CardHolderRegion:"...",CardHolderPostalCode:"...",CardHolderCountryCode:"...",ChargeCVN:123,# Card's CVVChargeExpirationMMYY:"1221",# Card's expiration date in MMYY formatStoreCard:true# Get a permanent token or not}response=client.charge_authorize(params)# => #<VSafe::Responses::ChargeAuthorize ...># Response attributesresponse.avs_resultresponse.auth_resultresponse.cvn_resultresponse.charge_permanent_tokenresponse.payment_acquirer_nameresponse.payment_idresponse.payment_status
Confirm charge

This should coupled withcharge_authorize, confirms the previous authorized charge attempt.

auth_response=client.charge_authorize(auth_params)confirm_params={PaymentID:auth_response.payment_id,ChargeAmount:auth_params[:ChargeAmount],TransactionID:auth_params[:TransactionID]}response=client.charge_confirm(confirm_params)# => #<VSafe::Responses::ChargeConfirm ...>response.payment_status
Charge sale

Directly charge credit card.

charge_params={#... Same as authorize charge params}response=client.charge_sale(charge_params)# => #<VSafe::Responses::ChargeSale ...># Response attributesresponse.avs_resultresponse.auth_resultresponse.cvn_resultresponse.charge_permanent_tokenresponse.payment_acquirer_nameresponse.payment_idresponse.payment_id_pkresponse.payment_status
Reverse payment

Reverse a previously charged payment.

params={RefundAmount:10.0,PaymentID:"...",# payment id from charge_confirm or charge_saleTransactionID:"..."# transaction id passed-in in charge/auth params}response=client.reverse_payment(params)# => #<VSafe::Responses::ReversePayment ...># Response attributesresponse.available_refund_amountresponse.payment_acquirer_nameresponse.payment_id
Validate Credit card

Check to see if a credit card is valid.

params={TransactionID:"...",ChargeAccountNumberToken:"...",WebSessionID:"100_000000000",# Fingerprint generated by get_session_tags as part of ChargeSource::WEB transactionIsTempToken:true,StoreCard:true,PaymentDescriptor:"...",ChargeSource:VSafe::ChargeSource::WEB,CardHolderFirstName:"Foo",CardHolderLastName:"Bar",CardHolderAddressLine1:"...",CardHolderAddressLine2:"...",CardHolderCity:"...",CardHolderRegion:"...",CardHolderPostalCode:"...",CardHolderCountryCode:"...",ChargeCVN:123,# Card's CVVChargeExpirationMMYY:"1221",# Card's expiration date in MMYY format}response=client.validate_charge_account(params)response.avs_resultresponse.auth_resultresponse.cvn_resultresponse.charge_permanent_tokenresponse.payment_acquirer_nameresponse.payment_idresponse.payment_status
Get Payment Status

Get the payment status by the partner transaction ID or Vesta Payment ID.

params={PartnerTransactionID:'333c1b85-c5db-4648-a946-ba408582fc1c'}response=client.get_payment_status(params)# => #<VSafe::Responses::GetPaymentStatus ...># Response attributesresponse.amountresponse.payment_idresponse.payment_statusresponse.response_coderesponse.transaction_id

Note: If transaction does not exist on Vesta, result ofresponse.success? will be false.

Contributing

  1. Fork it (https://github.com/[my-github-username]/vsafe-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Ruby API Library for Vesta's vSafe Payment Gateway.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp