#surajpatidar

1 messages · Page 1 of 1 (latest)

slender nightBOT
solemn gorge
storm crater
#

stripe.error.InvalidRequestError: Request req_Ick2qxV8syNQqN: No such PaymentMethod: 'pm_1NQMlLECJUF37lWXiQ0MeVQs'; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account.

solemn gorge
#

pm_1NQMlLECJUF37lWXiQ0MeVQs was created on the platform acct_1MxqqUECJUF37lWX whereas you tried to access it from the connected account acct_1NNZ2YE9YLYsLUB7. You should create the payment method on the connected account with Stripe-Account header in order to access it from the connected account.

storm crater
#

ho ti create payment intetn from there

#

can you please help i want to direct charge from customer to connect account like that
100$ customer pay
10$ platform fees
remeaing stripe fees and remeaing add on connected account

solemn gorge
#

Can you share why you would like to use Direct Charges on Express account? Direct Charges is only recommended for Standard account. Express account should use Destination Charges or Separate Charges and Transfers

slender nightBOT
storm crater
#

client requirement like that
100$ product so customer pay 100$
platform fees set client 10%
so 10$ is platform
and remeaing 90$ stripe cut processing fees all that

dense yew
#

Sorry that doesn't explain why you want to use Direct Charges on Express account. You shouldn't do that in the first place

#

You can still do Destination Charge for the same requirement

#

I guess you want Connected Account to bear the Stripe processing fee?

storm crater
#

but in destination charge if i set 10% application fees so stripe cut processing fee from application fees

dense yew
#

Yes, correct. But switching over to Direct Charges on Express accounts will run you into a lot of other problem down the road, ie. Express account can't handle Dispute, Platform needs to cover negative balance, you can't use Radar, get metrics, and so on...

#

So the better approach is do a calculation on Platform taking fee, so that it will cover Stripe processing fee

storm crater
#

means you say i will calculate stripe fee + platform fee and then added amount on application fees right

dense yew
#

Yes!

#

You may want to write it down and testing around

storm crater
#

so it possible to stripe fees % change every time or not

dense yew
#

No it shouldn't

storm crater
#

okay

#

please don't close chat

#

i need one help

#

i have use stripe checkout for destination charge

dense yew
#

Sure

storm crater
#

stripe.error.InvalidRequestError: Request req_VelTOfeOCxD7Dt: No such charge: 'py_1NQNeaE9YLYsLUB7zi5DJdWA'

#

now i have simple use destination charge but it give error like that

dense yew
#

The py is on your connected account. Yes using Destination Charge will still generate some Id on your Connected Account, including this py

#

You need to Stripe-account header to view it

storm crater
#
        session = stripe.checkout.Session.create(
            expires_at=int(time.time()) + 1860,
            payment_method_types=["card"],
            customer=stripe_customer.id,
            line_items=[
                {
                    "price_data": {
                        "currency": "usd",
                        "unit_amount": int(total * 100),
                        "product_data": {
                            "name": product.title,
                            "description": product.description,
                        },
                    },
                    "quantity": 1,
                }
            ],
            invoice_creation={
                "enabled": True,
            },
            metadata={
                "order_id": order.id,
            },

            payment_intent_data={
                "application_fee_amount": int(platform_fee * 100),
                "transfer_data": {
                    "destination": order.provider.stripe_account.id,
                },
            },
            mode="payment",
            success_url=f"{prefix}{settings.HOST_NAME}/order/checkout/success",
            cancel_url=f"{prefix}{settings.HOST_NAME}/order/checkout/cancel/",
        )
        Session.sync_from_stripe_data(session)
        # Redirect the user to the Stripe Checkout page
        return redirect(session.url)```
dense yew
#

No you are doing correctly with Destination Charge

#

I mean you need the Stripe account header for the request to retrieve the py_object

#

req_VelTOfeOCxD7Dt

storm crater
#

return redirect(session.url, headers={"Stripe-Account": order.provider.stripe_account.id})

#

i need one confimation In Stripe Accont header which account id i pass connected account or platform account id ?

dense yew
#

The Connected Account Id, but not there! Your code above is good alreayd

storm crater
#

how to add connect Account id in header like that ?
return redirect(session.url, headers={"Stripe-Account": order.provider.stripe_account.id})

dense yew
#

No not this code, in the code you were send out req_VelTOfeOCxD7Dt

storm crater
#

then how to solve this error because i have controll on this code

dense yew
#

Can you provide the code sent the request req_VelTOfeOCxD7Dt?

storm crater
#

code
stripe.error.InvalidRequestError: Request req_E3iGhJEtY4fTLE: No such charge: 'py_1NQOD5E9YLYsLUB7wk7XZX44'

        session = stripe.checkout.Session.create(
            expires_at=int(time.time()) + 1860,
            payment_method_types=["card"],
            customer=stripe_customer.id,
            line_items=[
                {
                    "price_data": {
                        "currency": "usd",
                        "unit_amount": int(total * 100),
                        "product_data": {
                            "name": product.title,
                            "description": product.description,
                        },
                    },
                    "quantity": 1,
                }
            ],
            invoice_creation={
                "enabled": True,
            },
            metadata={
                "order_id": order.id,
            },

            payment_intent_data={
                "application_fee_amount": int(platform_fee * 100),
                "transfer_data": {
                    "destination": order.provider.stripe_account.id,
                },
            },
            mode="payment",
            success_url=f"{prefix}{settings.HOST_NAME}/order/checkout/success",
            cancel_url=f"{prefix}{settings.HOST_NAME}/order/checkout/cancel/",
        )
        Session.sync_from_stripe_data(session)
        # Redirect the user to the Stripe Checkout page
        return redirect(session.url)```
