diff --git a/api/stripe_payment_link.php b/api/stripe_payment_link.php index 2aca019..3da7d7e 100644 --- a/api/stripe_payment_link.php +++ b/api/stripe_payment_link.php @@ -8,10 +8,10 @@ class stripe_payment_link extends cora\crud { public static $exposed = [ - 'private' => [ + 'private' => [], + 'public' => [ 'open' - ], - 'public' => [] + ] ]; public static $user_locked = false; @@ -81,10 +81,9 @@ class stripe_payment_link extends cora\crud { public function open($attributes) { $stripe_payment_link = $this->get($attributes); - $user = $this->api('user', 'get', $this->session->get_user_id()); $url = $stripe_payment_link['url'] . - '?prefilled_email=' . $user['email_address'] . - '&client_reference_id=' . $user['user_id']; + '?prefilled_email=' . $attributes['prefilled_email'] . + '&client_reference_id=' . $attributes['client_reference_id']; header('Location: ' . $url); die(); diff --git a/js/component/card/contribute.js b/js/component/card/contribute.js index 0219414..83b5f03 100644 --- a/js/component/card/contribute.js +++ b/js/component/card/contribute.js @@ -306,7 +306,21 @@ beestat.component.card.contribute.prototype.decorate_contents_ = function(parent .set_background_hover_color() .removeEventListener('click'); - window.open('api/?resource=stripe_payment_link&method=open&arguments={"attributes":{"amount":' + (contribute_amount * 100) + ',"currency":"' + beestat.setting('units.currency') + '","interval":"' + contribute_interval + '"}}&api_key=' + window.beestat_api_key_local); + const stripe_payment_link_arguments = { + 'attributes': { + 'amount': (contribute_amount * 100), + 'currency': beestat.setting('units.currency'), + 'interval': contribute_interval, + 'prefilled_email': beestat.user.get().email_address, + 'client_reference_id': beestat.user.get().user_id + } + }; + window.open( + 'api/?resource=stripe_payment_link&method=open&arguments=' + + JSON.stringify(stripe_payment_link_arguments) + + '&api_key=' + + window.beestat_api_key_local + ); setTimeout(function() { self.rerender();