#bayorwor

1 messages · Page 1 of 1 (latest)

iron wingBOT
little jackal
blazing wharf
#

It works on test mode but doesn’t on production or live

#

@little jackal find snippets here of my code here:

// Step 2: Create a customer in Stripe
let customer = await stripe.customers.create({
email: email,
name: lead_name,
});

let source = await stripe.customers.createSource(customer.id, {
  source: token,
});

await stripe.customers
  .verifySource(customer.id, source.id, {
    amounts: [35, 40],
  })
  .then(async () => {
    if (selected_method === "ach" && totalFees * 100 > 0) {
      const ipAddress =
        req.headers["x-forwarded-for"] || req.connection.remoteAddress;
      const userAgent = req.headers["user-agent"];

      await stripe.paymentIntents.create({
        payment_method: source.id,
        setup_future_usage: "off_session",
        customer: customer.id,
        amount: Math.round(totalFees.toFixed(2) * 100),
        currency: "usd",
        confirm: true,
        payment_method_types: ["us_bank_account"],
        payment_method_options: {
          us_bank_account: {
            verification_method: "microdeposits",
          },
        },
        mandate_data: {
          customer_acceptance: {
            type: "online",
            online: {
              ip_address: ipAddress,
              user_agent: userAgent,
            },
          },
        },
      });
    }
  });

const subscriptionSchedule = await stripe.subscriptionSchedules.create({
  customer: customer.id,
  start_date: unix,
  end_behavior: "cancel",
  phases: [
    {
      items: [
        {
          price: priceID,
          // quantity: 1,
        },
      ],
      default_tax_rates: ["txr_XXXXX"],
      iterations: parseInt(contract_length),
    },
  ],
});
little jackal
#

what does "it doesn't work" mean? do you have an example of a specific error?

blazing wharf
#

Yes, sharing

little jackal
#

note the code you share doesn't make sense really

#

you're using both the legacy ACH Sources integration, and PaymentIntents. Don't use that and try to combine the old and new, use the guide I shared

blazing wharf
#

Ok

#

{
"error": {
"code": "bank_account_verification_failed",
"doc_url": "https://stripe.com/docs/error-codes/bank-account-verification-failed",
"message": "The amounts provided do not match the amounts that were sent to the bank account. To continue trying to verify the account, please reach out to us directly.",

}

@little jackal this the error I'm getting

Learn more about error codes and how to resolve them.

little jackal
#

yeah that's becaues you're just trying to use those test values in live mode

#

I don't think you understand how this works.

in livemode, we send the microdeposit to the customer's bank. They arrive in a day or two. The customer checks their bank statement and sees the amounts. They contact you to tell you what they are. You call our API and pass the amounts, and we check if they matched what we sent.

blazing wharf
#

At what point do you send the micro-deposits

  1. create source or after subscription or paymentIntent? @little jackal
little jackal
#

not sure, I think it's when the Source is created

#

again, that is legacy and deprecated API, don't use it.

blazing wharf
#

Yeah, for sure

little jackal
#

use our official guide that allows for instant verification without waiting for days for microdeposits(and if microdeposits are required, we have tools to help like hosted pages)

blazing wharf
#

Can you help with snippets?, if any

little jackal
blazing wharf
#

Ok, thanks