class Lucid::Shopify::CreateCharge

Public Class Methods

new(client: Container[:client]) click to toggle source

@param client [#post_json]

# File lib/lucid/shopify/create_charge.rb, line 9
def initialize(client: Container[:client])
  @client = client
end

Public Instance Methods

call(credentials, charge) click to toggle source

Create a new recurring application charge.

@param credentials [Credentials] @param charge [Hash]

@return [Hash] the pending charge

# File lib/lucid/shopify/create_charge.rb, line 19
def call(credentials, charge)
  data = @client.post_json(credentials, 'recurring_application_charges', post_data(charge))

  data['recurring_application_charge']
end

Private Instance Methods

post_data(charge) click to toggle source

@param charge [Hash]

@return [Hash]

# File lib/lucid/shopify/create_charge.rb, line 28
        def post_data(charge)
  {
    'recurring_application_charge' => {
      'return_url' => Shopify.config.billing_callback_uri
    }.merge(charge.transform_keys(&:to_s)),
  }
end