Class: Payment::Gateways::PurchaseOrder
- Inherits:
-
BasePaymentGateway
- Object
- BasePaymentGateway
- Payment::Gateways::PurchaseOrder
- Defined in:
- app/services/payment/gateways/purchase_order.rb
Overview
Purchase-order gateway. Authorization just consumes the customer's
available credit (no external API); voiding replenishes it.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#authorize ⇒ Payment::Gateways::PurchaseOrder::Result
Mark the PO authorized and resync the billing customer's available credit so the consumed amount is reflected.
-
#initialize(payment, _delivery = nil) ⇒ PurchaseOrder
constructor
A new instance of PurchaseOrder.
-
#void(report_fraud = false) ⇒ Payment::Gateways::PurchaseOrder::Result
Void an authorized PO and replenish the billing customer's available credit.
Constructor Details
#initialize(payment, _delivery = nil) ⇒ PurchaseOrder
Returns a new instance of PurchaseOrder.
9 10 11 12 13 |
# File 'app/services/payment/gateways/purchase_order.rb', line 9 def initialize(payment, _delivery = nil) @payment = payment success = nil = nil end |
Instance Method Details
#authorize ⇒ Payment::Gateways::PurchaseOrder::Result
Mark the PO authorized and resync the billing customer's available
credit so the consumed amount is reflected.
19 20 21 22 23 |
# File 'app/services/payment/gateways/purchase_order.rb', line 19 def @payment. @payment.order.billing_entity.sync_credit_limit Result.new(success: true) end |
#void(report_fraud = false) ⇒ Payment::Gateways::PurchaseOrder::Result
Void an authorized PO and replenish the billing customer's
available credit.
30 31 32 33 34 35 36 37 |
# File 'app/services/payment/gateways/purchase_order.rb', line 30 def void(report_fraud = false) return Result.new(success: false) unless @payment. @payment.payment_voided! # Replenish Credit line @payment.order.billing_entity.sync_credit_limit if @payment.order.billing_entity Result.new(success: true) end |