Class: CreatePromptpayVoucherService
- Inherits:
-
Object
- Object
- CreatePromptpayVoucherService
- Defined in:
- app/services/create_promptpay_voucher_service.rb
Overview
Omise Promptpay has 2 ID, charge ID and transaction ID
* charge ID is created when creating Promptpay
* transaction ID is received when Promptpay has been paid
GB Primepay only has 1 ID, gbpReferenceNo so charge ID and Transaction ID is same
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(voucher_transaction) ⇒ CreatePromptpayVoucherService
constructor
A new instance of CreatePromptpayVoucherService.
Constructor Details
#initialize(voucher_transaction) ⇒ CreatePromptpayVoucherService
Returns a new instance of CreatePromptpayVoucherService.
12 13 14 15 |
# File 'app/services/create_promptpay_voucher_service.rb', line 12 def initialize(voucher_transaction) @voucher_transaction = voucher_transaction BUSINESS_LOGGER.set_business_context({ voucher_transaction_id: voucher_transaction.id }) end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/create_promptpay_voucher_service.rb', line 17 def execute success = false ActiveRecord::Base.transaction do voucher_transaction.charges.build(charge_attribute(voucher_transaction)) success = true end if !success APMErrorHandler.report('Failed to process voucher transaction with Promptpay', voucher_transaction_id: voucher_transaction.id) return false end BUSINESS_LOGGER.info 'Done processing voucher transaction with Promptpay', voucher_transaction_id: voucher_transaction.id success end |