class Skrill::Payment

Constants

OPTIONS
VERSION

Public Class Methods

new(payment_data = {}) { |self| ... } click to toggle source

Prepares a new payment using the configuration attributes when provided and the payment attributes. The configuration attributes can be overwritten by using in the same Hash keys or methods. Attributes can be passed in by using a block or a Hash.

@example Prepare a new payment using a block.

Skrill::Payment.new do |payee|
  payee.email = 'customer@example.com'
  payee.amount = 10.00
end

@example Prepare a new payment using a Hash.

Skrill::Payment.new(email: 'customer@example.com', amount:  10.00)

@return [ Skrill::Payment ] The payment object.

@since 0.1.0

# File lib/skrill/payment.rb, line 33
def initialize(payment_data = {}, &block)
  assign_attirbutes(payment_data)

  yield(self) if block_given?
end

Public Instance Methods

deliver() click to toggle source

Sends a payment request to Skrill. Use the `successful?` method to check if the Skrill was able to process the payment successfully.

@return [ Request ] The request object.

@since 0.1.0

# File lib/skrill/payment.rb, line 45
def deliver
  @request = Skrill::Payment::Request.post(config_data, payment_data)
end
error_message() click to toggle source

Returns the error message from Skrill or nil when the payment was successful.

@return [ String, nil ] The error message or nil.

@since 0.2.0

# File lib/skrill/payment.rb, line 64
def error_message
  @request.error_message
end
successful?() click to toggle source

Checks if the payment has been delivered and was successful.

@return [ true, false ] The payment success status.

@since 0.1.0

# File lib/skrill/payment.rb, line 54
def successful?
  !!@request && @request.successful?
end

Private Instance Methods

config_data() click to toggle source
# File lib/skrill/payment.rb, line 70
def config_data
  Configuration.serialized_data
end
payment_data() click to toggle source
# File lib/skrill/payment.rb, line 74
def payment_data
  serialize_arguments(OPTIONS)
end