Module: Sdp::Resources::Ramps

Included in:
Client
Defined in:
lib/sdp/resources/ramps.rb

Overview

Fiat on/off-ramps (SDP payments/ramps).

SANDBOX-ONLY at v0.2: wired against SDP’s ramp surface and the sandbox simulate hook, NOT verified against live fiat rails. The execute calls are POSTs and follow the same never-retry-on-write posture as transfers (a ramp moves money). #simulate_ramp drives a sandbox ramp to a terminal state.

The execute/quote requests carry a large provider KYC/compliance payload (SDP’s bvnkCompliance). Rather than model that nested blob, the core fields are keyword args and the compliance object is passed through via compliance:.

Instance Method Summary collapse

Instance Method Details

#offramp_currencies(source: nil, dest: nil, provider: nil) ⇒ Object

GET /v1/payments/ramps/offramp/currency → Sdp::RampCurrencies



85
86
87
# File 'lib/sdp/resources/ramps.rb', line 85

def offramp_currencies(source: nil, dest: nil, provider: nil)
  RampCurrencies.from_hash(ramp_currencies("offramp", source, dest, provider))
end

#offramp_execute(provider:, counterparty_id:, source_wallet:, crypto_token:, fiat_currency:, crypto_amount:, kyc_reference: nil, redirect_url: nil, compliance: nil) ⇒ Object

POST /v1/payments/ramps/offramp/execute → Sdp::RampExecution. Custodial money movement (crypto→fiat); never retried.



116
117
118
119
120
121
122
123
124
# File 'lib/sdp/resources/ramps.rb', line 116

def offramp_execute(provider:, counterparty_id:, source_wallet:, crypto_token:,
                    fiat_currency:, crypto_amount:, kyc_reference: nil, redirect_url: nil, compliance: nil)
  payload = {
    provider: provider, counterpartyId: counterparty_id, sourceWallet: source_wallet,
    cryptoToken: crypto_token, fiatCurrency: fiat_currency, cryptoAmount: amount_string(crypto_amount),
    kycReference: kyc_reference, redirectUrl: redirect_url, bvnkCompliance: compliance
  }.compact
  RampExecution.from_hash(ramp_record(post("/v1/payments/ramps/offramp/execute", payload).data, :ramp))
end

#onramp_currencies(source: nil, dest: nil, provider: nil) ⇒ Object

GET /v1/payments/ramps/onramp/currency → Sdp::RampCurrencies Filters (camelCased on the wire): source:, dest:, provider:.



80
81
82
# File 'lib/sdp/resources/ramps.rb', line 80

def onramp_currencies(source: nil, dest: nil, provider: nil)
  RampCurrencies.from_hash(ramp_currencies("onramp", source, dest, provider))
end

#onramp_execute(provider:, counterparty_id:, destination_wallet:, crypto_token:, fiat_currency:, fiat_amount:, kyc_reference: nil, redirect_url: nil, compliance: nil) ⇒ Object

POST /v1/payments/ramps/onramp/execute → Sdp::RampExecution. Custodial money movement; never retried. compliance: maps to SDP’s bvnkCompliance payload.



104
105
106
107
108
109
110
111
112
# File 'lib/sdp/resources/ramps.rb', line 104

def onramp_execute(provider:, counterparty_id:, destination_wallet:, crypto_token:,
                   fiat_currency:, fiat_amount:, kyc_reference: nil, redirect_url: nil, compliance: nil)
  payload = {
    provider: provider, counterpartyId: counterparty_id, destinationWallet: destination_wallet,
    cryptoToken: crypto_token, fiatCurrency: fiat_currency, fiatAmount: amount_string(fiat_amount),
    kycReference: kyc_reference, redirectUrl: redirect_url, bvnkCompliance: compliance
  }.compact
  RampExecution.from_hash(ramp_record(post("/v1/payments/ramps/onramp/execute", payload).data, :ramp))
end

#onramp_quote(provider:, counterparty_id:, destination_wallet:, crypto_token:, fiat_currency:, fiat_amount:, redirect_url: nil, collected_data: nil) ⇒ Object

POST /v1/payments/ramps/onramp/quote → Sdp::RampQuote. Indicative pricing for a fiat→crypto on-ramp. Never retried (write).



91
92
93
94
95
96
97
98
99
# File 'lib/sdp/resources/ramps.rb', line 91

def onramp_quote(provider:, counterparty_id:, destination_wallet:, crypto_token:,
                 fiat_currency:, fiat_amount:, redirect_url: nil, collected_data: nil)
  payload = {
    provider: provider, counterpartyId: counterparty_id, destinationWallet: destination_wallet,
    cryptoToken: crypto_token, fiatCurrency: fiat_currency, fiatAmount: amount_string(fiat_amount),
    redirectUrl: redirect_url, collectedData: collected_data
  }.compact
  RampQuote.from_hash(ramp_record(post("/v1/payments/ramps/onramp/quote", payload).data, :quote))
end

#simulate_ramp(**payload) ⇒ Object

POST /v1/payments/ramps/sandbox/simulate → the simulated transaction (Hash passthrough, nil if absent). Sandbox-only test hook: advances a sandbox ramp to a terminal state. Keyword args are forwarded verbatim (no camelCase conversion) — SDP leaves the body provider-shaped, so pass the keys SDP expects.



130
131
132
133
# File 'lib/sdp/resources/ramps.rb', line 130

def simulate_ramp(**payload)
  data = post("/v1/payments/ramps/sandbox/simulate", payload).data
  data.is_a?(Hash) ? data[:transaction] : nil
end