#juiceman

1 messages ยท Page 1 of 1 (latest)

subtle flameBOT
wary jetty
#

Hello ๐Ÿ‘‹
Do you have a request ID that I can take a look at?

cunning forge
#

1 sec

#

req_bhS9jfUW2JUWSq

#

I think there is a issue with the logic with my code though

#

can i share my code with u

#

i been trying to fix this for like a week

wary jetty
#

Its because you're passing in a source transaction which is of $1

cunning forge
#

oh i see

#

let me try somethig

#

it kinda work once idk

#

im doing something silly

#

so my idea is this. if the good sold for 10$, i want to keep 20%

#

charge = await stripe.charges.create({
amount: amount*.20,
currency: "usd",
source: campaignStripeBankId,
description: Campaign id is${campaignId}. Campaign name is ${description}
});

      // here



       // give the rest to the seller
      const transfer = await stripe.transfers.create({
        amount: amount*.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: channelOwnerStripeBankAccount.stripeBankId,
      });
#

im really close to getting this to work!

wary jetty
#

You'd want to print the charge & transfer amount
transfer amount should be equal or less than the charge amount.

cunning forge
#

1 sec

#

charge {
id: 'py_1MU9z2KvlLDAjAUzmkpx2F4p',
object: 'charge',
amount: 10000,
amount_captured: 10000,
amount_refunded: 0,
application: 'ca_NBRmmORkIULK2j196pebdDJ4H0wJAI1i',
application_fee: null,
application_fee_amount: null,
balance_transaction: 'txn_1MU9z2KvlLDAjAUziNZOYFLn',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: null,
name: null,
phone: null
},
calculated_statement_descriptor: null,
captured: true,
created: 1674656992,
currency: 'usd',
customer: null,
description: 'Campaign id is63cecd85d63e3715cfb12817. Campaign name is jcasasmail@gmail.com',
destination: null,
dispute: null,
disputed: false,
failure_balance_transaction: null,
failure_code: null,
failure_message: null,
fraud_details: {},
invoice: null,
livemode: false,
metadata: {},
on_behalf_of: null,
order: null,
outcome: {
network_status: 'approved_by_network',
reason: null,
risk_level: 'not_assessed',
seller_message: 'Payment complete.',
type: 'authorized'
},
paid: true,
payment_intent: null,
payment_method: null,
payment_method_details: { stripe_account: {}, type: 'stripe_account' },
receipt_email: null,
receipt_number: null,
receipt_url: 'https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xSFRyZE5LdmxMREFqQVV6KOH5xJ4GMgYrqpwr82U6LBZD81u6epQwBh5cpPjzq2Sk0cwhF0sQ7j1UfLBqgPmomiyh9ecQ3LlwLAbZ',
refunded: false,
refunds: {
object: 'list',
data: [],
has_more: false,
total_count: 0,
url: '/v1/charges/py_1MU9z2KvlLDAjAUzmkpx2F4p/refunds'
},
review: null,
shipping: null,
source: { id: 'acct_1MTo3U4JzdkAys4y', object: 'account' },
source_transfer: 'tr_1MU9z24JzdkAys4yJfVVVyqg',
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'succeeded',
transfer_data: null,
transfer_group: null
}
transfer amount 40000

#

the charge is an obj, u mean the charge amount

#

ok jk

#

i see what u said

#

1 sec

#

charge amount: 10000,
transfer amount 40000

#

ok

#

1 sec

cunning forge
#

1 sec

#

Error code is: StripeInvalidRequestError: Insufficient funds in Stripe account. In test mode, you can add funds to your available balance

#

so let me tell u what the goal of this is.
when a seller sells a good for 10$, 8$ should go to the seller, and 2$ should go to the company. does the following code accomplish that:

#

// charge
charge = await stripe.charges.create({
amount: amount,
currency: "usd",
source: buyerStripeBankId,
description: Campaign id is${campaignId}. Campaign name is ${description}
});

       // from the charge, give 80% of it to the channel owner
      const transfer = await stripe.transfers.create({
        amount: charge.amount*.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: channelOwnerStripeBankAccount.stripeBankId,
      });
