Class: ModernTreasury::PaymentOrderApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/modern_treasury/apis/payment_order_api.rb

Overview

PaymentOrderApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from ModernTreasury::BaseApi

Instance Method Details

#create_async_payment_order(idempotency_key: nil, body: nil) ⇒ ApiResponse

Create a new payment order asynchronously something unique, preferably something like an UUID. type description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (PaymentOrderAsyncCreateRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/modern_treasury/apis/payment_order_api.rb', line 15

def create_async_payment_order(idempotency_key: nil,
                               body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/payment_orders/create_async',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(AsyncResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('403',
                             'forbidden',
                             ErrorMessageException))
    .execute
end

#create_payment_order(type, amount, direction, originating_account_id, content_type: nil, idempotency_key: nil, subtype: nil, priority: nil, receiving_account_id: nil, accounting: nil, accounting_category_id: nil, accounting_ledger_class_id: nil, currency: nil, effective_date: nil, description: nil, statement_descriptor: nil, remittance_information: nil, purpose: nil, metadata: nil, charge_bearer: nil, foreign_exchange_indicator: nil, foreign_exchange_contract: nil, nsf_protected: nil, originating_party_name: nil, ultimate_originating_party_name: nil, ultimate_originating_party_identifier: nil, ultimate_receiving_party_name: nil, ultimate_receiving_party_identifier: nil, send_remittance_advice: nil, expires_at: nil, fallback_type: nil, receiving_account: nil, ledger_transaction: nil, line_items: nil, transaction_monitoring_enabled: nil, documents: nil) ⇒ ApiResponse

