A Ruby client library for the PAY.JP v2 API. This SDK provides a convenient way to interact with PAY.JP's payment processing services from Ruby applications.
This Ruby gem is automatically generated by the OpenAPI Generator project:
- API version: 2.0.0
- Package version: 0.0.1
- Generator version: 7.14.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
Ruby 3.2+
gem install payjpv2Add this line to your application's Gemfile:
gem 'payjpv2', '~> 0.0.1'Then execute:
bundle installIf you want to use the latest development version, add this to your Gemfile:
gem 'payjpv2', git: 'https://github.com/payjp/payjpv2-ruby.git'Then import the package:
require 'payjpv2'Please follow the installation procedure and then run the following:
require 'payjpv2'
require 'securerandom'
# Configure Bearer authentication with API key
# You can set your API key via environment variable or directly in code
PAYJPv2.configure do |config|
config.access_token = ENV['PAYJP_API_KEY']
end
# Create API instance
customers_api = PAYJPv2::CustomersApi.new
begin
# Create a customer with idempotency key
customer_request = PAYJPv2::CustomerCreateRequest.new(
email: 'customer@example.com',
description: 'Test customer'
)
idempotency_key = SecureRandom.uuid
customer = customers_api.create_customer(
customer_request,
idempotency_key: idempotency_key
)
puts "Created customer: #{customer.id}"
puts "Email: #{customer.email}"
# Retrieve a customer
retrieved = customers_api.get_customer(customer.id)
puts "Retrieved customer: #{retrieved.id}"
# List customers with pagination
customer_list = customers_api.get_all_customers(limit: 10)
customer_list.data.each do |c|
puts " - #{c.id} (#{c.email || 'no email'})"
end
rescue PAYJPv2::ApiError => e
puts "API Error: #{e.message}"
puts "HTTP status code: #{e.code}" if e.code
endFor security, it's recommended to store your API key in environment variables:
export PAYJP_API_KEY=sk_test_xxxxxxxxxxxxPAYJPv2.configure do |config|
# API Host (optional, defaults to https://api.pay.jp)
config.host = 'https://api.pay.jp'
# Bearer authentication (recommended)
config.access_token = ENV['PAYJP_API_KEY']
# Or use a proc to dynamically fetch the token
config.access_token_getter = -> { fetch_token_from_secure_storage }
endPAY.JP supports idempotency keys to safely retry requests without accidentally performing the same operation twice:
require 'securerandom'
idempotency_key = SecureRandom.uuid
customer = customers_api.create_customer(
customer_request,
idempotency_key: idempotency_key
)By default, API methods return only the response data. If you need access to the HTTP status code and headers, use the include_http_info option:
# Default: returns data only
customer = customers_api.get_customer('cus_xxxxx')
# With include_http_info: returns [data, status_code, headers]
data, status_code, headers = customers_api.get_customer(
'cus_xxxxx',
include_http_info: true
)
puts "Status: #{status_code}" # => 200
puts "Headers: #{headers}" # => { "Content-Type" => "application/json", ... }
puts "Customer ID: #{data.id}" # => "cus_xxxxx"The SDK raises PAYJPv2::ApiError exceptions for API errors:
begin
customer = customers_api.create_customer(customer_request)
rescue PAYJPv2::ApiError => e
puts "Error: #{e.message}"
puts "Status code: #{e.code}" if e.code
puts "Response body: #{e.response_body}" if e.response_body
puts "Response headers: #{e.response_headers}" if e.response_headers
ende.message- Error messagee.code- HTTP status codee.response_body- Raw response bodye.response_headers- Response headers
400- Invalid request parameters401- Authentication error (invalid API key)403- Permission error404- Resource not found429- Rate limit exceeded500- Internal server error
All URIs are relative to http://localhost
| Class | Method | HTTP request | Description |
|---|---|---|---|
| PAYJPv2::BalancesApi | create_balance_url | POST /v2/balances/{balance_id}/balance_urls | Create Balance Url |
| PAYJPv2::BalancesApi | get_all_balances | GET /v2/balances | Get All Balances |
| PAYJPv2::BalancesApi | get_balance | GET /v2/balances/{balance_id} | Get Balance |
| PAYJPv2::CheckoutSessionsApi | create_checkout_session | POST /v2/checkout/sessions | Create Checkout Session |
| PAYJPv2::CheckoutSessionsApi | 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 | GET /v2/checkout/sessions | Get All Checkout Sessions |
| PAYJPv2::CheckoutSessionsApi | get_checkout_session | GET /v2/checkout/sessions/{checkout_session_id} | Get Checkout Session |
| PAYJPv2::CheckoutSessionsApi | update_checkout_session | POST /v2/checkout/sessions/{checkout_session_id} | Update Checkout Session |
| PAYJPv2::CustomersApi | create_customer | POST /v2/customers | Create Customer |
| PAYJPv2::CustomersApi | delete_customer | DELETE /v2/customers/{customer_id} | Delete Customer |
| PAYJPv2::CustomersApi | get_all_customers | GET /v2/customers | Get All Customers |
| PAYJPv2::CustomersApi | get_customer | GET /v2/customers/{customer_id} | Get Customer |
| PAYJPv2::CustomersApi | get_customer_payment_methods | GET /v2/customers/{customer_id}/payment_methods | Get Customer Payment Methods |
| PAYJPv2::CustomersApi | update_customer | POST /v2/customers/{customer_id} | Update Customer |
| PAYJPv2::EventsApi | get_all_events | GET /v2/events | Get All Events |
| PAYJPv2::EventsApi | get_event | GET /v2/events/{event_id} | Get Event |
| PAYJPv2::PaymentFlowsApi | cancel_payment_flow | POST /v2/payment_flows/{payment_flow_id}/cancel | Cancel Payment Flow |
| PAYJPv2::PaymentFlowsApi | capture_payment_flow | POST /v2/payment_flows/{payment_flow_id}/capture | Capture Payment Flow |
| PAYJPv2::PaymentFlowsApi | confirm_payment_flow | POST /v2/payment_flows/{payment_flow_id}/confirm | Confirm Payment Flow |
| PAYJPv2::PaymentFlowsApi | create_payment_flow | POST /v2/payment_flows | Create Payment Flow |
| PAYJPv2::PaymentFlowsApi | get_all_payment_flows | GET /v2/payment_flows | Get All Payment Flows |
| PAYJPv2::PaymentFlowsApi | get_payment_flow | GET /v2/payment_flows/{payment_flow_id} | Get Payment Flow |
| PAYJPv2::PaymentFlowsApi | get_payment_flow_refunds | GET /v2/payment_flows/{payment_flow_id}/refunds | Get Payment Flow Refunds |
| PAYJPv2::PaymentFlowsApi | update_payment_flow | POST /v2/payment_flows/{payment_flow_id} | Update Payment Flow |
| PAYJPv2::PaymentMethodConfigurationsApi | get_all_payment_method_configurations | GET /v2/payment_method_configurations | Get All Payment Method Configurations |
| PAYJPv2::PaymentMethodConfigurationsApi | get_payment_method_configuration | GET /v2/payment_method_configurations/{payment_method_configuration_id} | Get Payment Method Configuration |
| PAYJPv2::PaymentMethodConfigurationsApi | update_payment_method_configuration | POST /v2/payment_method_configurations/{payment_method_configuration_id} | Update Payment Method Configuration |
| PAYJPv2::PaymentMethodsApi | attach_payment_method | POST /v2/payment_methods/{payment_method_id}/attach | Attach Payment Method |
| PAYJPv2::PaymentMethodsApi | create_payment_method | POST /v2/payment_methods | Create Payment Method |
| PAYJPv2::PaymentMethodsApi | detach_payment_method | POST /v2/payment_methods/{payment_method_id}/detach | Detach Payment Method |
| PAYJPv2::PaymentMethodsApi | get_all_payment_methods | GET /v2/payment_methods | Get All Payment Methods |
| PAYJPv2::PaymentMethodsApi | get_payment_method | GET /v2/payment_methods/{payment_method_id} | Get Payment Method |
| PAYJPv2::PaymentMethodsApi | get_payment_method_by_card | GET /v2/payment_methods/cards/{card_id} | Get Payment Method By Card |
| PAYJPv2::PaymentMethodsApi | update_payment_method | POST /v2/payment_methods/{payment_method_id} | Update Payment Method |
| PAYJPv2::PaymentRefundsApi | create_payment_refund | POST /v2/payment_refunds | Create Payment Refund |
| PAYJPv2::PaymentRefundsApi | get_all_payment_refunds | GET /v2/payment_refunds | Get All Payment Refunds |
| PAYJPv2::PaymentRefundsApi | get_payment_refund | GET /v2/payment_refunds/{payment_refund_id} | Get Payment Refund |
| PAYJPv2::PaymentRefundsApi | update_payment_refund | POST /v2/payment_refunds/{payment_refund_id} | Update Payment Refund |
| PAYJPv2::PaymentTransactionsApi | get_all_payment_transactions | GET /v2/payment_transactions | Get All Payment Transactions |
| PAYJPv2::PaymentTransactionsApi | get_payment_transaction | GET /v2/payment_transactions/{payment_transaction_id} | Get Payment Transaction |
| PAYJPv2::PricesApi | create_price | POST /v2/prices | Create Price |
| PAYJPv2::PricesApi | get_all_prices | GET /v2/prices | Get All Prices |
| PAYJPv2::PricesApi | get_price | GET /v2/prices/{price_id} | Get Price |
| PAYJPv2::PricesApi | update_price | POST /v2/prices/{price_id} | Update Price |
| PAYJPv2::ProductsApi | create_product | POST /v2/products | Create Product |
| PAYJPv2::ProductsApi | delete_product | DELETE /v2/products/{product_id} | Delete Product |
| PAYJPv2::ProductsApi | get_all_products | GET /v2/products | Get All Products |
| PAYJPv2::ProductsApi | get_product | GET /v2/products/{product_id} | Get Product |
| PAYJPv2::ProductsApi | update_product | POST /v2/products/{product_id} | Update Product |
| PAYJPv2::SetupFlowsApi | cancel_setup_flow | POST /v2/setup_flows/{setup_flow_id}/cancel | Cancel Setup Flow |
| PAYJPv2::SetupFlowsApi | create_setup_flow | POST /v2/setup_flows | Create Setup Flow |
| PAYJPv2::SetupFlowsApi | get_all_setup_flows | GET /v2/setup_flows | Get All Setup Flows |
| PAYJPv2::SetupFlowsApi | get_setup_flow | GET /v2/setup_flows/{setup_flow_id} | Get Setup Flow |
| PAYJPv2::SetupFlowsApi | update_setup_flow | POST /v2/setup_flows/{setup_flow_id} | Update Setup Flow |
| PAYJPv2::StatementsApi | create_statement_url | POST /v2/statements/{statement_id}/statement_urls | Create Statement Url |
| PAYJPv2::StatementsApi | get_all_statements | GET /v2/statements | Get All Statements |
| PAYJPv2::StatementsApi | get_statement | GET /v2/statements/{statement_id} | Get Statement |
| PAYJPv2::TaxRatesApi | create_tax_rate | POST /v2/tax_rates | Create Tax Rate |
| PAYJPv2::TaxRatesApi | get_all_tax_rates | GET /v2/tax_rates | Get All Tax Rates |
| PAYJPv2::TaxRatesApi | get_tax_rate | GET /v2/tax_rates/{tax_rate_id} | Get Tax Rate |
| PAYJPv2::TaxRatesApi | update_tax_rate | POST /v2/tax_rates/{tax_rate_id} | Update Tax Rate |
| PAYJPv2::TermsApi | get_all_terms | GET /v2/terms | Get All Terms |
| PAYJPv2::TermsApi | get_term | GET /v2/terms/{term_id} | Get Term |
- PAYJPv2::BalanceListResponse
- PAYJPv2::BalanceResponse
- PAYJPv2::BalanceState
- PAYJPv2::BalanceURLResponse
- PAYJPv2::BankInfoResponse
- PAYJPv2::CaptureMethod
- PAYJPv2::CardConfigRequest
- PAYJPv2::CheckoutSessionCreateRequest
- PAYJPv2::CheckoutSessionCustomerDetailsAddressResponse
- PAYJPv2::CheckoutSessionCustomerDetailsResponse
- PAYJPv2::CheckoutSessionDetailsResponse
- PAYJPv2::CheckoutSessionLineItemDataResponse
- PAYJPv2::CheckoutSessionLineItemListResponse
- PAYJPv2::CheckoutSessionListResponse
- PAYJPv2::CheckoutSessionMode
- PAYJPv2::CheckoutSessionPaymentMethodOptionsCardRequest
- PAYJPv2::CheckoutSessionPaymentMethodOptionsRequest
- PAYJPv2::CheckoutSessionStatus
- PAYJPv2::CheckoutSessionSubmitType
- PAYJPv2::CheckoutSessionUIMode
- PAYJPv2::CheckoutSessionUpdateRequest
- PAYJPv2::Country
- PAYJPv2::Currency
- PAYJPv2::CustomerCreateRequest
- PAYJPv2::CustomerCreation
- PAYJPv2::CustomerListResponse
- PAYJPv2::CustomerResponse
- PAYJPv2::CustomerUpdateRequest
- PAYJPv2::DisplayPreferenceRequest
- PAYJPv2::ErrorResponse
- PAYJPv2::EventListResponse
- PAYJPv2::EventResponse
- PAYJPv2::LineItemRequest
- PAYJPv2::Locale
- PAYJPv2::MetadataValue
- PAYJPv2::PayPayConfigRequest
- PAYJPv2::PaymentFlowCancelRequest
- PAYJPv2::PaymentFlowCancellationReason
- PAYJPv2::PaymentFlowCaptureRequest
- PAYJPv2::PaymentFlowConfirmRequest
- PAYJPv2::PaymentFlowCreateRequest
- PAYJPv2::PaymentFlowDataRequest
- PAYJPv2::PaymentFlowListResponse
- PAYJPv2::PaymentFlowPaymentMethodOptionsCardRequest
- PAYJPv2::PaymentFlowPaymentMethodOptionsRequest
- PAYJPv2::PaymentFlowResponse
- PAYJPv2::PaymentFlowStatus
- PAYJPv2::PaymentFlowUpdateRequest
- PAYJPv2::PaymentMethodApplePayCreateRequest
- PAYJPv2::PaymentMethodApplePayUpdateRequest
- PAYJPv2::PaymentMethodAttachRequest
- PAYJPv2::PaymentMethodBillingAddressRequest
- PAYJPv2::PaymentMethodBillingAddressResponse
- PAYJPv2::PaymentMethodBillingDetailsRequest
- PAYJPv2::PaymentMethodBillingDetailsResponse
- PAYJPv2::PaymentMethodCardBillingDetailsRequest
- PAYJPv2::PaymentMethodCardCreateRequest
- PAYJPv2::PaymentMethodCardDetailsResponse
- PAYJPv2::PaymentMethodCardResponse
- PAYJPv2::PaymentMethodCardUpdateRequest
- PAYJPv2::PaymentMethodConfigurationDetailsResponse
- PAYJPv2::PaymentMethodConfigurationDisplayPreference
- PAYJPv2::PaymentMethodConfigurationListResponse
- PAYJPv2::PaymentMethodConfigurationSettingResponse
- PAYJPv2::PaymentMethodConfigurationUpdateRequest
- PAYJPv2::PaymentMethodCreateCardDetailsRequest
- PAYJPv2::PaymentMethodCreateRequest
- PAYJPv2::PaymentMethodListResponse
- PAYJPv2::PaymentMethodPayPayCreateRequest
- PAYJPv2::PaymentMethodPayPayResponse
- PAYJPv2::PaymentMethodPayPayUpdateRequest
- PAYJPv2::PaymentMethodResponse
- PAYJPv2::PaymentMethodTypes
- PAYJPv2::PaymentMethodUpdateRequest
- PAYJPv2::PaymentRefundCreateRequest
- PAYJPv2::PaymentRefundListResponse
- PAYJPv2::PaymentRefundReason
- PAYJPv2::PaymentRefundResponse
- PAYJPv2::PaymentRefundStatus
- PAYJPv2::PaymentRefundUpdateRequest
- PAYJPv2::PaymentTransactionListResponse
- PAYJPv2::PaymentTransactionResponse
- PAYJPv2::PaymentTransactionType
- PAYJPv2::PriceCreateRequest
- PAYJPv2::PriceDetailsResponse
- PAYJPv2::PriceListResponse
- PAYJPv2::PriceType
- PAYJPv2::PriceUpdateRequest
- PAYJPv2::ProductCreateRequest
- PAYJPv2::ProductDeletedResponse
- PAYJPv2::ProductDetailsResponse
- PAYJPv2::ProductListResponse
- PAYJPv2::ProductUpdateRequest
- PAYJPv2::SetupFlowCancelRequest
- PAYJPv2::SetupFlowCancellationReason
- PAYJPv2::SetupFlowCreateRequest
- PAYJPv2::SetupFlowDataRequest
- PAYJPv2::SetupFlowListResponse
- PAYJPv2::SetupFlowPaymentMethodOptionsCardRequest
- PAYJPv2::SetupFlowPaymentMethodOptionsRequest
- PAYJPv2::SetupFlowResponse
- PAYJPv2::SetupFlowStatus
- PAYJPv2::SetupFlowUpdateRequest
- PAYJPv2::StatementItemResponse
- PAYJPv2::StatementListResponse
- PAYJPv2::StatementResponse
- PAYJPv2::StatementSubject
- PAYJPv2::StatementType
- PAYJPv2::StatementURLResponse
- PAYJPv2::TaxRateCreateRequest
- PAYJPv2::TaxRateDetailsResponse
- PAYJPv2::TaxRateListResponse
- PAYJPv2::TaxRateUpdateRequest
- PAYJPv2::TermListResponse
- PAYJPv2::TermResponse
- PAYJPv2::Usage
Authentication schemes defined for the API:
- Type: HTTP basic authentication
- Type: Bearer authentication