Code Monkey home page Code Monkey logo

adyen-ruby-api-library's Introduction

Ruby

Adyen API Library for Ruby

This is the officially supported Ruby library for using Adyen's APIs.

Supported APIs

This library supports the following:

API name API version Description API object
BIN lookup API v54 The BIN Lookup API provides endpoints for retrieving information based on a given BIN. BinLookup
Checkout API v70 Our latest integration for accepting online payments. CheckoutAPI
Configuration API v2 The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. BalancePlatform
DataProtection API v1 Adyen Data Protection API provides a way for you to process Subject Erasure Requests as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) DataProtection
Legal Entity Management API v3 Manage legal entities that contain information required for verification. LegalEntityManagement
Management API v1 Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Management
Payments API v68 Our classic integration for online payments. Classic Integration API
Payouts API v68 Endpoints for sending funds to your customers. Payout
POS Terminal Management API v1 Endpoints for managing your point-of-sale payment terminals. TerminalManagement
Recurring API v68 Endpoints for managing saved payment details. Recurring
Stored Value API v46 Manage both online and point-of-sale gift cards and other stored-value cards. StoredValue
Transfers API v3 The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. Transfers
Cloud-based Terminal API - Our point-of-sale integration. TerminalCloudAPI

For more information, refer to our documentation or the API Explorer.

Prerequisites

Installation

The sole dependency is faraday for HTTP communication. Run the following command to install faraday if you don't already have it:

bundle install

To validate functionality of client and run mock API tests use

bundle install --with development 

and

rspec

Documentation

Follow the rest of our guides from the documentation on how to use this library.

Using the library

General use with API key

require 'adyen-ruby-api-library'
adyen = Adyen::Client.new

adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
  • Make a Payment
response = adyen.checkout.payments_api.payments({
  :amount => {
    :currency => "EUR",
    :value => 1000
  },
  :reference => "Your order number",
  :paymentMethod => {
    :type => "scheme",
    :encryptedCardNumber => "test_4111111111111111",
    :encryptedExpiryMonth => "test_03",
    :encryptedExpiryYear => "test_2030",
    :encryptedSecurityCode => "test_737"
  },
  :returnUrl => "https://your-company.com/checkout/",
  :merchantAccount => "YourMerchantAccount"
})
  • Change API Version
adyen.checkout.version = 68

Example integration

For a closer look at how our Ruby library works, clone our example integration. This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.

Running the tests

To run the tests use :

bundle install --with development 

Using the Cloud Terminal API Integration

In order to submit In-Person requests with Terminal API over Cloud you need to initialize the client in the same way as explained above for Ecommerce transactions:

# Step 1: Require the parts of the module you want to use
require 'adyen-ruby-api-library'

# Step 2: Initialize the client object
adyen = Adyen::Client.new(api_key: 'YOUR_API_KEY', env: :test)

# Step 3: Create the request
serviceID = "123456789"
saleID = "POS-SystemID12345"
POIID = "Your Device Name(eg V400m-123456789)"

# Use a unique transaction for every transaction you perform
transactionID = "TransactionID"

request = 
{
  "SaleToPOIRequest": {
    "MessageHeader": {
      "MessageClass": "Service",
      "MessageCategory": "Payment",
      "MessageType": "Request",
      "ServiceID": serviceID,
      "SaleID": saleID,
      "POIID": POIID,
      "ProtocolVersion": "3.0"
    },
    "PaymentRequest": {
      "SaleData": {
        "SaleTransactionID": {
          "TransactionID": transactionID,
          "TimeStamp": "2023-08-23T09:48:55"
        },
        "SaleToAcquirerData": "eyJhcHBsaWNhdGlvbkluZm8iOnsiYWR5ZW5MaWJyYXJ5Ijp7Im5hbWUiOiJhZ....",
        "TokenRequestedType": "Transaction"
      },
      "PaymentTransaction": {
        "AmountsReq": {
          "Currency": "EUR",
          "RequestedAmount": 10
        }
      }
    }
  }
}

# Step 4: Make the request
response = adyen.terminal_cloud_api.sync(request)

Optional: perform an abort request

To perform an abort request you can use the following example:

abortRequest = 
{
  "MessageHeader": {
    "MessageClass": "Service",
    "MessageCategory": "Abort",
    "MessageType": "Request",
    "ServiceID": serviceID,
    "SaleID": saleID,
    "POIID": POIID,
    "ProtocolVersion": "3.0"
  },
  "AbortRequest": {
    "AbortReason": "MerchantAbort",
    "MessageReference": {
      "MessageCategory": "Payment",
      "SaleID": saleID,
      # Service ID of the payment you're aborting
      "ServiceID": serviceID,
      "POIID": POIID
    }
  }
}

response = adyen.terminal_cloud_api.sync(abortRequest)

Optional: perform a status request

To perform a status request you can use the following example:

statusRequest =
{
  "MessageHeader": {
    "MessageClass": "Service",
    "MessageCategory": "TransactionStatus",
    "MessageType": "Request",
    "ServiceID": serviceID,
    "SaleID": saleID,
    "POIID": POIID,
    "ProtocolVersion": "3.0"
  },
  "TransactionStatusRequest": {
    "ReceiptReprintFlag": true,
    "DocumentQualifier": [
      "CashierReceipt",
      "CustomerReceipt"
    ],
    "MessageReference": {
      "SaleID": saleID,
      # serviceID of the transaction you want the status update for
      "ServiceID": serviceID,
      "MessageCategory": "Payment"
    }
  }
}

response = adyen.terminal_cloud_api.sync(statusRequest)

Feedback

We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out our feedback form to share your thoughts, suggestions or ideas.

Contributing

We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements. Have a look at our contributing guidelines to find out how to raise a pull request.

Support

If you have a feature request, or spotted a bug or a technical problem, create an issue here.

For other questions, contact our Support Team.

Licence

This repository is available under the MIT license.

See also

adyen-ruby-api-library's People

Contributors

acampos1916 avatar adyenautomationbot avatar aleffio avatar alexandrosmor avatar antolo-arch avatar crrood avatar cyattilakiss avatar dependabot-preview[bot] avatar fconforti avatar gcmannb avatar hbkwong avatar jillingk avatar jlindberg-oss avatar kadobot avatar leandromagnabosco avatar lgtm-com[bot] avatar lucasbledsoe avatar raedmakhlouf avatar renovate-bot avatar renovate[bot] avatar rickwieman avatar rikterbeek avatar rkewlani avatar robotdana avatar sndrgrdn avatar timtait avatar vvangemert avatar wboereboom avatar wilsonpinto avatar x4d3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.