#mattsulima

1 messages ยท Page 1 of 1 (latest)

weary talonBOT
little nacelle
#

๐Ÿ‘‹ happy to help

#

are you adding the metadata on the payment link?

split hinge
#

yup, I am

little nacelle
#

the metadata on the payment link doesn't get copied to the subscription

#

what you can do is to listen to both checkout.session.complete and the invoice.paid events

#

but session doens't have paymentintent id so I am unable to load charge
yes the PaymentIntent would be on the invoice object

split hinge
#

then how to load the charge and the metadata to save the info user has subscribed to product?

#

I need:

  • user opens payment link, fills details, clicks subscribe
  • I receive an event (webhook), I can load metadata and charge, so I can store al lpayment details (amount, fee ect) into product's payment history
little nacelle
#

Payment Links are meant to be used as a "Campaign"-like link when you don't really know the customer

#

so the metadata on the PaymentLink should not reflect who that customer is

split hinge
#

Erm then how to achieve what I need?

#

I need to generate url and send to user to pay. When user pays we load info what's the product ect (from metadata) and store all info into payment history

little nacelle
#

what is the metadata you're looking to collect?

#

in a checkout session you can choose which products/prices you want the customer to pay

split hinge
#

For single payment it works, webhook event (CheckoutSessionCompleted) has all data I need

little nacelle
#

in your case the subscription

#

but I don't understand what is the metadata that you need if you already have the prices in the subscription/invoices

#

would you mind sharing a payment link ID or something where you used metadata so I could get an idea of what you're trying to achieve

#

this would help me better advise you

split hinge
#

Link has ContractId metadata I need- each customer can have one or many contracts

#

So I want to get webhook event - metadata (ContractId = C74768), user paid 75 GBP (from charge and balance transaction)

little nacelle
#

the contract ID is something related to the customer? or related to the subscription/price?

split hinge
#

Well, we offer renting parking spaces. So ContractId is a single agreement with us to rent a parking space. So I'd say ContractId is related to product

#

One customer can have one or many contracts

little nacelle
#

so to get it right one product (price) can only have 1 contract ID?

split hinge
#

One product, yeah can have only one contract id. But one product can have few prices

little nacelle
#

in that case you can add the metadata directly to the product

#

and retrieve the metadata from the subscription's price.product.metadata

split hinge
#

Thanks, yeah that could work

#

Weird it's not possible to load payment link's metadata or other details

little nacelle
#

it's more complicated, achievable but more complicated and imo not the right approach

#

since this is not related to the payment link but rather an info of the product itself

split hinge
#

yeah, we track product's payment history so it can be in product's metadat (actually it is, I simply don't load it ๐Ÿ˜‰ )

#

Okay, I think I know how to use it then, thanks!

#

I have also a question about one of your messages

little nacelle
#

yes sure

split hinge
little nacelle
#

it depends on the use case

split hinge
#

Like I said, I need a solution where:

  • customer created contract, agrees with the details
  • I generate payment link and send to customer to pay
  • customer pays, my webhooks listen for events and logs it's paid
  • contract is activated
#

In theory anyone can pay using this link, we don't care, we care if it's paid and we can charge every month ๐Ÿ™‚

little nacelle
#

I generate payment link and send to customer to pay
you can create a checkout session

little nacelle
#

as far as I understood, a contract can be only assigned to one customer at a time

split hinge
#

yeah, other user means other contract

little nacelle
#

this is why in your case payment links is not really what you're looking for

split hinge
#

Okay, i'll look and try searching how to use checkout sessionthen

little nacelle
#

it's pretty much the same the only difference between payment links and checkout sessions is that checkout sessions have an expiry of 24hrs by default

#

whereas payment links would generate a new checkout session each time the link is visited

split hinge
#

Oh I think I know why I didn't use it... it requires success and error urls to be passed, we don't need it

little nacelle
#

ok

split hinge
#

Okay, I think I know all I need to know, thank you!

little nacelle
#

let me know if you need any more help