Class: RippleRest::Payment

Inherits:
RestObject show all
Defined in:
lib/ripple-rest/generated-schemas.rb,
lib/ripple-rest/schemas.rb,
lib/ripple-rest/generated-schemas.rb

Overview

A flattened Payment object used by the ripple-rest API

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RestObject

#initialize, #to_hash

Constructor Details

This class inherits a constructor from RippleRest::RestObject

Instance Attribute Details

#client_resource_idString

Returns:

  • (String)


82
83
84
# File 'lib/ripple-rest/schemas.rb', line 82

def client_resource_id
  @client_resource_id
end

#destination_accountString<RippleAddress>

Returns:

  • (String<RippleAddress>)


265
# File 'lib/ripple-rest/generated-schemas.rb', line 265

property :destination_account, :RippleAddress

#destination_amountAmount

The amount the destination_account will receive

Returns:



276
# File 'lib/ripple-rest/generated-schemas.rb', line 276

property :destination_amount, :Amount

#destination_balance_changesArray<Amount>

Parsed from the validated transaction metadata, this array represents the changes to balances held by the destination_account. For those receiving payments this is important to check because if the partial_payment flag is set this value may be less than the destination_amount

Returns:



342
# File 'lib/ripple-rest/generated-schemas.rb', line 342

property :destination_balance_changes, [:Array, :Amount]

#destination_tagString<UINT32>

A string representing an unsigned 32-bit integer most commonly used to refer to a receiver’s hosted account at a Ripple gateway

Returns:

  • (String<UINT32>)


271
# File 'lib/ripple-rest/generated-schemas.rb', line 271

property :destination_tag, :UINT32

#directionString

The direction of the payment, from the perspective of the account being queried. Possible values are “incoming”, “outgoing”, and “passthrough”

Returns:

  • (String)

    “^incoming|outgoing|passthrough$”



302
# File 'lib/ripple-rest/generated-schemas.rb', line 302

property :direction, [:String, "^incoming|outgoing|passthrough$"]

#feeBigDecimal

The Ripple Network transaction fee, represented in whole XRP (NOT “drops”, or millionths of an XRP, which is used elsewhere in the Ripple protocol)

Returns:

  • (BigDecimal)


332
# File 'lib/ripple-rest/generated-schemas.rb', line 332

property :fee, :FloatString

#hashString<Hash256>

The 256-bit hash of the payment. This is used throughout the Ripple protocol as the unique identifier for the transaction

Returns:

  • (String<Hash256>)


322
# File 'lib/ripple-rest/generated-schemas.rb', line 322

property :hash, :Hash256

#invoice_idString<Hash256>

A 256-bit hash that can be used to identify a particular payment

Returns:

  • (String<Hash256>)


282
# File 'lib/ripple-rest/generated-schemas.rb', line 282

property :invoice_id, :Hash256

#ledgerString

The string representation of the index number of the ledger containing the validated or failed payment. Failed payments will only be written into the Ripple Ledger if they fail after submission to a rippled and a Ripple Network fee is claimed

Returns:

  • (String)

    “^[0-9]$”+



317
# File 'lib/ripple-rest/generated-schemas.rb', line 317

property :ledger, [:String, "^[0-9]+$"]

#no_direct_rippleBoolean

A boolean that can be set to true if paths are specified and the sender would like the Ripple Network to disregard any direct paths from the source_account to the destination_account. This may be used to take advantage of an arbitrage opportunity or by gateways wishing to issue balances from a hot wallet to a user who has mistakenly set a trustline directly to the hot wallet

Returns:

  • (Boolean)


297
# File 'lib/ripple-rest/generated-schemas.rb', line 297

property :no_direct_ripple, :Boolean

#partial_paymentBoolean

A boolean that, if set to true, indicates that this payment should go through even if the whole amount cannot be delivered because of a lack of liquidity or funds in the source_account account