wary jetty
#

You've tested your code and it doesn't seem to work so I'm not sure ๐Ÿ˜…

In order to get around to insufficient balance, you can create a test transaction via dashboard using the test card here
https://stripe.com/docs/testing#available-balance

That should allow you to continue testing

cunning forge
#

You've tested your code and it doesn't seem to work so I'm not sure ๐Ÿ˜…
--- im not asking to check the code. im asking if what i am describing is achieved by the code. im just not sure that i am using the correct apis.thats what i was asking to get checked please

#

where is the make transaction button lol

#

i addded click funds, and did everything, not sure if thats it

wary jetty
#

Ah it should be under "Payments" tab

#

im asking if what i am describing is achieved by the code.
Yes it is possible to do this via code

cunning forge
#

im asking if what i am describing is achieved by the code.
Yes it is possible to do this via code
--- I am asking if the code i provided does what i described

#

i clicked on create payment

#

then i got 3 options. not sure if this is it

wary jetty
#

You can do manual payment

#

I am asking if the code i provided does what i described
yeah your code to create charge and making a transfer looks fine to me

cunning forge
wary jetty
#

Yup, now you should have enough balance to continue your testing..

cunning forge
#

why do i even have to do this payment on the dashboard thing?
what does this payment mean?

wary jetty
#

You got an error earlier about not having enough balance๐Ÿ˜…

Error code is: StripeInvalidRequestError: Insufficient funds in Stripe account. In test mode, you can add funds to your available balance

This payment moves funds directly to your available balance which would allow you to continue to test transfers

cunning forge
#

But that transfer should be from the charge.

#

Please review my code with comment of how the money should move

#

Iโ€™m like 1 step away from finally figuring this out

autumn island
#

Right, the transfer would be from the funds from this new charge. That error makes it sound like the funds from that original charge have been either send off or paid out already

cunning forge
#

wut!!!
im so confused.
how can i find out if it has been send off or paid out?

sorry im a complete noob at stripe

autumn island
#

Let's take a step back. Where did you get the "Insufficient funds in Stripe account. In test mode, you can add funds to your available balance" error? What API call where you making?

cunning forge
#

when a seller sells a good for 10$, 8$ should go to the seller, and 2$ should go to the company. does the following code accomplish that:

charge = await stripe.charges.create({
amount: amount,
currency: "usd",
source: buyerStripeBankId,
description: Campaign id is${campaignId}. Campaign name is ${description}
});

       // from the charge, give 80% of it to the seller 
      const transfer = await stripe.transfers.create({
        amount: charge.amount*.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: sellerStripeBankAccount.stripeBankId,
      });
autumn island
#

It looks like it should but in practice it sounds like it isn't. Is your transfer call getting that error? If so can you get me a request ID (req_123) from a time that it got that error?

cunning forge
#

1 sec

#

req_bhS9jfUW2JUWSq

autumn island
#

That's the request that was already requested at the start

#

And the issue came down to the fact you were trying to move $4 of a $1 charge, so it sounds like the wrong charge ID may have been passed there

cunning forge
#

weird

autumn island
#

I was asking specifically about the "Insufficient funds in Stripe account. In test mode, you can add funds to your available balance" error, is that the one you are currently running in to or are you running in to that transfer issue still?

cunning forge
#

1 sec

#

ok so i made it really expensive so that i can use all the funds

#

these is the new error:

#

Error code is: StripeInvalidRequestError: Amount must be no more than $999,999.99

#

based of the same code i send u

autumn island
#

Yep that is the USD limit, you can make it smaller than that and you won't get that error

cunning forge
#

ok i got the error again:
Insufficient funds in Stripe account. In test mode, you can add funds to your available balance (bypassing your pending balance) by creating a charge with

#

those funds should be coming from the charge though

#

so confusing

autumn island
#

