#Crawl

1 messages ยท Page 1 of 1 (latest)

crimson mirageBOT
dapper pecan
#

Hello ๐Ÿ‘‹
Do you have an example handy? I can take a look

halcyon plume
# dapper pecan Hello ๐Ÿ‘‹ Do you have an example handy? I can take a look

Hello

Here's the webhook object I'm receiving when a payment intent is successfull (test data)

I want to know for wich subscription this payment has been done

  id: 'pi_3N8PRELM4GHVXwuA1Q5HGQHS',
  object: 'payment_intent',
  amount: 3000,
  amount_capturable: 0,
  amount_details: { tip: {} },
  amount_received: 3000,
  application: null,
  application_fee_amount: null,
  automatic_payment_methods: null,
  canceled_at: null,
  cancellation_reason: null,
  capture_method: 'automatic',
  client_secret: '.......',
  confirmation_method: 'automatic',
  created: 1684249520,
  currency: 'usd',
  customer: 'cus_NuDsXCScZJgMFT',
  description: 'Subscription creation',
  invoice: 'in_1N8PRDLM4GHVXwuAtSvCATl3',
  last_payment_error: null,
  latest_charge: 'ch_3N8PRELM4GHVXwuA1DIefl58',
  livemode: false,
  metadata: {},
  next_action: null,
  on_behalf_of: null,
  payment_method: 'pm_1N8PRDLM4GHVXwuA0kk2E4Zp',
  payment_method_options: {
    acss_debit: { mandate_options: [Object], verification_method: 'automatic' },
    card: {
      installments: null,
      mandate_options: null,
      network: null,
      request_three_d_secure: 'automatic',
      setup_future_usage: 'off_session'
    }
  },
  payment_method_types: [ 'acss_debit', 'card' ],
  processing: null,
  receipt_email: null,
  review: null,
  setup_future_usage: 'off_session',
  shipping: null,
  source: null,
  statement_descriptor: null,
  statement_descriptor_suffix: null,
  status: 'succeeded',
  transfer_data: null,
  transfer_group: null
}
PaymentIntent for 3000 was successful!
c```
dapper pecan
#

Gotcha. So if you look at the invoice parameter here
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice

It is expandable so once you expand it, you should be able to see the complete invoice object. The invoice object should have a subscription param with its ID
https://stripe.com/docs/api/invoices/object#invoice_object-subscription

halcyon plume
#

Like this for exemple :


    stripe.invoices.retrieve(invoiceId, function(error, invoice) {
      if (error) {
        console.log(error);
      } else {
        var subscriptionId = invoice.subscription;
        console.log("Subscription ID: " + subscriptionId);
      }
    });```
dapper pecan
#

You'd need to make another call, yes.

#

yeah your code should work too ๐Ÿ™‚

halcyon plume
#

awesome thanks