- Notifications
You must be signed in to change notification settings - Fork2
Ruby API Library for Vesta's vSafe Payment Gateway.
License
listia/vsafe-ruby
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Add this line to your application's Gemfile:
gem'vsafe-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vsafe-ruby
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
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
The logger passed to HTTParty can be specified in config:
VSafe.configuredo |config|config.logger=Rails.loggerend
First, Setup a client for making request:
client=VSafe::Client.new
Check if VSafe API is up or not.
client.heartbeat.success?
Get web session id forWEB
charge source.
response=client.get_session_tags# => #<VSafe::Responses::GetSessionTags ...># Response attributesresponse.org_idresponse.web_session_id
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
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
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 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
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 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.
- Fork it (https://github.com/[my-github-username]/vsafe-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
About
Ruby API Library for Vesta's vSafe Payment Gateway.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.