#surajpatidar
1 messages · Page 1 of 1 (latest)
Can you share the request ID (req_xxx) with the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
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.
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.
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
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
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
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?
but in destination charge if i set 10% application fees so stripe cut processing fee from application fees
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
means you say i will calculate stripe fee + platform fee and then added amount on application fees right
so it possible to stripe fees % change every time or not
No it shouldn't
okay
please don't close chat
i need one help
i have use stripe checkout for destination charge
Sure
stripe.error.InvalidRequestError: Request req_VelTOfeOCxD7Dt: No such charge: 'py_1NQNeaE9YLYsLUB7zi5DJdWA'
now i have simple use destination charge but it give error like that
i have folloe this doc https://stripe.com/docs/connect/collect-then-transfer-guide?payment-ui=checkout
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
how to set stripe account header because i have use this stripe checkout with destination charge so in this doc https://stripe.com/docs/connect/collect-then-transfer-guide?payment-ui=checkout
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)```
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
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 ?
The Connected Account Id, but not there! Your code above is good alreayd
okay
how to add connect Account id in header like that ?
return redirect(session.url, headers={"Stripe-Account": order.provider.stripe_account.id})
No not this code, in the code you were send out req_VelTOfeOCxD7Dt
then how to solve this error because i have controll on this code
Can you provide the code sent the request req_VelTOfeOCxD7Dt?
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)```
No that's not. Check this https://dashboard.stripe.com/test/logs/req_E3iGhJEtY4fTLE
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
It is a GET /v1/charges/py_.... request
i have problem from this part
wehbook payment.created
Yes, and can you find the code upon receiving this webhook event?
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---------------------------")```
This part stripe.Charge.retrieve
You need a Stripe Account header here
in my dashboard show 12 events and i have received 13 events
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}}',
)
No, not that
I mean this part
Charge.sync_from_stripe_data(stripe.Charge.retrieve(event.data["object"]["id"]))
this stripe.Charge.retrieve(....)
in this part i need to add Account Header right ?
Yep
this event "payment.created" for connected account right so need Stripe Account Header to find this event ?
No, you need Stripe Account header inside the call stripe.Charge.retrieve
stripe.Charge.retrieve(event.data["object"]["id"], {stripe_account: 'acct_xxx'})
stripe.error.AuthenticationError: Invalid API Key provided: {'stripe******************************B7'}
You sure you passed in correct Connected Account Id?
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```
Not familiar with this line
target_cls(**kwargs).api_retrieve(
stripe_account=stripe_account, api_key=event.default_api_key
)
Can you find the request on your Dashboard log? https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.