WhiteLabelName Ruby Library

The WhiteLabelName Ruby library wraps around the WhiteLabelName API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

Documentation

WhiteLabelName Web Service API

Requirements

  • Ruby 2.2+

Installation

RubyGem install (recommended)

$ gem install whitelabelmachinename-ruby-sdk

Usage

The library needs to be configured with your account's space id, user id, and secret key which are available in your WhiteLabelName account dashboard. Set space_id, user_id, and api_secret to their values:

Configuring a Service

require 'whitelabelmachinename-ruby-sdk'

space_id = 405
app_user_id = 512
app_user_key = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ="

WhiteLabelMachineName.configure do |config|
  config.user_id = app_user_id
  config.authentication_key = app_user_key
end

# TransactionService
transaction_service = WhiteLabelMachineName::TransactionService.new
# TransactionPaymentPageService
transaction_payment_page_service = WhiteLabelMachineName::TransactionPaymentPageService.new

To get stated with sending transactions you can review the example below:

require 'whitelabelmachinename-ruby-sdk'

space_id = 405
app_user_id = 512
app_user_key = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ="

WhiteLabelMachineName.configure do |config|
    config.user_id = app_user_id
    config.authentication_key = app_user_key
end

# TransactionService
transaction_service = WhiteLabelMachineName::TransactionService.new
# TransactionPaymentPageService
transaction_payment_page_service = WhiteLabelMachineName::TransactionPaymentPageService.new

transaction = WhiteLabelMachineName::TransactionCreate.new({
    billingAddress: WhiteLabelMachineName::AddressCreate.new({
        city: "City",
        country: "US",
        emailAddress: "[email protected]",
        familyName: "Family",
        givenName: "Given",
        postCode: "98100",
        postalState: "WA",
        street: "Street"
    }),
    currency: 'EUR',
    customerEmailAddress: "[email protected]",
    customerPresence: WhiteLabelMachineName::CustomersPresence::VIRTUAL_PRESENT,
    failedUrl: "http://localhost/failure",
    invoiceMerchantReference: "order-1",
    language: "en_US",
    lineItems: [
        WhiteLabelMachineName::LineItemCreate.new({
            amountIncludingTax: 29.60,
            name: "Item 1",
            quantity: 1,
            shippingRequired: true,
            sku: "sku-1",
            taxes: [
                WhiteLabelMachineName::TaxCreate.new({
                    rate: 8,
                    title: "VAT"
                })
            ],
            type: WhiteLabelMachineName::LineItemType::PRODUCT,
            uniqueId: "unique-id-item-1",
        }),
        WhiteLabelMachineName::LineItemCreate.new({
            amountIncludingTax: 5.60,
            name: "Test Shipping",
            quantity: 1,
            shippingRequired: false,
            sku: "test-shipping",
            taxes: [
                WhiteLabelMachineName::TaxCreate.new({
                    rate: 8,
                    title: "VAT"
                })
            ],
            type: WhiteLabelMachineName::LineItemType::SHIPPING,
            uniqueId: "unique-id-shipping-1",
        }),
    ],
    merchantReference: "order-1",
    shippingAddress: WhiteLabelMachineName::AddressCreate.new({
        city: "City",
        country: "US",
        emailAddress: "[email protected]",
        familyName: "Family",
        givenName: "Given",
        postCode: "98100",
        postalState: "WA",
        street: "Street"
    }),
    shippingMethod: "Test Shipping",
    successUrl: "http://localhost/success"
})

transaction = transaction_service.create(space_id, transaction)
payment_page_url = transaction_payment_page_service.payment_page_url(space_id, transaction.id)
# redirect to payment_page_url

License

Please see the license file for more information.