Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
payjpv2 (1.1.0)
payjpv2 (1.2.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Ruby client library for the PAY.JP v2 API. This SDK provides a convenient way
This Ruby gem is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 2.0.0
- Package version: 1.1.0
- Package version: 1.2.0
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen

Expand All @@ -26,7 +26,7 @@ gem install payjpv2
Add this line to your application's Gemfile:

```ruby
gem 'payjpv2', '~> 1.1.0'
gem 'payjpv2', '~> 1.2.0'
```

Then execute:
Expand Down Expand Up @@ -196,6 +196,7 @@ Class | Method | HTTP request | Description
*PAYJPv2::BalancesApi* | [**get_all_balances**](docs/BalancesApi.md#get_all_balances) | **GET** /v2/balances | Get All Balances
*PAYJPv2::BalancesApi* | [**get_balance**](docs/BalancesApi.md#get_balance) | **GET** /v2/balances/{balance_id} | Get Balance
*PAYJPv2::CheckoutSessionsApi* | [**create_checkout_session**](docs/CheckoutSessionsApi.md#create_checkout_session) | **POST** /v2/checkout/sessions | Create Checkout Session
*PAYJPv2::CheckoutSessionsApi* | [**expire_checkout_session**](docs/CheckoutSessionsApi.md#expire_checkout_session) | **POST** /v2/checkout/sessions/{checkout_session_id}/expire | Expire Checkout Session
*PAYJPv2::CheckoutSessionsApi* | [**get_all_checkout_session_line_items**](docs/CheckoutSessionsApi.md#get_all_checkout_session_line_items) | **GET** /v2/checkout/sessions/{checkout_session_id}/line_items | Get All Checkout Session Line Items
*PAYJPv2::CheckoutSessionsApi* | [**get_all_checkout_sessions**](docs/CheckoutSessionsApi.md#get_all_checkout_sessions) | **GET** /v2/checkout/sessions | Get All Checkout Sessions
*PAYJPv2::CheckoutSessionsApi* | [**get_checkout_session**](docs/CheckoutSessionsApi.md#get_checkout_session) | **GET** /v2/checkout/sessions/{checkout_session_id} | Get Checkout Session
Expand Down
70 changes: 70 additions & 0 deletions docs/CheckoutSessionsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *http://localhost*
| Method | HTTP request | Description |
| ------ | ------------ | ----------- |
| [**create_checkout_session**](CheckoutSessionsApi.md#create_checkout_session) | **POST** /v2/checkout/sessions | Create Checkout Session |
| [**expire_checkout_session**](CheckoutSessionsApi.md#expire_checkout_session) | **POST** /v2/checkout/sessions/{checkout_session_id}/expire | Expire Checkout Session |
| [**get_all_checkout_session_line_items**](CheckoutSessionsApi.md#get_all_checkout_session_line_items) | **GET** /v2/checkout/sessions/{checkout_session_id}/line_items | Get All Checkout Session Line Items |
| [**get_all_checkout_sessions**](CheckoutSessionsApi.md#get_all_checkout_sessions) | **GET** /v2/checkout/sessions | Get All Checkout Sessions |
| [**get_checkout_session**](CheckoutSessionsApi.md#get_checkout_session) | **GET** /v2/checkout/sessions/{checkout_session_id} | Get Checkout Session |
Expand Down Expand Up @@ -80,6 +81,75 @@ end
- **Accept**: application/json, application/problem+json


## expire_checkout_session

> <CheckoutSessionDetailsResponse> expire_checkout_session(checkout_session_id)

Expire Checkout Session

### Examples

```ruby
require 'time'
require 'payjpv2'
# setup authorization
PAYJPv2.configure do |config|
# Configure HTTP basic authorization: HTTPBasic
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'

# Configure Bearer authorization: HTTPBearer
config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PAYJPv2::CheckoutSessionsApi.new
checkout_session_id = 'checkout_session_id_example' # String |

begin
# Expire Checkout Session
result = api_instance.expire_checkout_session(checkout_session_id)
p result
rescue PAYJPv2::ApiError => e
puts "Error when calling CheckoutSessionsApi->expire_checkout_session: #{e}"
end
```

#### Using the include_http_info option

To get response data along with status code and headers, use the `include_http_info: true` option.

```ruby
begin
# Expire Checkout Session
data, status_code, headers = api_instance.expire_checkout_session(checkout_session_id, { include_http_info: true })
p status_code # => 2xx
p headers # => { ... }
p data # => <CheckoutSessionDetailsResponse>
rescue PAYJPv2::ApiError => e
puts "Error when calling CheckoutSessionsApi->expire_checkout_session: #{e}"
end
```

### Parameters

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **checkout_session_id** | **String** | | |

### Return type

[**CheckoutSessionDetailsResponse**](CheckoutSessionDetailsResponse.md)

### Authorization

[HTTPBasic](../README.md#HTTPBasic), [HTTPBearer](../README.md#HTTPBearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json, application/problem+json


## get_all_checkout_session_line_items

> <CheckoutSessionLineItemListResponse> get_all_checkout_session_line_items(checkout_session_id, opts)
Expand Down
2 changes: 1 addition & 1 deletion docs/SetupFlowCancelRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |
| **cancellation_reason** | [**SetupFlowCancellationReason**](SetupFlowCancellationReason.md) | この SetupFlow のキャンセル理由。 | 値 | |:---| | **abandoned**: 顧客が SetupFlow を完了しなかった場合。 | | **requested_by_customer**: 顧客がキャンセルを要求した場合。 | | **duplicate**: 支払い方法が重複している場合。 | | [optional] |
| **cancellation_reason** | [**SetupFlowCancellationReason**](SetupFlowCancellationReason.md) | この SetupFlow のキャンセル理由。 | 値 | |:---| | **abandoned**: 顧客が SetupFlow を完了しなかった場合。 | | **requested_by_customer**: 顧客がキャンセルを要求した場合。 | | **duplicate**: 支払い方法が重複している場合。 | &#x60;expired&#x60; はシステムが自動的に設定する値のため、リクエストでは指定できません。 | [optional] |

## Example

Expand Down
60 changes: 60 additions & 0 deletions lib/payjpv2/api/checkout_sessions_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,66 @@ def create_checkout_session(checkout_session_create_request, opts = {})
end
end

# Expire Checkout Session
# @param checkout_session_id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :idempotency_key Idempotency key for the request
# @option opts [Boolean] :include_http_info If true, returns [data, status_code, headers] instead of just data
# @return [CheckoutSessionDetailsResponse, Array] Returns data or [data, status_code, headers] if include_http_info is true
def expire_checkout_session(checkout_session_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: CheckoutSessionsApi.expire_checkout_session ...'
end
# verify the required parameter 'checkout_session_id' is set
if @api_client.config.client_side_validation && checkout_session_id.nil?
raise ArgumentError, "Missing the required parameter 'checkout_session_id' when calling CheckoutSessionsApi.expire_checkout_session"
end
# resource path
local_var_path = '/v2/checkout/sessions/{checkout_session_id}/expire'.sub('{' + 'checkout_session_id' + '}', CGI.escape(checkout_session_id.to_s))

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
header_params['Idempotency-Key'] = opts[:idempotency_key] if opts[:idempotency_key]
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json']) unless header_params['Accept']

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body]

# return_type
return_type = opts[:debug_return_type] || 'CheckoutSessionDetailsResponse'

# auth_names
auth_names = opts[:debug_auth_names] || ['HTTPBasic', 'HTTPBearer']

new_options = opts.merge(
:operation => :"CheckoutSessionsApi.expire_checkout_session",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: CheckoutSessionsApi#expire_checkout_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end

if opts[:include_http_info]
[data, status_code, headers]
else
data
end
end

# Get All Checkout Session Line Items
# @param checkout_session_id [String]
# @param [Hash] opts the optional parameters
Expand Down
14 changes: 14 additions & 0 deletions lib/payjpv2/models/line_item_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ def quantity=(quantity)
@quantity = quantity
end

# Custom attribute writer method with validation
# @param [Object] tax_rates Value to be assigned
def tax_rates=(tax_rates)
if tax_rates.nil?
raise ArgumentError, 'tax_rates cannot be nil'
end

if tax_rates.length > 1
raise ArgumentError, 'invalid value for "tax_rates", number of items must be less than or equal to 1.'
end

@tax_rates = tax_rates
end

# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
Expand Down
2 changes: 1 addition & 1 deletion lib/payjpv2/models/setup_flow_cancel_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

module PAYJPv2
class SetupFlowCancelRequest
# この SetupFlow のキャンセル理由。 | 値 | |:---| | **abandoned**: 顧客が SetupFlow を完了しなかった場合。 | | **requested_by_customer**: 顧客がキャンセルを要求した場合。 | | **duplicate**: 支払い方法が重複している場合。 |
# この SetupFlow のキャンセル理由。 | 値 | |:---| | **abandoned**: 顧客が SetupFlow を完了しなかった場合。 | | **requested_by_customer**: 顧客がキャンセルを要求した場合。 | | **duplicate**: 支払い方法が重複している場合。 | `expired` はシステムが自動的に設定する値のため、リクエストでは指定できません。
attr_accessor :cancellation_reason

class EnumAttributeValidator
Expand Down
3 changes: 2 additions & 1 deletion lib/payjpv2/models/setup_flow_cancellation_reason.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ module PAYJPv2
class SetupFlowCancellationReason
ABANDONED = "abandoned".freeze
DUPLICATE = "duplicate".freeze
EXPIRED = "expired".freeze
REQUESTED_BY_CUSTOMER = "requested_by_customer".freeze

def self.all_vars
@all_vars ||= [ABANDONED, DUPLICATE, REQUESTED_BY_CUSTOMER].freeze
@all_vars ||= [ABANDONED, DUPLICATE, EXPIRED, REQUESTED_BY_CUSTOMER].freeze
end

# Builds the enum from string
Expand Down
2 changes: 1 addition & 1 deletion lib/payjpv2/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
=end

module PAYJPv2
VERSION = '1.1.0'
VERSION = '1.2.0'
end
33 changes: 33 additions & 0 deletions spec/api/checkout_sessions_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@
end
end

# unit tests for expire_checkout_session
# Expire Checkout Session
# @param checkout_session_id
# @param [Hash] opts the optional parameters
# @return [CheckoutSessionDetailsResponse]
describe 'expire_checkout_session test' do
it 'should work' do
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
end

describe 'with mocked api_client' do
let(:mock_data) { double('data') }
let(:mock_status) { 200 }
let(:mock_headers) { { 'Content-Type' => 'application/json' } }

before do
@api_instance.api_client.config.client_side_validation = false
allow(@api_instance.api_client).to receive(:call_api)
.and_return([mock_data, mock_status, mock_headers])
end

it 'returns data only by default' do
result = @api_instance.expire_checkout_session(nil)
expect(result).to eq(mock_data)
end

it 'returns [data, status, headers] with include_http_info: true' do
result = @api_instance.expire_checkout_session(nil, include_http_info: true)
expect(result).to eq([mock_data, mock_status, mock_headers])
end
end
end

# unit tests for get_all_checkout_session_line_items
# Get All Checkout Session Line Items
# @param checkout_session_id
Expand Down
Loading