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

react native stripe element implementation? #20

Closed
AxanIqbal opened this issue Apr 25, 2022 · 2 comments
Closed

react native stripe element implementation? #20

AxanIqbal opened this issue Apr 25, 2022 · 2 comments

Comments

@AxanIqbal
Copy link

Hey there, I've been trying to following this guide i have also created the custom Checkout, i am getting data null in payment_intent and setup_intent is there any option i am missing?

Custom Serializer

class CustomCheckoutRequestSerializer(CheckoutRequestSerializer):
    """Handle creation of a custom checkout session where parameters are customized."""

    def validate(self, attrs):
        stripe_user = get_or_create_stripe_user(user_id=self.context['request'].user.id)
        try:
            checkout_session = stripe_api_create_checkout_session(
                customer_id=stripe_user.customer_id,
                price_id=attrs['price_id'],
                trial_end='auto' if stripe_user.subscription_items.count() == 0 else None,
                payment_method_types=["card"],
                checkout_mode="subscription",
            )
            print(checkout_session)
            attrs['session_id'] = checkout_session['id']
            attrs['customer_id'] = checkout_session['customer']
            attrs['payment_intent'] = checkout_session['payment_intent']
            attrs['url'] = checkout_session['url']
        except StripeError as e:
            raise ValidationError(e.error)
        return attrs

SETTING

DRF_STRIPE = {
    "STRIPE_API_SECRET": env('STRIPE_API', default=''),
    "STRIPE_WEBHOOK_SECRET": "*",
    "NEW_USER_FREE_TRIAL_DAYS": 7,
}
@oscarychen
Copy link
Owner

I suspect it has to with the mode, payment intent might not be always populated: https://stackoverflow.com/questions/66545866/payment-intent-is-null-in-a-subscription-checkout-session

@AxanIqbal
Copy link
Author

i see thanks i guess ill have to go for url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants