question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to override paymentMethod per subscription/bundle

See original GitHub issue

Today, when an invoice needs to be paid, the payment code extracts the default payment method associated with the account. An invoice contains potentially several items, each of which can map to a specific bundle/subscription. A Payment matches a specific invoice. Associating a payment method with a specific subscription or bundle will only work if the invoice associated with the payment contains only one subscription/bundle (or they all share the same overridden payment method).

Fortunately we have a mechanism in catalog to group certain subscription/bundle into one invoice. This is called billingAlignment, and we support 3 cases:

  • ACCOUNT (all subscriptions will appear on one invoice)

  • BUNDLE (all subscriptions for a given bundle will appear on one invoice)

  • SUBSCRIPTION (only a specific subscription will appear on one given invoice)

    In order to override that behavior and override payment method per subscription/bundle, there are several possible designs:

  1. Extend the current InvoicePaymentRoutingPluginApi to implement that functionality. The InvoicePaymentRoutingPluginApi implements the PaymentRoutingPluginApi, and that api is called from RetryOperationCallback to potentially break the flow or override values such as amount to be paid, currency to use, but also payment method that should be be used.

So, that code could be extended in the following way:

  • Add a new table (state) to capture the paymentMethodId associated to a given bundle/subscription
  • Export a new endpoint to register the paymentMethodId associated to a given bundle/subscription
  • Have the InvoicePaymentRoutingPluginApi check whether the payment method should be overridden by looking in the new table.

The issue is that this code (InvoicePaymentRoutingPluginApi) has not been extracted as a first class citizen plugin and is still part of Kill Bill core.

  1. Modification of the previous proposal but in a custom plugin

The system property org.killbill.payment.invoice.plugin allows to specify an order of PaymentRoutingPluginApi that will be called by RetryOperationCallback in the priorCall method. This one will now need to contain “INVOICE_PAYMENT_CONTROL_PLUGIN, <name_of_new_plugin>”, in that order.

The invoiceId that will be needed can be extracted using the property PROP_IPCD_INVOICE_ID. See for instance how this is done in InvoicePaymentRoutingPluginApi: final PluginProperty invoiceProp = getPluginProperty(paymentRoutingContext.getPluginProperties(), PROP_IPCD_INVOICE_ID);

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
chris13524commented, Jun 29, 2017

Any news on this? This would be a great feature to have.

0reactions
sbrossiecommented, Apr 12, 2022

Since a payment happens against a specific invoice, and since a given invoice may contain multiple line items (possibly for different bundles/subscriptions), we first need to create a mechanism to group specific line items to their own invoices. This feature is tracked by https://github.com/killbill/killbill/issues/1658.

Once we have the mechanism in place to create independent invoices for specific (group of) subscription(s), this feature can easily be implemented using a payment control plugin: The payment control plugin can check which payment method to use for a specific (group of) subscription(s), and update the payment accordingly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set payment methods per-subscription | Stripe Documentation
Manually select payment methods. You can override the payment methods that can be used to pay a subscription by changing its payment settings....
Read more >
Price Override - Chargebee Docs
To enable price override for your Chargebee site, navigate to Settings > Configure Chargebee > Billing LogIQ and enable the Allow Price Override...
Read more >
Manually Add or Edit a Subscription - WooCommerce
Set up automatic payments​​ To change a subscription's payment method: Go to the WooCommerce > Subscriptions administration screen. Click the ID of the...
Read more >
Payment options for your Microsoft business subscription
You can't automatically change from paying by invoice to paying with a different payment method. Instead, you must buy a different subscription ......
Read more >
Laravel Cashier (Stripe) - The PHP Framework For Web Artisans
Installation. Database Migrations · Configuration. Billable Model · Customers. Retrieving Customers · Payment Methods. Storing Payment Methods · Subscriptions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found