#Jinliang

1 messages · Page 1 of 1 (latest)

coarse ermineBOT
limber raptor
#

com.stripe.exception.SignatureVerificationException: No signatures found matching the expected signature for payload

#

The payload of event:

patent crown
#

You mean this is another question now? you managed to fetch the PaymentIntent ?

limber raptor
#

I want to implement scenario: Accept the payment, then split the funds and transfer them to another connected account.

#

Here is the payload of event

patent crown
#

Ok, and now you are facing an excpetion when verifying the signature of the event ?

#

There is two possible causes for this, you are using an incorrect webhook secret or your backend is updating/modifying the raw body of the event

limber raptor
#

Yes

patent crown
#

what programming language are you using for your webhook endpoint ?

limber raptor
#

Java, but without remove the Stripe Account Id, the verifying works

coarse ermineBOT
low flicker
#

Hi! I'm taking over my colleague. Please, give me a moment to catch up.

#

but without remove the Stripe Account Id
You remove it from the original PI call?

limber raptor
#

SessionCreateParams params =
SessionCreateParams
.builder()
.setMode(SessionCreateParams.Mode.PAYMENT)
.addLineItem(
SessionCreateParams.LineItem
.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build()
)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.build();

Session session = Session.create(params, null);

#

After "charge.succeeded" event is received, transfer funds:

TransferCreateParams params =
TransferCreateParams
.builder()
.setAmount(1000L)
.setCurrency("usd")
.setSourceTransaction("{{CHARGE_ID}}")
.setDestination("{{CONNECTED_ACCOUNT_ID}}")
.build();

Transfer transfer = Transfer.create(params)

#

Because the PaymentIntent object does not contain charge after creating the session, so I prepare to receive the charge object in event callback.

low flicker
#

By "event callback" you mean webhook?

limber raptor
#

Yes, the tranfer needs charge id, I don't known how to get the charge id, so i tried the webhook.

#

But, the question is the webhook works before removed the Stripe Account Id, so the webhook secret is correct.

low flicker
#

Which call has the Stripe-Account header?

limber raptor
#

SessionCreateParams params =
SessionCreateParams
.builder()
.setMode(SessionCreateParams.Mode.PAYMENT)
.addLineItem(
SessionCreateParams.LineItem
.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build()
)
.setPaymentIntentData(
SessionCreateParams.PaymentIntentData
.builder()
.setApplicationFeeAmount(123L)
.build()
)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.build();
RequestOptions requestOptions =
RequestOptions.builder().setStripeAccount("{{CONNECTED_ACCOUNT_ID}}").build();

Session session = Session.create(params, requestOptions);

low flicker
limber raptor
#

I want to implement scenario: Accept the payment, then split the funds and transfer them to another connected account.

low flicker
#

And you don't need to use the Stripe-Account header

limber raptor
#

Yes, I faced Transfer Availability issue, there is insufficient available balance sometimes.

#

So refer to Transfer Availablity section, I need charge Id:

#

TransferCreateParams params =
TransferCreateParams
.builder()
.setAmount(1000L)
.setCurrency("usd")
.setSourceTransaction("{{CHARGE_ID}}")
.setDestination("{{CONNECTED_ACCOUNT_ID}}")
.build();

low flicker
#

You can use the transfer_group as well

limber raptor
#

Yes, I've implement using transfer_group solution, but faced Transfer Availability issue, there is insufficient available balance sometimes.

#

Refer this document, I need the CHARGE_ID, the original charge paid by customer

low flicker
#

Okay, I see. Are you able to get the charge from the webhook endpoint if you don't use the Stripe-Account header?

limber raptor
#

The payload of event include the charge object. But there is a exception of calling Webhook.constructEvent()

#

Don't use the Stripe-Account header, you mean remove Stripe.apiKey = xxx ?

low flicker
limber raptor
#

Yes, I removed this.

low flicker
limber raptor
#

Yes, before remove the Stripe-Account , constructEvent() works

low flicker
#

Maybe you are using Stripe API Secret Key from your Connected account?

#

You need to use the Secret Key and Webhook secret from your Platform account.

limber raptor
#

Yes, I use our platform account, I confirm the webhook secret is correct.

#

We can place different order type, one order don't use setStripeAccount("{{CONNECTED_ACCOUNT_ID}}")
, the constructEvent() work, and the other type of order don't use setStripeAccount, then there is a exception at constructEvent() . The same code.

low flicker
#

Could you please share what your webhook code looks like?

low flicker
limber raptor
#

the account: pi_3MrepxIbtRg3bgk61cJd3Gso

#

Don't set the account: pi_3MrerSFCRvzb7CqW1ybkWEi0

low flicker
#

You should never use it in your use case.

limber raptor
#

Yes, I know, the same code support different secenario.

#

I just want to confirm webhook secret is correct, and the parameter of constructEvent is correct.

low flicker
#

But for your connect webhook you should use a different webhook secret

limber raptor
#

We use our platform webhook, I don't understand, any docs?

low flicker
limber raptor
#

Ok, I will try, thank you very much.

low flicker
#

Happy to help. Please, let me know if you have any other questions.