Class: Twilio::REST::Api::V2010::AccountContext::CallContext::PaymentContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/call/payment.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected]

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, call_sid, sid) ⇒ PaymentContext

Initialize the PaymentContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the Account that will update the resource.

  • call_sid (String)

    The SID of the call that will update the resource. This should be the same call sid that was used to create payments resource.

  • sid (String)

    The SID of Payments session that needs to be updated.


179
180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 179

def initialize(version, , call_sid, sid)
  super(version)

  # Path Solution
  @solution = {account_sid: , call_sid: call_sid, sid: sid, }
  @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Payments/#{@solution[:sid]}.json"
end

Instance Method Details

#inspectObject

Provide a detailed, user friendly representation


235
236
237
238
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 235

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Api.V2010.PaymentContext #{context}>"
end

#to_sObject

Provide a user friendly representation


228
229
230
231
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 228

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Api.V2010.PaymentContext #{context}>"
end

#update(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset) ⇒ PaymentInstance

Update the PaymentInstance

Parameters:

  • idempotency_key (String) (defaults to: nil)

    A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.

  • status_callback (String) (defaults to: nil)

    Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the Update and Complete/Cancel POST requests.

  • capture (payment.Capture) (defaults to: :unset)

    The piece of payment information that you wish the caller to enter. Must be one of `payment-card-number`, `expiration-date`, `security-code`, `postal-code`, `bank-routing-number`, or `bank-account-number`.

  • status (payment.Status) (defaults to: :unset)

    Indicates whether the current payment session should be cancelled or completed. When `cancel` the payment session is cancelled. When `complete`, Twilio sends the payment information to the selected <Pay> connector for processing.

Returns:


207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/twilio-ruby/rest/api/v2010/account/call/payment.rb', line 207

def update(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset)
  data = Twilio::Values.of({
      'IdempotencyKey' => idempotency_key,
      'StatusCallback' => status_callback,
      'Capture' => capture,
      'Status' => status,
  })

  payload = @version.update('POST', @uri, data: data)

  PaymentInstance.new(
      @version,
      payload,
      account_sid: @solution[:account_sid],
      call_sid: @solution[:call_sid],
      sid: @solution[:sid],
  )
end