Daniel
09/23/2021, 10:33 AMkennyadsl
Daniel
09/23/2021, 10:48 AMDaniel
09/23/2021, 10:51 AMkennyadsl
kennyadsl
kennyadsl
Daniel
09/23/2021, 10:55 AMkennyadsl
gateway_payment_profile_id name, it will be automatically stored on the payment source for that order/user.Daniel
09/23/2021, 10:56 AMkennyadsl
Daniel
09/23/2021, 10:58 AMresponse_code to store the transaction id.Daniel
09/23/2021, 10:58 AMDaniel
09/23/2021, 10:59 AMkennyadsl
Daniel
09/23/2021, 12:02 PMDaniel
09/23/2021, 5:00 PMresponse_code during transition to submit the transaction_id from the PSP.Daniel
09/23/2021, 5:01 PMresponse_code param to permitted checkout_payment_attributes
Spree::PermittedAttributes.payment_attributes << :response_code
Spree::PermittedAttributes.class_variable_set(:@@checkout_payment_attributes, [
payments_attributes: Spree::PermittedAttributes.payment_attributes + [
source_attributes: Spree::PermittedAttributes.source_attributes
]
])
Using class_variable_set feels totally wrong but not sure how to otherwise fix this. I thought just extending payment_attributes should extend checkout_payment_attributes as well, but that one was already initialized.
2. Decorate Spree::Payment to use the response_code in a before_validation hook to populate `Spree::CreditCard`:
module PaymentDecorator
def self.prepended(base)
base.before_validation :set_datatrans_source, if: -> { new_record? && source && payment_method&.type == 'Spree::PaymentMethod::DatatransCreditCard' }
base.before_validation :validate_source, unless: :invalid?
end
private
def set_datatrans_source
transaction = Datatrans.client.get_transaction(response_code)
source.gateway_payment_profile_id = transaction['card']['alias']
source.month = transaction['card']['expiryMonth']
source.year = transaction['card']['expiryYear']
source.number = transaction['card']['masked']
source.name = transaction['card']['info']['brand']
source.verification_value = true
end
Spree::Payment.prepend self
endDaniel
09/23/2021, 5:11 PMgateway_payment_profile_id without having to call the API again with the response_code .Daniel
09/23/2021, 5:14 PMDaniel
09/24/2021, 11:32 AMSpree::WalletPaymentSource that the default Spree::Payment object created during transition to the checkout payment step gets invalidated when transitioned to confirm?Daniel
09/24/2021, 11:33 AM=> [#<Spree::Payment:0x00007fc4eb5f2460
id: 51,
amount: 0.0,
order_id: 39,
source_type: "Spree::CreditCard",
source_id: 16,
payment_method_id: 6,
state: "invalid",
response_code: nil,
avs_response: nil,
created_at: Fri, 24 Sep 2021 11:28:21.866170000 UTC +00:00,
updated_at: Fri, 24 Sep 2021 11:28:27.104091000 UTC +00:00,
number: "HZKTQLL6",
cvv_response_code: nil,
cvv_response_message: nil>,
#<Spree::Payment:0x00007fc4eb5f2258
id: 52,
amount: 0.1825e2,
order_id: 39,
source_type: "Spree::CreditCard",
source_id: 16,
payment_method_id: 6,
state: "checkout",
response_code: nil,
avs_response: nil,
created_at: Fri, 24 Sep 2021 11:28:27.081662000 UTC +00:00,
updated_at: Fri, 24 Sep 2021 11:28:27.081662000 UTC +00:00,
number: "YTMYFHY5",
cvv_response_code: nil,
cvv_response_message: nil>]kennyadsl
Daniel
09/24/2021, 2:24 PMSpree::Payment object is (Spree::Order#add_default_payment_from_wallet ) when transitioning to the payment step.Daniel
09/24/2021, 2:25 PMconfirm with an existing card or a new one.kennyadsl
kennyadsl
Daniel
09/24/2021, 3:18 PMDaniel
09/24/2021, 3:39 PMDaniel
09/24/2021, 3:39 PMDaniel
09/24/2021, 3:40 PMkennyadsl
kennyadsl
Daniel
09/24/2021, 3:46 PMDaniel
09/24/2021, 3:50 PMkennyadsl
kennyadsl
Daniel
09/24/2021, 3:53 PMDaniel
09/29/2021, 8:29 AMkennyadsl
Daniel
09/29/2021, 8:30 AMDaniel
09/29/2021, 8:41 AMSpree::Wallet::DefaultPaymentBuilder obsolete as well.Daniel
09/29/2021, 8:42 AMDaniel
09/29/2021, 8:44 AMSpree::PaymentCreate would support updating an existing payment, Spree::OrderUpdateAttributes#assign_payments_attributes never reuses a payment (because of the missing payment argument).kennyadsl
Daniel
09/29/2021, 8:45 AMDaniel
09/29/2021, 8:46 AMkennyadsl
Daniel
09/29/2021, 8:49 AMDaniel
09/29/2021, 8:56 AMkennyadsl
Daniel
09/29/2021, 9:01 AMDaniel
09/29/2021, 9:31 AM