class PaymentsApi::Requests::CreateCardPayment
Attributes
Public Class Methods
Instantiate a new payment
@param amount [Integer] The amount in pence, for instance, 14500 for 145 @param reference [String] The reference you wish to associate with this payment @param description [String] A human-readable description of the payment that
the user will see on the payment pages and admin tool
@param return_url
[String] This is a URL that your service hosts for the user
to return to, after their payment journey on GOV.UK Pay ends
@option optional_details
[Hash] Additional properties to be sent in the payload,
for example +email+ or +metadata+
@raise [ArgumentError] if any of the mandatory params above are missing @return [PaymentsApi::Requests::CreateCardPayment] instance
@see govukpay-api-browser.cloudapps.digital/#create-a-payment
# File lib/payments_api/requests/create_card_payment.rb, line 30 def initialize(amount:, reference:, description:, return_url:, **optional_details) @optional_details = optional_details @amount = amount @reference = reference @description = description @return_url = return_url end
Public Instance Methods
Create a new payment
@raise [PaymentsApi::Errors::ApiError] refer to lib/payments_api/errors.rb @return [Responses::PaymentResult] result response
@see govukpay-api-browser.cloudapps.digital/#tocscreatecardpaymentrequest @see govukpay-api-browser.cloudapps.digital/#tocscreatepaymentresult
# File lib/payments_api/requests/create_card_payment.rb, line 47 def call Responses::PaymentResult.new( http_client.post(endpoint, payload) ) end
# File lib/payments_api/requests/create_card_payment.rb, line 53 def endpoint '/v1/payments' end
# File lib/payments_api/requests/create_card_payment.rb, line 57 def payload { amount: amount, reference: reference, description: description, return_url: return_url }.merge( optional_details ) end