Can you send me the request ID from this time when you got the error?

cunning forge
#

req_uumQdwfB6eTuzY

#

these should be the values::

charge amount : 500000
transfer amount : 400000

#

this is the code. it actually crashes before initializing transfer

charge = await stripe.charges.create({
        amount: amount,
        currency: "usd",
        source: campaignStripeBankId, // buyer
        description: `Campaign id is${campaignId}. Campaign name is ${description}`
      });

      console.log('charge amount :           ',charge.amount);
      console.log('transfer amount  :           ',charge.amount*.80);

       // from the charge, give 80% of it to the seller
      const transfer = await stripe.transfers.create({
        amount: charge.amount*.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: channelOwnerStripeBankAccount.stripeBankId, // seller stripe
      });
autumn island
#

Gotcha, thank you for that request ID. I am looking in to why that error is here, it definitely looks like it shouldn't need to check your account's actual balance. Will get back with what I can find

#

Is the crash an uncaught exception?

cunning forge
#

Itโ€™s on try catch

#

Not sure if thatโ€™s the same

autumn island
#

Is your catch only specifying certain kinds of exception? If you do that it is possible that the stripe exception isn't getting caught by your try catch

#

Still looking in to the transfer request will let you know what I can find

cunning forge
#

well this is the whole function::

async function chargeCardToken(channelOwnerStripeBankAccount,campaignStripeBankId, token, amount, description, stripeUserId, campaignId, campaignCreator, channelCreatorId) {
let charge;
try {

    // charge 
     charge = await stripe.charges.create({
        amount: amount,
        currency: "usd",
        source: campaignStripeBankId, // buyer
        description: `Campaign id is${campaignId}. Campaign name is ${description}`
      });

      console.log('charge amount :           ',charge.amount);
      console.log('transfer amount  :           ',charge.amount*.80);

       // from the charge, give 80% of it to the seller
      const transfer = await stripe.transfers.create({
        amount: charge.amount*.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: channelOwnerStripeBankAccount.stripeBankId, // seller stripe
      });


    createCharge({ stripePaymentId: charge.id, stripeUserId: stripeUserId, itemId: campaignId, itemType: 'campaign purchased data from channel', total: 0 - amount, error: 'n/a', creator: campaignCreator })
    createCharge({ stripePaymentId: charge.id, stripeUserId: stripeUserId, itemId: campaignId, itemType: 'channel sold data to campaign', total: amount, error: 'n/a', creator: channelCreatorId })

    //console.log('SUCCESSS IN CHARGING',paymentIntent)
} catch (err) {
    console.log('Error code is: ', err);

}
return charge;

}

autumn island
#

So it looks like this error is happening because that charge's funds had already become available on your account but were transferred away

cunning forge
#

y

#

im not transfering nothing lol

autumn island
#

Still finding docs to help explain this

cunning forge
#

this operation should not be depended on the funds on the account though. like why would be? i am trying to add funds to the accoutn from the charge generated

#

so i ask, are u sure that the code is doing what I am intending?

#

if all the money is coming from the buyer, what else matters?

#

what am i missign?

autumn island
#

Once the funds are on your account, they are mixed in with your other available funds

#

So once they are there. If you pay out your funds or transfer them elsewhere, they are gone. So you still need that amount in your available balance before making the transfer

#

So to do this, you can make another charge on your account with one of our test cards that bypasses pending balance, if you have at least $4000 in available funds on your account, you will be able to transfer the funds using that one charge as your source transaction https://stripe.com/docs/testing#available-balance

Simulate payments to test your integration.

cunning forge
#

r u sure?

so i am confused as to how this issue would be resolved in production..

How do i make it wait for the funds to make it to the account?

autumn island
#

The source_transaction parameter is the way to do this. What happened here is that the charge you are using is so old that the funds already landed and were sent elsewhere

#

If you make that call on a fresh charge, the source_transaction parameter will make Stripe wait for the funds to land before being sent off

cunning forge
#

