Class: Mpp::Methods::Stripe::StripeMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/mpp/methods/stripe/stripe_method.rb

Overview

Stripe payment method implementation. Handles SPT-based payments through Stripe’s Business Network.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key:, network_id:, payment_methods: nil, metadata: nil, currency: Defaults::DEFAULT_CURRENCY, decimals: Defaults::DEFAULT_DECIMALS) ⇒ StripeMethod

Returns a new instance of StripeMethod.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 15

def initialize(secret_key:, network_id:, payment_methods: nil,
  metadata: nil, currency: Defaults::DEFAULT_CURRENCY,
  decimals: Defaults::DEFAULT_DECIMALS)
  @name = "stripe"
  @secret_key = secret_key
  @network_id = network_id
  @payment_methods = payment_methods
  @metadata = 
  @currency = currency
  @recipient = network_id
  @decimals = decimals
  @intents = {}
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



12
13
14
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 12

def currency
  @currency
end

#decimalsObject (readonly)

Returns the value of attribute decimals.



12
13
14
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 12

def decimals
  @decimals
end

#intentsObject

Returns the value of attribute intents.



13
14
15
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 13

def intents
  @intents
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 12

def name
  @name
end

#recipientObject (readonly)

Returns the value of attribute recipient.



12
13
14
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 12

def recipient
  @recipient
end

Instance Method Details

#transform_request(request, _credential) ⇒ Object

Transform request - injects Stripe-specific methodDetails.



30
31
32
33
34
35
36
37
38
39
# File 'lib/mpp/methods/stripe/stripe_method.rb', line 30

def transform_request(request, _credential)
  method_details = request.fetch("methodDetails", {})
  method_details = {} unless method_details.is_a?(Hash)

  method_details["networkId"] = @network_id
  method_details["paymentMethods"] = @payment_methods if @payment_methods
  method_details["metadata"] = @metadata if @metadata

  request.merge("methodDetails" => method_details)
end