#mattsulima
1 messages ยท Page 1 of 1 (latest)
yup, I am
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
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
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
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
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
For single payment it works, webhook event (CheckoutSessionCompleted) has all data I need
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
ParkLet contract C74768
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)
the contract ID is something related to the customer? or related to the subscription/price?
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
so to get it right one product (price) can only have 1 contract ID?
One product, yeah can have only one contract id. But one product can have few prices
in that case you can add the metadata directly to the product
and retrieve the metadata from the subscription's price.product.metadata
Thanks, yeah that could work
Weird it's not possible to load payment link's metadata or other details
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
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
yes sure
this seems worrying, I feel like I shouldn't use payment links in my case?
it depends on the use case
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 ๐
I generate payment link and send to customer to pay
you can create a checkout session
this is usually used when multiple customers can buy the same product
as far as I understood, a contract can be only assigned to one customer at a time
yeah, other user means other contract
this is why in your case payment links is not really what you're looking for
Okay, i'll look and try searching how to use checkout sessionthen
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
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
ok
Okay, I think I know all I need to know, thank you!
let me know if you need any more help