wut!!
thats so strange, why is it using an old charge?

i am not sure how to use a new charge

like the code is creating a charge right there. how could it be using an old charge?

#

like the code is only a few lines short here lol

dreamy tapir
#

๐Ÿ‘‹ stepping in

#

Can you log out the charge there before you create the transfer

cunning forge
#

charge: {
id: 'py_1MUCTEKvlLDAjAUzLYR7u7NF',
object: 'charge',
amount: 500000,
amount_captured: 500000,
amount_refunded: 0,
application: 'ca_NBRmmORkIULK2j196pebdDJ4H0wJAI1i',
application_fee: null,
application_fee_amount: null,
balance_transaction: 'txn_1MUCTEKvlLDAjAUzcxIIq3a3',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: null,
name: null,
phone: null
},
calculated_statement_descriptor: null,
captured: true,
created: 1674666552,
currency: 'usd',
customer: null,
description: 'Campaign id is63cecd85d63e3715cfb12817. Campaign name is jcasasmail@gmail.com',
destination: null,
dispute: null,
disputed: false,
failure_balance_transaction: null,
failure_code: null,
failure_message: null,
fraud_details: {},
invoice: null,
livemode: false,
metadata: {},
on_behalf_of: null,
order: null,
outcome: {
network_status: 'approved_by_network',
reason: null,
risk_level: 'not_assessed',
seller_message: 'Payment complete.',
type: 'authorized'
},
paid: true,
payment_intent: null,
payment_method: null,
payment_method_details: { stripe_account: {}, type: 'stripe_account' },
receipt_email: null,
receipt_number: null,
receipt_url: 'https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xSFRyZE5LdmxMREFqQVV6KLnExZ4GMgYq9LcuRmo6LBZr-I_NdKiNxAy8D1eNPnlHf278uH6sRr8xYNbuhKwM5QkrwHc_fKVJNsUw',
refunded: false,
refunds: {
object: 'list',
data: [],
has_more: false,
total_count: 0,
url: '/v1/charges/py_1MUCTEKvlLDAjAUzLYR7u7NF/refunds'
},
review: null,
shipping: null,
source: { id: 'acct_1MTo3U4JzdkAys4y', object: 'account' },
source_transfer: 'tr_1MUCTE4JzdkAys4y9paw6rjW',
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'succeeded',
transfer_data: null,
transfer_group: null
}
payment is undefined

dreamy tapir
#

Okay this is a super long thread

#

Can you clarify what the outstanding question or confusion is?

#

I'd be happy to help

cunning forge
#

the transfer does not work

#

the issue is. if the good sold for 10$, i want to keep 20%. for some reason that is not working

#

the following code should be achiving that functionality, but there is a bug:

async function chargeCardToken(channelOwnerStripeBankAccount,campaignStripeBankId, token, amount, description, stripeUserId, campaignId, campaignCreator, channelCreatorId) {
let charge;
try {

    // charge 
     charge = await stripe.charges.create({
        amount: amount,
        currency: "usd",
        source: campaignStripeBankId, // buyer
        description: Campaign id is${campaignId}. Campaign name is ${description}
      });

      console.log('charge amount :           ',charge.amount);
      console.log('transfer amount  :           ',charge.amount.80);

       // from the charge, give 80% of it to the seller
      const transfer = await stripe.transfers.create({
        amount: charge.amount.80,
        currency: "usd",
        source_transaction: charge.id,
        destination: channelOwnerStripeBankAccount.stripeBankId, // seller stripe
      });


    createCharge({ stripePaymentId: charge.id, stripeUserId: stripeUserId, itemId: campaignId, itemType: 'campaign purchased data from channel', total: 0 - amount, error: 'n/a', creator: campaignCreator })
    createCharge({ stripePaymentId: charge.id, stripeUserId: stripeUserId, itemId: campaignId, itemType: 'channel sold data to campaign', total: amount, error: 'n/a', creator: channelCreatorId })

    //console.log('SUCCESSS IN CHARGING',paymentIntent)
} catch (err) {
    console.log('Error code is: ', err);

}
return charge;

}

