Class: Payment::Gateways::PurchaseOrder

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

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(payment, _delivery = nil) ⇒ PurchaseOrder

Returns a new instance of PurchaseOrder.



6
7
8
9
10
# File 'app/services/payment/gateways/purchase_order.rb', line 6

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

Instance Method Details

#authorizeObject



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

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

#void(report_fraud = false) ⇒ Object



18
19
20
21
22
23
24
25
# File 'app/services/payment/gateways/purchase_order.rb', line 18

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

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