#james_api

1 messages ¡ Page 1 of 1 (latest)

icy rootBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1230023359895441429

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

south willowBOT
dry flare
#

Did you get the Price ID? You can try to expand the Price's Product property

#

Do you use Checkout Session? If yes you can look at the checkout.session.completed instead

zealous lodge
#

@dry flare There's no price property in the payload I received for payment_indent.succeed. I tried checkout.session.completed and it only contains id for payment_intent, payment_link, payment_method_configuration_details

So after user complete checkout session, what's the proper way to get the product information in the webhook?
For subscriptions I can get subscription id and use subscription API to get product, but for one-off payment product I still don't know how to achieve that.

dry flare
#

Do you see line items inside checkout.session.completed?

zealous lodge
#

@dry flare The whole payload looks like this, don't think there's the line items

{
  "after_expiration":null,
  "allow_promotion_codes":false,
  "amount_subtotal":500,
  "amount_total":500,
  "automatic_tax":{
    "enabled":false,
    "liability":null,
    "status":null
  },
  "billing_address_collection":"auto",
  "cancel_url":"https://stripe.com",
  "client_reference_id":null,
  "client_secret":null,
  "consent":null,
  "consent_collection":{
    "payment_method_reuse_agreement":null,
    "promotions":"none",
    "terms_of_service":"none"
  },
  "created":1713333156,
  "currency":"usd",
  "currency_conversion":null,
  "custom_fields":[
  ],
#

  "custom_text":{
    "after_submit":null,
    "shipping_address":null,
    "submit":null,
    "terms_of_service_acceptance":null
  },
  "customer":null,
  "customer_creation":"if_required",
  "customer_details":{
    "address":{
      "city":null,
      "country":"TW",
      "line1":null,
      "line2":null,
      "postal_code":null,
      "state":null
    },
    "email":"<user-email>",
    "name":"<user-name>",
    "phone":null,
    "tax_exempt":"none",
    "tax_ids":[
      
    ]
  },
  "customer_email":null,
  "expires_at":1713419555,
  "id":"cs_test_...",
  "invoice":null,
  "invoice_creation":{
    "enabled":false,
    "invoice_data":{
      "account_tax_ids":null,
      "custom_fields":null,
      "description":null,
      "footer":null,
      "issuer":null,
      "metadata":{
        
      },
      "rendering_options":null
    }
  },
  "livemode":false,
  "locale":"auto",
  "metadata":{
    
  },
  "mode":"payment",
  "object":"checkout.session",
  "payment_intent":"pi_...",
  "payment_link":"plink_...",
  "payment_method_collection":"always",
  "payment_method_configuration_details":{
    "id":"pmc_...",
    "parent":null
  },
  "payment_method_options":{
    "card":{
      "request_three_d_secure":"automatic"
    }
  },
  "payment_method_types":[
    "card",
    "klarna",
    "link",
    "cashapp"
  ],
  "payment_status":"paid",
  "phone_number_collection":{
    "enabled":false
  },
  "recovered_from":null,
  "setup_intent":null,
  "shipping_address_collection":null,
  "shipping_cost":null,
  "shipping_details":null,
  "shipping_options":[
    
  ],
  "status":"complete",
  "submit_type":"auto",
  "subscription":null,
  "success_url":"https://stripe.com",
  "total_details":{
    "amount_discount":0,
    "amount_shipping":0,
    "amount_tax":0
  },
  "ui_mode":"hosted",
  "url":null
}
dry flare
#

Could you share the event id evt_xxx of checkout.session.completed?

zealous lodge
#

yes evt_1P6RQTLz2IywdOP2vbNEejbE

dry flare
#

Okie so this comes from a Payment Link

#

Could you expand the payment_link property?

zealous lodge
#

It's s string id. I get the payment link object with retrieve payment id API and the result is

{
  id: 'plink_1P6PkyLz2IywdOP2Rl66aGIN',
  object: 'payment_link',
  active: true,
  after_completion: {
    hosted_confirmation: { custom_message: null },
    type: 'hosted_confirmation'
  },
  allow_promotion_codes: false,
  application: null,
  application_fee_amount: null,
  application_fee_percent: null,
  automatic_tax: { enabled: false, liability: null },
  billing_address_collection: 'auto',
  consent_collection: {
    payment_method_reuse_agreement: null,
    promotions: 'none',
    terms_of_service: 'none'
  },
  currency: 'usd',
  custom_fields: [],
  custom_text: {
    after_submit: null,
    shipping_address: null,
    submit: null,
    terms_of_service_acceptance: null
  },
  customer_creation: 'if_required',
  inactive_message: null,
  invoice_creation: {
    enabled: false,
    invoice_data: {
      account_tax_ids: null,
      custom_fields: null,
      description: null,
      footer: null,
      issuer: null,
      metadata: {},
      rendering_options: null
    }
  },
  livemode: false,
  metadata: {},
  on_behalf_of: null,
  payment_intent_data: null,
  payment_method_collection: 'always',
  payment_method_types: null,
  phone_number_collection: { enabled: false },
  restrictions: null,
  shipping_address_collection: null,
  shipping_options: [],
  submit_type: 'auto',
  subscription_data: null,
  tax_id_collection: { enabled: false },
  transfer_data: null,
  url: '<test-url>'
}
dry flare
zealous lodge
#

@dry flare I can get the line items along with price property and product id. Thanks, looks like this is the way to do it. THank you very much for the help