summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorAlessandro Desantis <desa.alessandro@gmail.com>2020-06-18 15:39:02 +0200
committerAlessandro Desantis <desa.alessandro@gmail.com>2020-06-18 16:38:45 +0200
commite6e84fba0518b9bf72c57f54ed67074e8a73497c (patch)
tree510162824ad39998693aa9de72cb78b3869e2b68 /app/services
parent55d38a16cabafdde0b0ca2479d780e71662ebd47 (diff)
Store payment method and source on subscriptions
This allows each subscription to have its own payment method and source. It also allows having subscriptions with payment methods that aren't credit cards, which is useful if you want e.g. to allow users to pay by check/wire transfer.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/solidus_subscriptions/checkout.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/services/solidus_subscriptions/checkout.rb b/app/services/solidus_subscriptions/checkout.rb
index cd66406..3457435 100644
--- a/app/services/solidus_subscriptions/checkout.rb
+++ b/app/services/solidus_subscriptions/checkout.rb
@@ -116,22 +116,26 @@ module SolidusSubscriptions
end
def ship_address
- subscription.shipping_address || user.ship_address
+ subscription.shipping_address_to_use
end
def bill_address
- subscription.billing_address || user.bill_address
+ subscription.billing_address_to_use
end
- def active_card
- user.wallet.default_wallet_payment_source.payment_source
+ def payment_source
+ subscription.payment_source_to_use
+ end
+
+ def payment_method
+ subscription.payment_method_to_use
end
def create_payment
order.payments.create(
- source: active_card,
+ source: payment_source,
amount: order.total,
- payment_method: active_card.payment_method,
+ payment_method: payment_method,
)
end