mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-08 00:01:02 -05:00
Merge pull request #716 from stripe/remi-add-checkout-sessions
Add support for Checkout Sessions
This commit is contained in:
commit
b99ed974d4
@ -17,7 +17,7 @@ sudo: false
|
|||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
# If changing this number, please also change it in `test/test_helper.rb`.
|
# If changing this number, please also change it in `test/test_helper.rb`.
|
||||||
- STRIPE_MOCK_VERSION=0.39.0
|
- STRIPE_MOCK_VERSION=0.40.0
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
|||||||
@ -49,6 +49,7 @@ require "stripe/bitcoin_receiver"
|
|||||||
require "stripe/bitcoin_transaction"
|
require "stripe/bitcoin_transaction"
|
||||||
require "stripe/card"
|
require "stripe/card"
|
||||||
require "stripe/charge"
|
require "stripe/charge"
|
||||||
|
require "stripe/checkout_session"
|
||||||
require "stripe/country_spec"
|
require "stripe/country_spec"
|
||||||
require "stripe/coupon"
|
require "stripe/coupon"
|
||||||
require "stripe/customer"
|
require "stripe/customer"
|
||||||
|
|||||||
9
lib/stripe/checkout_session.rb
Normal file
9
lib/stripe/checkout_session.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Stripe
|
||||||
|
class CheckoutSession < APIResource
|
||||||
|
extend Stripe::APIOperations::Create
|
||||||
|
|
||||||
|
OBJECT_NAME = "checkout_session".freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -58,6 +58,7 @@ module Stripe
|
|||||||
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
||||||
Card::OBJECT_NAME => Card,
|
Card::OBJECT_NAME => Card,
|
||||||
Charge::OBJECT_NAME => Charge,
|
Charge::OBJECT_NAME => Charge,
|
||||||
|
CheckoutSession::OBJECT_NAME => CheckoutSession,
|
||||||
CountrySpec::OBJECT_NAME => CountrySpec,
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
||||||
Coupon::OBJECT_NAME => Coupon,
|
Coupon::OBJECT_NAME => Coupon,
|
||||||
Customer::OBJECT_NAME => Customer,
|
Customer::OBJECT_NAME => Customer,
|
||||||
|
|||||||
33
test/stripe/checkout_session_test.rb
Normal file
33
test/stripe/checkout_session_test.rb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require ::File.expand_path("../../test_helper", __FILE__)
|
||||||
|
|
||||||
|
module Stripe
|
||||||
|
class CheckoutSessionTest < Test::Unit::TestCase
|
||||||
|
should "be creatable" do
|
||||||
|
session = Stripe::CheckoutSession.create(
|
||||||
|
allowed_source_types: ["card"],
|
||||||
|
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",
|
||||||
|
],
|
||||||
|
success_url: "https://stripe.com/success"
|
||||||
|
)
|
||||||
|
assert_requested :post, "#{Stripe.api_base}/v1/checkout_sessions"
|
||||||
|
assert session.is_a?(Stripe::CheckoutSession)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -16,7 +16,7 @@ PROJECT_ROOT = ::File.expand_path("../../", __FILE__)
|
|||||||
require ::File.expand_path("../test_data", __FILE__)
|
require ::File.expand_path("../test_data", __FILE__)
|
||||||
|
|
||||||
# If changing this number, please also change it in `.travis.yml`.
|
# If changing this number, please also change it in `.travis.yml`.
|
||||||
MOCK_MINIMUM_VERSION = "0.39.0".freeze
|
MOCK_MINIMUM_VERSION = "0.40.0".freeze
|
||||||
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
|
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111
|
||||||
|
|
||||||
# Disable all real network connections except those that are outgoing to
|
# Disable all real network connections except those that are outgoing to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user