#amfpaulo_invoices-payment-intent-terminal

1 messages ยท Page 1 of 1 (latest)

earnest depotBOT
#

๐Ÿ‘‹ 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/1358832434959089850

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

marsh shadow
#

Everything seems to work, the only problem its the last step, using the collected intent to pay for the invoice

swift lake
#

Hi ๐Ÿ‘‹

What do you mean by "manually" pay an Invoice? If you have generated an invoice and you wish to pay it with a saved payment method, you can use the Pay API

marsh shadow
#

I generate a payment intent, I create a invoice and I want to use thie payment to pay for the invoice

#

I informed the request id

#

look, please do not give me generic answers, everything works so far, I am trying to do is almost working, plese read everything a added to the question

#

this is the charge I tried to use to pay for the invoice: ch_3RBHo1Dn6CAQGXZn2K5zP4K3

#

this is the request:
req_zz3BJ17te7S6vh ๐Ÿ‘ˆ

swift lake
#

I generate a payment intent, I create a invoice and I want to use thie payment to pay for the invoice

THis is already wrong

#

If you create a Payment Intent separately from the Invoice, payment for that Intent has no relation to the Invoice at all

marsh shadow
#

Ok, so what is the correct way to generate a payment intent for a invoice that can be paid

swift lake
#

Create the Invoice first

#

This will generate a Payment Intent that is linked to that Invoice

#

Confirm that Payment Intent and the Invoice will be paid

marsh shadow
#

I need to return to the client paymentIntentId and ClientSecret so the payment can be collected, where are those Fields on the invoice Object ?

#

Also, I am going to be able to collect the payment if client pays using apple pay, I thing I remember this being a limitation if payment intent was generated by a invoice

#

when I create a invoice , invoice.PaymentIntent is null

#

so I cant access the Secret

swift lake
#

Then you are creating the Invoice incorrectly. Can you share the request where you create the Invoice?

marsh shadow
#

yes. just a second

#

var options = new InvoiceCreateOptions
{
Customer = customerId,
CollectionMethod = collectionMethod,
DaysUntilDue = 1,
Metadata = new Dictionary<string, string> {
{ "origin", "payjj" },
{ "comission", string.Join(',', request.SalesPersonIds) },
{ "discount", request.Discount.ToString() },
{ "intent", paymentIntent.Id },
{ "wallet", paymentMethodType },
},
AutomaticTax = new InvoiceAutomaticTaxOptions { Enabled = true },
AutoAdvance = false,
};

        var invoiceService = new InvoiceService();
        var invoice = invoiceService.Create(options);
#

this works with "charge_automatically" payment, using client card on file

swift lake
#

Please provide the request ID

#

Using charge_automatically will charge the customer's card on file but the Payment Intent you added will never be confirmed

marsh shadow
#

just a second

#

req_TvZbksT2rbki5C

#

this is the invoice request

swift lake
#

Thanks, taking a look

marsh shadow
#

thank you

swift lake
#

This request sets auto_advance to false

#

The Invoice is created in this request but there is no Payment Intent because it is not finalized yet. It's still in draft status.

#

You finalize the Invoice here and now there is a Payment Intent pi_3RBINlDn6CAQGXZn13p4P0Vn

#

That Payment Intent is what you use to Pay the Invoice in our normal flow

marsh shadow
#

I am finilizing the invoice, you can see on my code

#

sorry i did no sent this part

#

invoiceService.FinalizeInvoice(invoice.Id, new InvoiceFinalizeOptions { AutoAdvance = false });

#

Is the reason the AutoAdvance = false, that its not creating the Intent ?

#

I can see the intent on the dashboard , so its creating, may be a i need to expand something ? or query the invoice again, I am doing the correct process

swift lake
#

You are creating the Payment Intent when you finalize the Invoice. If you want to access the Client Secret, you need to expand the Payment Intent when you make the Finalize request

#

Then you can use that client secret with the Payment Element to collect payment method information

marsh shadow
#

It makes sense, what is the expand string? "payment_intent" by the way is there any doc I can see possible expand options for each type of transaction ?

#

I did this, no error, paymentIntent still null:

        invoiceService.FinalizeInvoice(invoice.Id, new InvoiceFinalizeOptions
        {
            Expand = new List<string> { "payment_intent" },
            AutoAdvance = false
        });

#

I might be need to Get the invoice ?

swift lake
#

You can see the expandable properties on our API reference docs, like for the Invoice. Each expandable property will have the Expandable badge next to it

marsh shadow
#

ya, I noticed the badges now

#

anyways, I truied to finalize using expand, but did not work

#

Ok, I found my mistake

#

I was looking the wrong var, now using expand I get the intent. My last question is. Can the client pay for the invoice (payment intent ) using Apple Pay ?

swift lake
#

Sure

#

As long as your Payment Element is configured to accept Apple Pay

marsh shadow
#

Its M2 Terminal

#

that is the problem, everytime a seek support M2 is completely ignored

#

documentation is also poor

swift lake
#

In that case, it's the same as using a Payment Intent

marsh shadow
#

I did other integration with out coming here for any questions, everything was in the dos, but M2 everything works diff and no docs

#

ok cool

swift lake
#

Oh wait. no

#

This won't work. You cannot use card_present as a payment method type with Invoices

marsh shadow
#

I was happy too soon

#

ok, Ya, I remeber this

#

idk why stripe limits M2 like that,

#

Anyways, I have a solution, just tell me if my strategy will work....

#

If I collect a payment, in this case could possibly be apple pay, no invoice involved, just a payment intent created, validated, collected.

#

If I pay the invoice like that

await invoiceService.PayAsync(invoice.Id, new InvoicePayOptions { PaidOutOfBand = true });

#

invoice will be marked as paid right ?

#

I'll add the charge Id on the metadata just to keep track of it, and also control this on my database side

swift lake
#

Correct. If you want to generate Invoices for these payments I think that is your best option.

marsh shadow
#

ok cool,

#

thank you

#

I think I am all set, can you add a comment for Stripe to in the future Allow M2 to collect payments to pay for invoices ?

#

I do not understand the logic on this

swift lake
#

I can flag that internally

#

Okay I have filed that feedback.