dreamy tapir
#

Okay when you say it "doesn't work", what happens?

#

Is there an error?

#

Do you see the request reaching Stripe at all? (Is there a failed request in your Dashboard)?

cunning forge
#

Error code is: StripeInvalidRequestError: Insufficient funds in Stripe account. In test mode, you can add funds to your available balance (bypassing your pending balance) by creating a charge with 4000 0000 0000 0077 as the card number. If you provide source_transaction and the source transaction's available_on date has passed, you still need funds in your available balance. You can use the /v1/balance endpoint to view your Stripe balance (for more details, see stripe.com/docs/api#balance).

cunning forge
#

I just need help figuring out the issue of the 'insufficient funds'

all i want to do is charge the consumer, pay the seller, keep some of the money. im not sure what the confusion is

dreamy tapir
#

Okay so as you can see from the above you don't have sufficient funds

#

So there are two options here

cunning forge
#

right but that does not make sense

#

that makes no sense

#

why can I charge for the good, and then say that there are no funds?

#

is the charge not going through or something?

dreamy tapir
#

There are funds, but funds are not immediately availabe to be transferred

#

Unless you use source_transaction which I see you are attempting to do above.

#

So let's pause.

#

There should be a request ID that goes along with the error

#

Can you provide me that specific request ID

#

So that I can look at what exactly is going on

#

It looks like req_xxxx

cunning forge
#

req_2kSQcPfO73ad1t and req_kSHY1dGEE15hNx

dreamy tapir
#

Thanks give me a sec to look

#

Okay so a couple things here

#

The Charge you are creating is creating an Account Debit.

#

This means it is pulling funds from your Connected Account

#

It is not charging a Customer

#

I assume that is not intended

#

And you want to be actually charging a Customer, yes?

cunning forge
#

yes!!! ^^^

#

thank u!

#

I though i was charging the customer

dreamy tapir
#

Yeah so you need to change what you are using for the source value in your Charge request

cunning forge
#

how do I do that?
below is the code that creates an account and grabs the banking information.
the source value that I am using is the account.id that i created. so if that is not correct, then what should I be doing for this piece?

const account = await stripe.accounts.create({ type: 'express' });
const accountLink = await stripe.accountLinks.create({
account: account.id,
refresh_url: 'http://localhost:4200/settings',
return_url: 'http://localhost:4200/settings',
type: 'account_onboarding',
});
res.status(201).json({
url: accountLink.url
})
};

#

so do i need to add a credit card or smething?

dreamy tapir
#

Yes you need to collect your customer's payment method

#

What integration are you using for payments?

#

Or have you not set that up yet?

cunning forge
#

i though that that was it lol

#

one sec let me build that real quick

#

so use this to save a payment?

const session = await stripe.checkout.sessions.create({
    payment_method_types: ['card'],
    mode: 'setup',
    //customer: 'cus_NBwigdycfQU8U6',
    success_url: 'http://localhost:3000/api/stripe/saveCardToken/{CHECKOUT_SESSION_ID}',
    cancel_url: 'https://example.com/cancel',
});


res.status(201).json({
    url: session.url
})

do i need to use the customer thing?

dreamy tapir
#

Up to you whether you supply a Customer ID or not

#

Actually that will only happen if you actually save the PaymentMethod

#

So yeah you can ignore that

cunning forge
#

wait

#

ignore what

#

the customer id?

dreamy tapir
#

Yep

#

You don't need the Customer ID if you aren't going to take recurring payments in the future

cunning forge
#

ok 1 sec

#

still working on it

dreamy tapir
#

No problem

#

I have to step away but my colleague is stepping in and can help further

#

I'll leave the thread open

cunning forge
#

pl

#

i mean 1 sec

#

almost there

dreamy tapir
#

๐Ÿ‘

cunning forge
#

almost there

#

almost there boss

#

im taking a lunch break but i just got it to work