Class: Payment::Gateways::VerbalPurchaseOrder

Inherits:
BasePaymentGateway
  • Object
show all
Defined in:
app/services/payment/gateways/verbal_purchase_order.rb

Overview

Verbal purchase-order gateway. Behaves like PurchaseOrder
but the originating contact is captured via vpo_contact_id instead of an
uploaded PO document.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(payment, delivery = nil) ⇒ VerbalPurchaseOrder

Returns a new instance of VerbalPurchaseOrder.



11
12
13
14
15
# File 'app/services/payment/gateways/verbal_purchase_order.rb', line 11

def initialize(payment, delivery=nil)
  @payment = payment
  success = nil
  message = nil
end

Instance Method Details

#authorizePayment::Gateways::VerbalPurchaseOrder::Result

Mark the VPO authorized and resync the billing customer's
available credit.



21
22
23
24
25
# File 'app/services/payment/gateways/verbal_purchase_order.rb', line 21

def authorize
  @payment.payment_authorized!
  @payment.order.billing_entity.sync_credit_limit
  Result.new(success: true)
end

#void(report_fraud = false) ⇒ Payment::Gateways::VerbalPurchaseOrder::Result

Void an authorized VPO and replenish the customer credit line.

Parameters:

  • report_fraud (Boolean) (defaults to: false)

    retained for parity with CC gateway

Returns:



31
32
33
34
35
36
37
38
39
40
# File 'app/services/payment/gateways/verbal_purchase_order.rb', line 31

def void(report_fraud = false)
  return Result.new(success: false) unless @payment.authorized?

  @payment.payment_voided!
  # Replenish Credit line
  if @payment.order.billing_entity
    @payment.order.billing_entity.sync_credit_limit
  end
  Result.new(success: true)
end