Module: Sdp::Resources::Payments
- Included in:
- Client
- Defined in:
- lib/sdp/resources/payments.rb
Overview
Payment endpoints: transfer create/prepare/list/get.
Instance Method Summary collapse
-
#create_transfer(source:, destination:, amount:, token: "SOL", memo: nil) ⇒ Object
POST /v1/payments/transfers → Sdp::Transfer Synchronous sign-and-send: SDP confirms before responding, and the request is NEVER retried (no idempotency key upstream — see Client docs).
-
#get_transfer(transfer_id) ⇒ Object
GET /v1/payments/transfers/:id → Sdp::Transfer.
-
#list_transfers(wallet: nil, wallet_address: nil, token: nil, direction: nil, status: nil, page: nil, page_size: nil) ⇒ Object
GET /v1/payments/transfers → Enumerator yielding Sdp::Transfer.
-
#prepare_transfer(source:, destination:, amount:, token: "SOL", memo: nil, reference_address: nil, options: nil) ⇒ Object
POST /v1/payments/transfers/prepare → Sdp::PreparedTransfer Builds — but does not sign or send — the transaction, for non-custodial flows where the caller holds the keys.
Instance Method Details
#create_transfer(source:, destination:, amount:, token: "SOL", memo: nil) ⇒ Object
POST /v1/payments/transfers → Sdp::Transfer Synchronous sign-and-send: SDP confirms before responding, and the request is NEVER retried (no idempotency key upstream — see Client docs). amount is serialized as a decimal string; token is “SOL” or an SPL mint address.
57 58 59 60 61 62 |
# File 'lib/sdp/resources/payments.rb', line 57 def create_transfer(source:, destination:, amount:, token: "SOL", memo: nil) response = post("/v1/payments/transfers", transfer_payload(source, destination, amount, token, memo)) data = response.data src = data.is_a?(Hash) ? (data[:transfer] || data) : data Transfer.from_hash(src) end |
#get_transfer(transfer_id) ⇒ Object
GET /v1/payments/transfers/:id → Sdp::Transfer
104 105 106 107 108 109 |
# File 'lib/sdp/resources/payments.rb', line 104 def get_transfer(transfer_id) response = get("/v1/payments/transfers/#{encode_path_segment(transfer_id)}") data = response.data src = data.is_a?(Hash) ? (data[:transfer] || data) : data Transfer.from_hash(src) end |
#list_transfers(wallet: nil, wallet_address: nil, token: nil, direction: nil, status: nil, page: nil, page_size: nil) ⇒ Object
GET /v1/payments/transfers → Enumerator yielding Sdp::Transfer
Auto-paginates: without page:, the returned lazy enumerator follows meta.hasMore across pages, fetching each page only when iteration reaches it and re-sending the filters every time. With an explicit page:, it yields exactly that page and never fetches another. page_size is clamped to Pagination::MAX_PAGE_SIZE (100).
Filters: wallet: (walletId), wallet_address:, token:, direction: (“inbound”/“outbound”), status: (string or array, sent comma-separated), page:, page_size:.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/sdp/resources/payments.rb', line 86 def list_transfers(wallet: nil, wallet_address: nil, token: nil, direction: nil, status: nil, page: nil, page_size: nil) query = { wallet: wallet, walletAddress: wallet_address, token: token, direction: direction, status: status && Array(status).join(","), page: page, pageSize: page_size }.compact Pagination.enumerate(self, "/v1/payments/transfers", query) do |response| rows = response.data.is_a?(Array) ? response.data : [] rows.map { |transfer| Transfer.from_hash(transfer) } end end |
#prepare_transfer(source:, destination:, amount:, token: "SOL", memo: nil, reference_address: nil, options: nil) ⇒ Object
POST /v1/payments/transfers/prepare → Sdp::PreparedTransfer Builds — but does not sign or send — the transaction, for non-custodial flows where the caller holds the keys.
67 68 69 70 71 72 73 |
# File 'lib/sdp/resources/payments.rb', line 67 def prepare_transfer(source:, destination:, amount:, token: "SOL", memo: nil, reference_address: nil, options: nil) payload = transfer_payload(source, destination, amount, token, memo) payload[:referenceAddress] = reference_address if reference_address payload[:options] = if PreparedTransfer.from_hash(post("/v1/payments/transfers/prepare", payload).data) end |