Create a new Payment Order ‘check`, `sen`, `book`, `rtp`, `sepa`, `bacs`, `au_becs`, `interac`, `signet`, `provexchange`. smallest unit. e.g. $10 would be represented as 1000 (cents). For RTP, the maximum amount allowed by the network is $100,000. `debit`. Describes the direction money is flowing in the transaction. A `credit` moves money from your account to someone else’s. A ‘debit` pulls money from someone else’s account to your own. Note that wire, rtp, and check payments will always be ‘credit`. of one of your organization’s internal accounts. something unique, preferably something like an UUID. classification for the type of payment order you are doing. This field is only used for ‘ach` payment orders currently. For `ach` payment orders, the `subtype` represents the SEC code. We currently support `CCD`, `PPD`, `IAT`, `CTX`, `WEB`, `CIE`, and `TEL`. For ACH and EFT payments, `high` represents a same-day ACH or EFT transfer, respectively. For check payments, `high` can mean an overnight check rather than standard mail. `receiving_account` or `receiving_account_id` must be present. When using `receiving_account_id`, you may pass the id of an external account or an internal account. here of one of your accounting categories. Note that these will only be accessible if your accounting system has been connected. ID of one of your accounting ledger classes. Note that these will only be accessible if your accounting system has been connected. code. be posted to the participants’ account. Defaults to the current business day or the next business day if the current day is a bank holiday or weekend. Format: yyyy-mm-dd. for internal use. descriptor which will appear in the receiver’s statement. For ‘check` payments this field will be used as the memo line. For `ach` the maximum length is 10 characters. Note that for ACH payments, the name on your bank account will be included automatically by the bank, so you can use the characters for other useful information. For `eft` the maximum length is 15 characters. field will be passed through on an addenda record. For `wire` payments the field will be passed through as the “Originator to Beneficiary Information”, also known as OBI or Fedwire tag 6000. the purpose which is transmitted via the “InstrForDbtrAgt” field in the ISO20022 file. If you are using Currencycloud, this is the `payment.purpose_code` field. For `eft`, this field is the 3 digit CPA Code that will be attached to the payment. represented as key-value pairs. Both the key and value must be strings. will pay the fees for the payment order. Only applies to wire payment orders. Can be one of shared, sender, or receiver, which correspond respectively with the SWIFT 71A values `SHA`, `OUR`, `BEN`. parameter: Indicates the type of FX transfer to initiate, can be either `variable_to_fixed`, `fixed_to_variable`, or `null` if the payment order currency matches the originating account currency. indicates a specific foreign exchange contract number that has been generated by your financial institution. boolean to determine if NSF Protection is enabled for this payment order. Note that this setting must also be turned on in your organization settings page. this will replace your default company name on receiver’s bank statement. This field can only be used for ACH payments currently. For ACH, only the first 16 characters of this string will be used. Any additional characters will be truncated. of the ultimate originator of the payment order. Identifier of the ultimate originator of the payment order. the ultimate funds recipient. Identifier of the ultimate funds recipient. Send an email to the counterparty when the payment order is sent to the bank. If ‘null`, `send_remittance_advice` on the Counterparty is used. expires_at. This value must be past the effective_date. fallback to if the original type is not valid for the receiving account. Currently, this only supports falling back from RTP to ACH (type=rtp and fallback_type=ach) `receiving_account` or `receiving_account_id` must be present. When using `receiving_account_id`, you may pass the id of an external account or an internal account. parameter: TODO: type description here line items that must sum up to the amount of the payment order. parameter: A flag that determines whether a payment order should go through transaction monitoring. array of documents to be attached to the payment order. Note that if you attach documents, the request’s content type must be ‘multipart/form-data`.

Parameters:

  • type (Type5)

    Required parameter: One of ‘ach`, `eft`, `wire`,

  • amount (Integer)

    Required parameter: Value in specified currency’s

  • direction (Direction5)

    Required parameter: One of ‘credit`,

  • originating_account_id (UUID | String)

    Required parameter: The ID

  • content_type (ContentType) (defaults to: nil)

    Optional parameter: Example:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • subtype (Subtype) (defaults to: nil)

    Optional parameter: An additional layer of

  • priority (Priority) (defaults to: nil)

    Optional parameter: Either ‘normal` or `high`.

  • receiving_account_id (UUID | String) (defaults to: nil)

    Optional parameter: Either

  • accounting (Accounting) (defaults to: nil)

    Optional parameter: TODO: type description

  • accounting_category_id (UUID | String) (defaults to: nil)

    Optional parameter: The ID

  • accounting_ledger_class_id (UUID | String) (defaults to: nil)

    Optional parameter: The

  • currency (Currency) (defaults to: nil)

    Optional parameter: Three-letter ISO currency

  • effective_date (Date) (defaults to: nil)

    Optional parameter: Date transactions are to

  • description (String) (defaults to: nil)

    Optional parameter: An optional description

  • statement_descriptor (String) (defaults to: nil)

    Optional parameter: An optional

  • remittance_information (String) (defaults to: nil)

    Optional parameter: For ‘ach`, this

  • purpose (String) (defaults to: nil)

    Optional parameter: For ‘wire`, this is usually

  • metadata (Hash[String, String]) (defaults to: nil)

    Optional parameter: Additional data

  • charge_bearer (ChargeBearer) (defaults to: nil)

    Optional parameter: The party that

  • foreign_exchange_indicator (ForeignExchangeIndicator) (defaults to: nil)

    Optional

  • foreign_exchange_contract (String) (defaults to: nil)

    Optional parameter: If present,

  • nsf_protected (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: A

  • originating_party_name (String) (defaults to: nil)

    Optional parameter: If present,

  • ultimate_originating_party_name (String) (defaults to: nil)

    Optional parameter: Name

  • ultimate_originating_party_identifier (String) (defaults to: nil)

    Optional parameter:

  • ultimate_receiving_party_name (String) (defaults to: nil)

    Optional parameter: Name of

  • ultimate_receiving_party_identifier (String) (defaults to: nil)

    Optional parameter:

  • send_remittance_advice (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter:

  • expires_at (DateTime) (defaults to: nil)

    Optional parameter: RFP payments require an

  • fallback_type (FallbackType) (defaults to: nil)

    Optional parameter: A payment type to

  • receiving_account (ReceivingAccount1) (defaults to: nil)

    Optional parameter: Either

  • ledger_transaction (LedgerTransactionCreateRequest) (defaults to: nil)

    Optional

  • line_items (Array[LineItemRequest]) (defaults to: nil)

    Optional parameter: An array of

  • transaction_monitoring_enabled (TrueClass | FalseClass) (defaults to: nil)

    Optional

  • documents (Array[DocumentCreateRequest]) (defaults to: nil)

    Optional parameter: An

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/modern_treasury/apis/payment_order_api.rb', line 223

def create_payment_order(type,
                         amount,
                         direction,
                         ,
                         content_type: nil,
                         idempotency_key: nil,
                         subtype: nil,
                         priority: nil,
                         receiving_account_id: nil,
                         accounting: nil,
                         accounting_category_id: nil,
                         accounting_ledger_class_id: nil,
                         currency: nil,
                         effective_date: nil,
                         description: nil,
                         statement_descriptor: nil,
                         remittance_information: nil,
                         purpose: nil,
                         metadata: nil,
                         charge_bearer: nil,
                         foreign_exchange_indicator: nil,
                         foreign_exchange_contract: nil,
                         nsf_protected: nil,
                         originating_party_name: nil,
                         ultimate_originating_party_name: nil,
                         ultimate_originating_party_identifier: nil,
                         ultimate_receiving_party_name: nil,
                         ultimate_receiving_party_identifier: nil,
                         send_remittance_advice: nil,
                         expires_at: nil,
                         fallback_type: nil,
                         receiving_account: nil,
                         ledger_transaction: nil,
                         line_items: nil,
                         transaction_monitoring_enabled: nil,
                         documents: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/payment_orders',
                                 Server::DEFAULT)
               .form_param(new_parameter(type, key: 'type')
                            .is_required(true))
               .form_param(new_parameter(amount, key: 'amount')
                            .is_required(true))
               .form_param(new_parameter(direction, key: 'direction')
                            .is_required(true))
               .form_param(new_parameter(, key: 'originating_account_id')
                            .is_required(true))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .form_param(new_parameter(subtype, key: 'subtype'))
               .form_param(new_parameter(priority, key: 'priority'))
               .form_param(new_parameter(, key: 'receiving_account_id'))
               .form_param(new_parameter(accounting, key: 'accounting'))
               .form_param(new_parameter(accounting_category_id, key: 'accounting_category_id'))
               .form_param(new_parameter(accounting_ledger_class_id, key: 'accounting_ledger_class_id'))
               .form_param(new_parameter(currency, key: 'currency'))
               .form_param(new_parameter(effective_date, key: 'effective_date'))
               .form_param(new_parameter(description, key: 'description'))
               .form_param(new_parameter(statement_descriptor, key: 'statement_descriptor'))
               .form_param(new_parameter(remittance_information, key: 'remittance_information'))
               .form_param(new_parameter(purpose, key: 'purpose'))
               .form_param(new_parameter(, key: 'metadata'))
               .form_param(new_parameter(charge_bearer, key: 'charge_bearer'))
               .form_param(new_parameter(foreign_exchange_indicator, key: 'foreign_exchange_indicator'))
               .form_param(new_parameter(foreign_exchange_contract, key: 'foreign_exchange_contract'))
               .form_param(new_parameter(nsf_protected, key: 'nsf_protected'))
               .form_param(new_parameter(originating_party_name, key: 'originating_party_name'))
               .form_param(new_parameter(ultimate_originating_party_name, key: 'ultimate_originating_party_name'))
               .form_param(new_parameter(ultimate_originating_party_identifier, key: 'ultimate_originating_party_identifier'))
               .form_param(new_parameter(ultimate_receiving_party_name, key: 'ultimate_receiving_party_name'))
               .form_param(new_parameter(ultimate_receiving_party_identifier, key: 'ultimate_receiving_party_identifier'))
               .form_param(new_parameter(send_remittance_advice, key: 'send_remittance_advice'))
               .form_param(new_parameter(expires_at, key: 'expires_at'))
               .form_param(new_parameter(fallback_type, key: 'fallback_type'))
               .form_param(new_parameter(, key: 'receiving_account'))
               .form_param(new_parameter(ledger_transaction, key: 'ledger_transaction'))
               .form_param(new_parameter(line_items, key: 'line_items'))
               .form_param(new_parameter(transaction_monitoring_enabled, key: 'transaction_monitoring_enabled'))
               .form_param(new_parameter(documents, key: 'documents'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentOrder.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'parameter_invalid',
                             ErrorMessageException)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException)
                .local_error('403',
                             'forbidden',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#get_payment_order(id) ⇒ ApiResponse

Get details on a single payment order

Parameters:

  • id (String)

    Required parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/modern_treasury/apis/payment_order_api.rb', line 327

def get_payment_order(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/payment_orders/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentOrder.method(:from_hash))
                .is_api_response(true)
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end

#list_payment_orders(after_cursor: nil, per_page: nil, type: nil, priority: nil, counterparty_id: nil, originating_account_id: nil, transaction_id: nil, status: nil, direction: nil, reference_number: nil, effective_date_start: nil, effective_date_end: nil, metadata: nil) ⇒ ApiResponse

Get a list of all payment orders here here For ACH and EFT payments, ‘high` represents a same-day ACH or EFT transfer, respectively. For check payments, `high` can mean an overnight check rather than standard mail. description here type description here transaction that the payment order has been reconciled to. with the provided reference number bound for searching effective_date bound for searching effective_date you want to query for records with metadata key `Type` and value `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query parameters.

Parameters:

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • type (Type13) (defaults to: nil)

    Optional parameter: Example:

  • priority (Priority4) (defaults to: nil)

    Optional parameter: Either ‘normal` or `high`.

  • counterparty_id (UUID | String) (defaults to: nil)

    Optional parameter: TODO: type

  • originating_account_id (UUID | String) (defaults to: nil)

    Optional parameter: TODO:

  • transaction_id (UUID | String) (defaults to: nil)

    Optional parameter: The ID of a

  • status (Status24) (defaults to: nil)

    Optional parameter: Example:

  • direction (Direction15) (defaults to: nil)

    Optional parameter: Example:

  • reference_number (String) (defaults to: nil)

    Optional parameter: Query for records

  • effective_date_start (Date) (defaults to: nil)

    Optional parameter: An inclusive lower

  • effective_date_end (Date) (defaults to: nil)

    Optional parameter: An inclusive upper

  • metadata (Hash[String, String]) (defaults to: nil)

    Optional parameter: For example, if

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/modern_treasury/apis/payment_order_api.rb', line 66

def list_payment_orders(after_cursor: nil,
                        per_page: nil,
                        type: nil,
                        priority: nil,
                        counterparty_id: nil,
                        originating_account_id: nil,
                        transaction_id: nil,
                        status: nil,
                        direction: nil,
                        reference_number: nil,
                        effective_date_start: nil,
                        effective_date_end: nil,
                        metadata: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/payment_orders',
                                 Server::DEFAULT)
               .query_param(new_parameter(after_cursor, key: 'after_cursor'))
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(type, key: 'type'))
               .query_param(new_parameter(priority, key: 'priority'))
               .query_param(new_parameter(counterparty_id, key: 'counterparty_id'))
               .query_param(new_parameter(, key: 'originating_account_id'))
               .query_param(new_parameter(transaction_id, key: 'transaction_id'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(direction, key: 'direction'))
               .query_param(new_parameter(reference_number, key: 'reference_number'))
               .query_param(new_parameter(effective_date_start, key: 'effective_date_start'))
               .query_param(new_parameter(effective_date_end, key: 'effective_date_end'))
               .query_param(new_parameter(, key: 'metadata'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentOrder.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true))
    .execute
end

#update_payment_order(id, body: nil) ⇒ ApiResponse

Update a payment order description here

Parameters:

  • id (String)

    Required parameter: TODO: type description here

  • body (PaymentOrderUpdateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/modern_treasury/apis/payment_order_api.rb', line 352

def update_payment_order(id,
                         body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/payment_orders/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentOrder.method(:from_hash))
                .is_api_response(true)
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'parameter_invalid',
                             ErrorMessageException))
    .execute
end