#m.michalis
1 messages · Page 1 of 1 (latest)
Hello! Can you give me some more details here?
i use Stripe JS for rendering elements on frontend
const paymentElement = elements.create('payment');
//const addressElement = elements.create('address', {mode: 'billing'});
this.createModal({
type: 'subscription',
actionText: 'Pay ' + price_text
}, () => {
//addressElement.mount('#address-element');
paymentElement.mount('#payment-element')
});
Gotcha - are you seeing some payment method types that you have enabled through the dashboard not showing up in your payment element?
Can you be specific about which payment method types those are?
/**
* @param $customer_id
* @param $price_id
* @param string $currency
* @return \Stripe\Subscription
* @throws ApiErrorException
*/
public function createSubscription($customer_id, $price_id, string $currency = "USD"): \Stripe\Subscription
{
return $this->getClient()->subscriptions->create([
'customer' => $customer_id,
'items' => [
[
'price' => $price_id
]
],
'currency' => strtolower($currency),
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent'],
]);
}
sec
i use this like this:
$stripeCustomer = $stripeAPI->checkAndCreateCustomer($this->_getAccount(), $this->_getSession()->getDefaultCurrency());
$sub = $stripeAPI->createSubscription($stripeCustomer->id, $price->id, $this->_getSession()->getDefaultCurrency());
$response = [
'subscriptionId' => $sub->id,
'clientSecret' => $sub->latest_invoice->payment_intent->client_secret
];
Again, can you be really specific about WHICH payment method types aren't behaving as your expect?
You've provided a lot of screenshots but haven't actually said which parts aren't behaving llike you expect
ok. i've disabled every payment method on stripe dashboard, but on frontend sepa and paypal shows up
Where in the dashboard are you disabling them? Can you share the link?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
SEPA Direct Debit is off as well
only cards are on
Hmm... can you share the Subscription ID that you created?
sub_1NTSyjGhIhXmDWFT3MLqUNav
Can you show me your code where you're calling stripe.elements and the options you pass in there?
sec
i first call to by php server for the subscription id and the secret ^
then:
fetch(stripeConfig.urls.subscribeIntent, {
method: 'POST',
body: formData,
}).then((r) => r.json().then(this.createElements.bind(this)).then((elements) => {
const paymentElement = elements.create('payment');
//const addressElement = elements.create('address', {mode: 'billing'});
this.createModal({
type: 'subscription',
actionText: 'Pay ' + price_text
}, () => {
//addressElement.mount('#address-element');
paymentElement.mount('#payment-element')
});
}))
No, I just need to see the client-side code where you initialize elements
this is client side
You cshould have code that calls stripe.elements()
This would be coming before the code you're sharing
o shh.. sorry
this is createElements:
createElements({clientSecret}) {
return new Promise((resolve, reject) => {
this.getStripe().then(() => {
this.elements = this.Stripe.elements({
clientSecret: clientSecret,
appearance: {
theme: 'night',
variables: {
colorPrimary: '#55D3F9',
colorBackground: '#2b3750',
},
rules: {
'.Tab': {
borderColor: '#abb0ba',
boxShadow: 'none'
},
'.Input': {
borderColor: '#abb0ba',
boxShadow: 'none'
},
'.Input--focused': {
borderColor: '#abb0ba',
colorBackground: '#1a263f'
}
}
},
fields: {
billingDetails: {
name: 'auto',
address: {
line1: 'auto',
city: 'auto',
country: 'auto',
postalCode: 'auto'
}
}
}
});
resolve(this.elements)
});
})
}
Hello! I'm taking over and catching up...
hi!
What payment methods do you have enabled for Invoices here? https://dashboard.stripe.com/settings/billing/invoice
many were enabled, i just disabled them on test
now its like this:
still paypal shows up:
is this shared between test/production?
Yes, those settings are account wide.
To clarify, you don't want PayPal to show up there?
There should have been a setting in the Invoice template payment methods for PayPal; is it there? Is it disabled when you click on manage?
Yep. Oh, so you haven't activated PayPal on that account yet?
nope
Gotcha. Okay, let's try handling this another way. Can you change the payment_method_types when creating the Subscription to only be card? https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-payment_method_types
Needs to be nested under payment_settings.
I don't think it's a bug, just kinda unintuitive behavior, and maybe a gap in the Dashboard. I think accounts that have PayPal have it enabled by default. Normally you could go to the Invoice settings page I linked you to and turn it off, but you haven't enabled it in live mode for that account, so the setting is disabled.
Work is being done to improve that entire area of the Dashboard, so it shouldn't be an issue when that work is complete.
is the flow correct? every time a customer wants to subscribe to a plan, i create a subscription and prompt the user to enter payment info.
if payment continues, i catch it via webhooks
Yep, that sounds correct.
Happy to help!