Class: ShopeePayService::RefundInvoice
- Defined in:
- app/services/shopee_pay_service/refund_invoice.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(reservation, options = {}) ⇒ RefundInvoice
constructor
A new instance of RefundInvoice.
Constructor Details
#initialize(reservation, options = {}) ⇒ RefundInvoice
Returns a new instance of RefundInvoice.
8 9 10 11 |
# File 'app/services/shopee_pay_service/refund_invoice.rb', line 8 def initialize(reservation, = {}) @reservation = reservation @options = .reverse_merge(platform_type: 'pc') end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/shopee_pay_service/refund_invoice.rb', line 13 def execute response = super if response.present? && response[:errcode] == 0 service = CancelReservationService.new(@reservation.id, :admin, { require_reason: true }) service.cancel_reason = 'Shopee pay refund by admin' service.execute @reservation.update(refund: true) if reservation.by_marketplace? && reservation.tagthai_channel? Vendors::TagThai::WebhookWorker.perform_async(@reservation.id, ApiVendorV1::Constants::REFUND) end end response rescue ShopeePayService::Error @reservation.errors.add(:base, 'Sorry, something went wrong') false end |