Class used to call the Payment product.

Sections
Methods
C
G
L
Public
Instance Public methods
create_payment( recipient_id, reference, amount, schedule: nil, options: nil )

Create a payment.

recipient_id

Recipient ID that the payment will be initiated for.

reference

Payment reference.

amount

Payment amount.

schedule

Payment schedule.

options

Payment options.

Returns

Returns a PaymentCreateResponse object.

# File lib/plaid/products/payment_initiation.rb, line 52
def create_payment(
  recipient_id, reference, amount, schedule: nil, options: nil
)
  create_payment = {
    'recipient_id': recipient_id,
    'reference': reference,
    'amount': amount
  }

  create_payment['schedule'] = schedule unless schedule.nil?
  create_payment['options'] = options unless options.nil?

  post_with_auth('payment_initiation/payment/create',
                 PaymentCreateResponse,
                 create_payment)
end
create_payment_token(payment_id)

Create a payment token.

payment_id

Payment ID that the token will be created for.

Returns

Returns a PaymentTokenCreateResponse object.

# File lib/plaid/products/payment_initiation.rb, line 74
def create_payment_token(payment_id)
  puts 'Warning: this method will be deprecated in a future version. '\
       'To replace the payment_token, look into the link_token at '\
       'https://plaid.com/docs/api/tokens/#linktokencreate.'

  post_with_auth 'payment_initiation/payment/token/create',
                 PaymentTokenCreateResponse,
                 payment_id: payment_id
end
create_recipient(name, iban, address, bacs)

Create a recipient.

name

Recipient name.

iban

Recipient IBAN. Should be nil if using bacs.

address

Recipient address (hash with “street”, “city”, “postal_code” and “country”). Best practice is to set it as nil.

bacs

Recipient BACS (hash with “account” and “sort_code” keys). Should be nil if using iban.

Returns

Returns a PaymentRecipientCreateResponse object.

# File lib/plaid/products/payment_initiation.rb, line 14
def create_recipient(name, iban, address, bacs)
  post_with_auth 'payment_initiation/recipient/create',
                 PaymentRecipientCreateResponse,
                 name: name,
                 iban: iban,
                 bacs: bacs,
                 address: address
end
get_payment(payment_id)

Retrieve a payment.

payment_id

The payment ID from the `create_payment` response.

Returns

Returns a PaymentGetResponse object.

# File lib/plaid/products/payment_initiation.rb, line 89
def get_payment(payment_id)
  post_with_auth 'payment_initiation/payment/get',
                 PaymentGetResponse,
                 payment_id: payment_id
end
get_recipient(recipient_id)

Retrieve a recipient.

recipient_id

The recipient ID from the `create_recipient` response.

Returns

Returns a PaymentRecipientGetResponse object.

# File lib/plaid/products/payment_initiation.rb, line 28
def get_recipient(recipient_id)
  post_with_auth 'payment_initiation/recipient/get',
                 PaymentRecipientGetResponse,
                 recipient_id: recipient_id
end
list_payments(options)

List all payments.

options

Object to specify optional parameters 'count' and 'cursor'. e.g {count: 10, cursor: '2019-12-06T22:35:49Z'} returns 10 payments initiated before 2019-12-06T22:35:49Z.

Returns

Returns a PaymentListResponse object.

# File lib/plaid/products/payment_initiation.rb, line 102
def list_payments(options)
  post_with_auth 'payment_initiation/payment/list',
                 PaymentListResponse,
                 options
end
list_recipients()

List all recipients.

Returns

Returns a PaymentRecipientListResponse object.

# File lib/plaid/products/payment_initiation.rb, line 37
def list_recipients
  post_with_auth 'payment_initiation/recipient/list',
                 PaymentRecipientListResponse,
                 {}
end