#renlaer057

1 messages · Page 1 of 1 (latest)

proper laurelBOT
red stump
#

Sorry I don't follow the question. What order do you mean?

split marlin
#

I first created a checkout session and we developers got cs_test_a1XYgFhPB7Dj0lJYTQ45QR9fp8zgLblOM8zpBM0fRgdx7GaJhizRfyfad5. When the customer tried to pay, Stripe refused and the order was cancelled. Then we received the payment_intent.canceled event, but in this event, we did not see the ID cs_test_a1XYgFhPB7Dj0lJYTQ45QR9fp8zgLblOM8zpBM0fRgdx7GaJhizRfyfad5, which made us unable to update the order status

#

Developers need these two IDs to appear in the same event so that we can synchronously update the status of this order to canceled, otherwise it cannot correspond.

#

How can we solve it?

red stump
#

I see. When you create the Checkout Session, let's include a metadata for its underlying PaymentIntent. Later on when you received payment_intent.canceled, you can use the metadata there to match it back to your database

split marlin
#

When we create the checkout session, we get this parameter "payment_intent": "pi_1Gt00z2eZvKYlo2CqQSXWcPB", ?

red stump
#

yes, expand it

split marlin
#

I checked the checkout session I just created in the developer log, and it didn't return this parameter to me.

#

payment_intent

#

Request ID: req_i0FvtUmnQsr7XE

#

Payment_intent is not included in the response body

#

Is it necessary to listen to other webhook events to get Payment_intent?

#

Why is it a null value?

red stump
#

req_i0FvtUmnQsr7XE is when you created the Checkout Session. It hasn't been paid yet, so there will be no PaymentIntent.

red stump
split marlin
#

What's the meaning?

#

When I create a checkout session, just fill in a value in the metadata?

#

Fill in a unique value arbitrarily?

red stump
#

Yes, and save it in your Database, like cs_test_xxx, map with metadata_y

#

Later on if you receive payment_intent.cancelled with metadata_y, you can matching back to your Database

#

to know that's cs_test_xxx

split marlin
#

In payment_intent.canceled, this parameter was returned to me, which is "metadata": { },

#

right?

red stump
#

yeah (please test it out)

split marlin
#

OK,

#

right?

#

Did I fill it out correctly?

red stump
#

Look like so!

split marlin
#

"metadata": {
},

#

},
"type": "charge.failed"
}

#

I'm in this event, I don't see the metadata I want, he is empty

red stump
#

This is a Charge object, right?

#

not a PaymentIntent

#

metadata is per object. Charge is an object inside the PaymentIntent object

split marlin
#

payment_intent.payment_failed

#

Can this receive metadata?

red stump
#

It should

#

oh wait

split marlin
#

"metadata": {
},

#

is also empty

red stump
split marlin
#

。。。?

red stump
split marlin
#

what

#

I can't fill it out when creating a checkout session? then what do I do

red stump
#

You can, but by a different paramter

#

not the direct metadata parameter, but payment)intent_data.metadata

split marlin
#

Please give me a complete example about payment)intent_data.metadata

red stump
#

Depends on the language. For example in Ruby

co = Stripe::Checkout::Session.create({
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  line_items: [
    {price: 'price_1JkLX8Emaib10qkRG67HAWt8', quantity: 2},
  ],
  payment_intent_data: {
    metadata: {
      key: 'value',
    }
  },
  mode: 'payment',
})
#

It's really just wrap inside a payment_intent_data block

split marlin
#

Can you give me a copy of c#?

#

C# SDK var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = dto.AmountOfMoney,
Currency = dto.MonetaryUnit,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = dto.ProductName,
Description=dto.ProductDesc
},
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = domain,
CancelUrl = domain,

            ConsentCollection = new SessionConsentCollectionOptions()
            {
                TermsOfService = "required",/**/
            },

            BillingAddressCollection = "required", // 收集账单地址
            ShippingAddressCollection = new SessionShippingAddressCollectionOptions
            {
            },
            PaymentMethodTypes = new List<string> { dto.PaymentMethodStr },
            Metadata= new Dictionary<string, string>() { { "UnId", unId } }
            //ExpiresAt = DateTime.Now.AddMinutes(dto.ExpireMinute)
        };
#

These are the parameters the developer just filled in. Please help him correct them.

red stump
#

You should ask them join this chat

split marlin
#

He has no discord

#

What do these addresses mean? Send him to check?

#

You sent 2, which one should he look at?

proper laurelBOT
split marlin
#

According to my code, can you modify the correct parameters for me?

#

C# SDK var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = dto.AmountOfMoney,
Currency = dto.MonetaryUnit,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = dto.ProductName,
Description=dto.ProductDesc
},
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = domain,
CancelUrl = domain,

            ConsentCollection = new SessionConsentCollectionOptions()
            {
                TermsOfService = "required",/**/
            },

            BillingAddressCollection = "required", // 收集账单地址
            ShippingAddressCollection = new SessionShippingAddressCollectionOptions
            {
            },
            PaymentMethodTypes = new List<string> { dto.PaymentMethodStr },
            Metadata= new Dictionary<string, string>() { { "UnId", unId } }
            //ExpiresAt = DateTime.Now.AddMinutes(dto.ExpireMinute)
        };
red stump
#

No, please ask your developer to. Send him those 2 links and they would know