#.antoniot
1 messages · Page 1 of 1 (latest)
Invoices create PaymentIntents, so the way to do this would be to create the invoice on the connected account
ok im using that but in golang sdk v74 theres no place to add the amount to charge
also when I expand a payment intent it doesnt provide the payment intent ID
invoiceCreateParams := &stripe.InvoiceParams{
AutoAdvance: stripe.Bool(false),
ApplicationFeeAmount: stripe.Int64(int64(scenefileCommunity.Price * 100 * 0.15)),
Customer: stripe.String(customerID),
Currency: stripe.String(string(stripe.CurrencyUSD)),
DefaultPaymentMethod: stripe.String(paymentMethodID),
}
invoiceCreateParams.AddExpand("payment_intent")
invoiceCreateParams.AddMetadata("uuid_user", uuidUser)
invoiceCreateParams.AddMetadata("uuid_community_profile", scenefileCommunity.UUIDProfileCommunity)
invoiceCreateParams.AddMetadata("uuid_file_community", scenefileCommunity.UUIDFileCommunity)
invoiceCreateParams.AddMetadata("type", "marketplace")
invoiceCreateParams.SetStripeAccount(stripeConnect.AccountStripeID)
inv, err := invoice.New(invoiceCreateParams)
InvoiceParams on that struct there is no amount to debit or something like that
When you create an invoice like that, it will be in a draft state, you will need to finalize the invoice for it to create a PaymentIntent
That doc demonstrates how to create and finalize an invoice
oh so after the invoice creation i have to finalize
Correct
ok im doint this now but the invoice is on incomplete status
invoiceCreateParams := &stripe.InvoiceParams{
AutoAdvance: stripe.Bool(false),
ApplicationFeeAmount: stripe.Int64(int64(scenefileCommunity.Price * 100 * 0.15)),
Customer: stripe.String(customerID),
Currency: stripe.String(string(stripe.CurrencyUSD)),
DefaultPaymentMethod: stripe.String(paymentMethodID),
}
invoiceCreateParams.AddExpand("payment_intent")
invoiceCreateParams.AddMetadata("uuid_user", uuidUser)
invoiceCreateParams.AddMetadata("uuid_community_profile", scenefileCommunity.UUIDProfileCommunity)
invoiceCreateParams.AddMetadata("uuid_file_community", scenefileCommunity.UUIDFileCommunity)
invoiceCreateParams.AddMetadata("type", "marketplace")
invoiceCreateParams.SetStripeAccount(stripeConnect.AccountStripeID)
inv, _ := invoice.New(invoiceCreateParams)
itemParams := &stripe.InvoiceItemParams{
Customer: stripe.String(customerID),
Invoice: stripe.String(inv.ID),
Amount: stripe.Int64(int64(scenefileCommunity.Price) * 100),
}
itemParams.SetStripeAccount(stripeConnect.AccountStripeID)
invoiceitem.New(itemParams)
invFinalizeParams := &stripe.InvoiceFinalizeInvoiceParams{
AutoAdvance: stripe.Bool(true),
}
invFinalizeParams.SetStripeAccount(stripeConnect.AccountStripeID)
result, _ := invoice.FinalizeInvoice(inv.ID, invFinalizeParams)
do I have to do something with payment intent confirm?
If auto_advance is enabled on that invoice, you can wait for the first payment attempt to happen
Whether it is on or not, you can manually make a payment attempt by calling https://stripe.com/docs/api/invoices/pay
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
is there a way to get the invoice/receipt hosted url after the pay thing?
Yep, should be available on the invoice after it is finalized https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.