dense yew
#

It is a GET /v1/charges/py_.... request

storm crater
#

i have problem from this part
wehbook payment.created

dense yew
#

Yes, and can you find the code upon receiving this webhook event?

storm crater
#
def payment_created(event, **kwargs):
    print("-------------------------------------payment.created---------------------------")
    event = Event.objects.get(id=event.id)
    print(event.data)
    Charge.sync_from_stripe_data(stripe.Charge.retrieve(event.data["object"]["id"]))
    print("-------------------------------------payment.created completed---------------------------")```
dense yew
#

This part stripe.Charge.retrieve

#

You need a Stripe Account header here

storm crater
#

in my dashboard show 12 events and i have received 13 events

storm crater
# dense yew You need a Stripe Account header here

means you say before checkout i will cretae payment intent right ? with this code stripe.PaymentIntent.create(
amount=1000,
currency="usd",
automatic_payment_methods={"enabled": True},
stripe_account='{{CONNECTED_ACCOUNT_ID}}',
)

dense yew
#

No, not that

#

I mean this part

Charge.sync_from_stripe_data(stripe.Charge.retrieve(event.data["object"]["id"]))
#

this stripe.Charge.retrieve(....)

storm crater
#

in this part i need to add Account Header right ?

dense yew
#

Yep

storm crater
#

this event "payment.created" for connected account right so need Stripe Account Header to find this event ?

dense yew
#

No, you need Stripe Account header inside the call stripe.Charge.retrieve

#
stripe.Charge.retrieve(event.data["object"]["id"], {stripe_account: 'acct_xxx'})
storm crater
#

stripe.error.AuthenticationError: Invalid API Key provided: {'stripe******************************B7'}

dense yew
#

You sure you passed in correct Connected Account Id?

storm crater
#

yes

#

@webhooks.handler("payment.created")
def payment_created(event, **kwargs):
print("-------------------------------------payment.created---------------------------")
event = Event.objects.get(id=event.id)
print(event.data)
Charge.sync_from_stripe_data(stripe.Charge.retrieve(event.data["object"]["id"], {"stripe_account": "acct_1NNZ2YE9YLYsLUB7"}))
print("-------

#

i think add external account id

        # verbs that aren't strictly CRUD but Stripe do intend an update.  Such
        # as invoice.payment_failed.
        kwargs = {"id": id}
        if hasattr(target_cls, "customer"):
            kwargs["customer"] = event.customer

        # For account.external_account.* events
        if event.parts[:2] == ["account", "external_account"] and stripe_account:
            kwargs["account"] = models.Account._get_or_retrieve(id=stripe_account)

        data = target_cls(**kwargs).api_retrieve(
            stripe_account=stripe_account, api_key=event.default_api_key
        )
        # create or update the object from the retrieved Stripe Data
        obj = target_cls.sync_from_stripe_data(data, api_key=event.default_api_key)

    return obj```
dense yew