#xxxxx-payouts

1 messages · Page 1 of 1 (latest)

vagrant mural
#

Hey! Can you share an example?

#

To be clear, if you're using a manual payout schedule then only you (or your API keys) can create these payouts

wheat thorn
#

yes sure.

#

as its a simple logic.

#

I think its correct then why its creating multiple payout. I am not able to figure out why since yesterday.

#

I also added another another condition !order.payout_id but still the problem is not resolved.

vagrant mural
#

It's really difficult for us to understand what's going on there without any context of your application

wheat thorn
#

what we are doing basically we are fetching those orders whose status is complete then for a particular order just calling the payout api, thats it .

vagrant mural
#

And is it creating multiple payouts for a single order (order.order_number)?

wheat thorn
#

yes.

#

you can see here

vagrant mural
#

My guess is this is a race condition, and something is calling sendPayouts multiple times before you can update the payout_id, which is the only safe guard

wheat thorn
#

so what should i do ?

vagrant mural
#

You need to debug this I'm afraid. This isn't a Stripe issue

wheat thorn
#

you mean to say the payout api is called multiple times before updating the payout_id.

vagrant mural
#

That's my guess, yes

#

You're looking up multiple orders, right:

.findWithRelationsByCondition(
        {
          is_payout_done: false,
          completed_date: Not(IsNull()),
          payout_id: IsNull(),
        },
        ['products'],
      )
wheat thorn
#

Do you have any idea to solve this race around condition?

vagrant mural
#

What is the output of your orders callback variable there?

wheat thorn
#

an array of orders.

vagrant mural
#

Log the output and share it

wheat thorn
#

ORDERS [
Order {
id: 164,
order_number: 164,
buyer_user_id: 7,
shipping_method_id: 3,
buyer_user_address_id: null,
order_status_id: 3,
seller_user_id: 17,
shipping_partner_id: null,
shipment_tracking_id: null,
payment_method_id: 1,
payment_gateway_id: 1,
payment_status_id: null,
payment_method_token: {
id: 'card_1KP6ZPHFt6qIi7wnyeKFa4hM',
last4: '0077',
brand: 'visa'
},
tax_id: 20,
tax_value: 0,
payment_id: 'pi_3KWfINHFt6qIi7wn0NIq3BsY',
order_cancel_reason: null,
shipping_cost: '0.00',
product_total: 6,
is_refund_fee_charged: false,
delivery_date: null,
completed_date: 2022-03-03T11:25:32.641Z,
canceled_date: null,
canceled_by: null,
is_payout_done: false,
is_refund_done: false,
payout_failure_status: null,
refund_failure_status: null,
shipping_date: null,
payout_id: null,
refund_id: null,
shipment_id: null,
rate: null,
label_url: null,
easy_post_tracking_code: null,
transfer_id: 'tr_3KWfINHFt6qIi7wn0NItc7pK',
is_offer_accepted: null,
quantity: 1,
created_at: 2022-02-23T21:45:38.027Z,
updated_at: 2022-03-02T21:55:32.640Z,
deleted_at: null,
is_read: false,
products: [ [Product] ],
formatted_order_number: 'GTO00000000164'
}
]

#

this is my order array.

vagrant mural
#

So there's a single entry. And did that create multiple payout objects with Stripe?

wheat thorn
#

yes.

#

it's working well on localhost but creating problem on staging env.

#

i am really confused how can i solve this one.

vagrant mural
#

Yeah, I've no idea I'm afraid. This is something you'll need to work through as it's not specific to our APIs/products

#

My guess is there's a race condition calling the Payout API multiple times before your order DB is updated to reflect that it has been paid out