Sha256: e198e002f277cee6ea9f96bd9efbee3a14b13aadcaab825fc67bf60f2fe84b0f

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require "payment/manager/client/version"
require "payment/manager/request"
require "payment/manager/config"
require "json"

module Payment
  module Manager
    module Client
      class << self
        attr_accessor :config

        def configure
          self.config = Payment::Manager::Config
          yield(config)
        end

        def payment_url(plan_id, resource_id)
          params = {
            client_id: config.client_id,
            client_secret: config.client_secret,
            plan_id: plan_id,
            resource_id: resource_id
          }
          response =  Payment::Manager::Request.get(config.api_url + '/api/checkout', params)
          JSON.parse(response.body)['url']
        end

        def plans
          params = {
            client_id: config.client_id,
            client_secret: config.client_secret,
          }

          response =  Payment::Manager::Request.get(config.api_url + '/api/plans', params)
          JSON.parse(response.body)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
payment-manager-client-0.1.0 lib/payment/manager/client.rb