Sha256: d96f2d34df37a627c2d2829e95867312ffaf9c4990711e0a21310ee9df004482

Contents?: true

Size: 1.64 KB

Versions: 12

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __dir__)

module Stripe
  module Checkout
    class SessionTest < Test::Unit::TestCase
      should "be creatable" do
        session = Stripe::Checkout::Session.create(
          cancel_url: "https://stripe.com/cancel",
          client_reference_id: "1234",
          line_items: [
            {
              amount: 123,
              currency: "usd",
              description: "item 1",
              images: [
                "https://stripe.com/img1",
              ],
              name: "name",
              quantity: 2,
            },
          ],
          payment_intent_data: [
            receipt_email: "test@stripe.com",
          ],
          payment_method_types: ["card"],
          success_url: "https://stripe.com/success"
        )
        assert_requested :post, "#{Stripe.api_base}/v1/checkout/sessions"
        assert session.is_a?(Stripe::Checkout::Session)
      end

      should "be retrievable" do
        charge = Stripe::Checkout::Session.retrieve("cs_123")
        assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123"
        assert charge.is_a?(Stripe::Checkout::Session)
      end

      context "#list_line_items" do
        should "list the session's line items" do
          sources = Stripe::Checkout::Session.list_line_items(
            "cs_123"
          )
          assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123/line_items"
          assert sources.is_a?(Stripe::ListObject)
          assert sources.data.is_a?(Array)
          assert sources.data[0].is_a?(Stripe::LineItem)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
stripe-5.31.0 test/stripe/checkout/session_test.rb
stripe-5.30.0 test/stripe/checkout/session_test.rb
stripe-5.29.1 test/stripe/checkout/session_test.rb
stripe-5.29.0 test/stripe/checkout/session_test.rb
stripe-5.28.0 test/stripe/checkout/session_test.rb
stripe-5.27.0 test/stripe/checkout/session_test.rb
stripe-5.26.0 test/stripe/checkout/session_test.rb
stripe-5.25.0 test/stripe/checkout/session_test.rb
stripe-5.24.0 test/stripe/checkout/session_test.rb
stripe-5.23.1 test/stripe/checkout/session_test.rb
stripe-5.23.0 test/stripe/checkout/session_test.rb
stripe-5.22.0 test/stripe/checkout/session_test.rb