Returns:

  • (Boolean)


292
# File 'lib/ripple-rest/generated-schemas.rb', line 292

property :partial_payment, :Boolean

#pathsString

A “stringified” version of the Ripple PathSet structure that users should treat as opaque

Returns:

  • (String)


287
# File 'lib/ripple-rest/generated-schemas.rb', line 287

property :paths, :String

#resultString

The rippled code indicating the success or failure type of the payment. The code “tesSUCCESS” indicates that the payment was successfully validated and written into the Ripple Ledger. All other codes will begin with the following prefixes: “tec”, “tef”, “tel”, or “tej”

Returns:

  • (String)

    te[A-Za-z_]”+



312
# File 'lib/ripple-rest/generated-schemas.rb', line 312

property :result, [:String, "te[cfjlms][A-Za-z_]+"]

#source_accountString<RippleAddress>

The Ripple account address of the Payment sender

Returns:

  • (String<RippleAddress>)


244
# File 'lib/ripple-rest/generated-schemas.rb', line 244

property :source_account, :RippleAddress

#source_amountAmount

An optional amount that can be specified to constrain cross-currency payments

Returns:



255
# File 'lib/ripple-rest/generated-schemas.rb', line 255

property :source_amount, :Amount

#source_balance_changesArray<Amount>

Parsed from the validated transaction metadata, this array represents all of the changes to balances held by the source_account. Most often this will have one amount representing the Ripple Network fee and, if the source_amount was not XRP, one amount representing the actual source_amount that was sent

Returns:



337
# File 'lib/ripple-rest/generated-schemas.rb', line 337

property :source_balance_changes, [:Array, :Amount]

#source_slippageBigDecimal

An optional cushion for the source_amount to increase the likelihood that the payment will succeed. The source_account will never be charged more than source_amount.value + source_slippage

Returns:

  • (BigDecimal)


260
# File 'lib/ripple-rest/generated-schemas.rb', line 260

property :source_slippage, :FloatString

#source_tagString<UINT32>

A string representing an unsigned 32-bit integer most commonly used to refer to a sender’s hosted account at a Ripple gateway

Returns:

  • (String<UINT32>)


250
# File 'lib/ripple-rest/generated-schemas.rb', line 250

property :source_tag, :UINT32

#stateString

The state of the payment from the perspective of the Ripple Ledger. Possible values are “validated” and “failed” and “new” if the payment has not been submitted yet

Returns:

  • (String)

    “^validated|failed|new$”



307
# File 'lib/ripple-rest/generated-schemas.rb', line 307

property :state, [:String, "^validated|failed|new$"]

#timestampTime

The timestamp representing when the payment was validated and written into the Ripple ledger

Returns:

  • (Time)


327
# File 'lib/ripple-rest/generated-schemas.rb', line 327

property :timestamp, :Timestamp

Instance Method Details

#accountObject

Gets Account object of this Payment’s source account



53
54
55
# File 'lib/ripple-rest/schemas.rb', line 53

def 
  @account
end

#account=(val) ⇒ Object

Sets source account and secret for this Payment

Parameters:



59
60
61
62
# File 'lib/ripple-rest/schemas.rb', line 59

def account= val
  @account = val
  self. = val.address
end

#submitString

Submits a payment

Returns:

  • (String)

    Client resource ID

Raises:

  • (ArgumentError)

    if secret is missing from the Account object

  • (RippleRestError)

    if RippleRest server returns an error

  • (ProtocolError)

    if protocol is wrong or network is down



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ripple-rest/schemas.rb', line 69

def submit
  @account.require_secret
  
  hash = {}
  hash["payment"] = self.to_hash
  hash["secret"] = @account.secret
  hash["client_resource_id"] = client_resource_id = RippleRest.next_uuid
  
   = self.to_hash[:source_account]
  RippleRest.post("v1/accounts/#{}/payments", hash)["client_resource_id"]
end