Sha256: cf6def82872b1d07a6403fd399264cee37464a473d010b1344a796f9a913cc01

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require_relative 'checkout_link'
require_relative 'retryable'

module SpeedLightning
  module CheckoutLinkMethods
    include Retryable 

    def create_checkout_link(
        amount:,
        success_url:,
        currency: "SATS",
        metadata: { client: "ruby" },
        is_phone_enabled: false,
        is_email_enabled: false,
        is_billing_address_enabled: false,
        is_shipping_address_enabled: false,
        livemode: false
      )
      with_retry do
        body_hash = {
          amount: amount,
          success_url: success_url,
          currency: currency,
          metadata: metadata,
          customer_collections_status: {
              is_email_enabled: is_email_enabled,
              is_phone_enabled: is_phone_enabled,
              is_billing_address_enabled: is_billing_address_enabled,
              is_shipping_address_enabled: is_shipping_address_enabled
            },
          livemode: livemode
        }
        endpoint = "checkout-links"
        response = make_request(endpoint, :post, body_hash)
        CheckoutLink.new(response)
      end
    end

    def retrieve_checkout_link(id)
      with_retry do
        endpoint = "checkout-links/" + id
        response = make_request(endpoint, :get)
        CheckoutLink.new(response)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
speed_lightning-0.2.0 lib/speed_lightning/checkout_link_methods.rb