Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable donors to choose the network used to process their cards #2453

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion js/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Liberapay.stripe_form_init = function($form) {
var stripe = null;
if (window.Stripe) {
stripe = Stripe($form.data('stripe-pk'));
var elements = stripe.elements();
var elements = stripe.elements({
onBehalfOf: $form.data('stripe-on-behalf-of'),
});
var element_type = $container.data('type');
var options = {style: {
base: {
Expand Down
13 changes: 13 additions & 0 deletions www/%username/giving/pay/stripe/%payin_id.spt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,19 @@ if tippees:
LIMIT 1
""", tippee_ids=tuple(tip.tippee for tip in tips))
)
stripe_on_behalf_of = ''
if len(tips) == 1:
proto_transfers = resolve_tip(
website.db, tips[0], tips[0].tippee_p, 'stripe', payer, payer.guessed_country,
tips[0].periodic_amount
)
if len(proto_transfers) == 1:
if proto_transfers[0].destination.country not in constants.SEPA:
stripe_on_behalf_of = proto_transfers[0].destination.id
del proto_transfers
del tips
# Note: the `stripe_on_behalf_of` value isn't 100% accurate. This can be fixed
# later if it causes too many problems.

elif not payin_id:
response.redirect(payer.path('giving/pay'))
Expand Down Expand Up @@ -377,6 +389,7 @@ title = _("Funding your donations")
"make sure it’s allowing requests to the “stripe.com” domain."
) }}'
data-msg-submitting="{{ _('Request in progress, please wait…') }}"
data-stripe-on-behalf-of="{{ stripe_on_behalf_of }}"
data-stripe-pk="{{ website.app_conf.stripe_publishable_key }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
% if len(payment.recipient_names) == 1
Expand Down
Loading