#KarlS-dotnet-paymentintent

1 messages ยท Page 1 of 1 (latest)

worn berry
marble pivot
#

code here or into pastebin?

worn berry
#

here is fine!

#

don't leak your API key

marble pivot
#

did that once checking in code to github... that was costly

#

var service = new PaymentIntentService();
bool fetch = true;
while (fetch)
{
fetch = false;
var payments = service.List(options);

foreach(var pay in payments)
{
    Model.PaymentResponse obj;
    response.Add(obj = new Model.PaymentResponse()
    {
        ID = pay.Id,
        Status = pay.Status,
        Created = pay.Created,
        Description = pay.Description,
        Email = pay.ReceiptEmail,
        Amount = pay.Amount / 100
    });
}

fetch = payments.HasMore;
if (payments.HasMore)
    options.StartingAfter = payments.Last().Id;

}
return response;

worn berry
#

hum that should paginate fine but I'm not sure what your response.Add does and how you turn that into a CSV

#

my advice is: log all payments ids to a file first and then check if what you have in the Dashboard is/isn't in the list?

marble pivot
#

var response = new List<Model.PaymentResponse>();

#

that is my own Model.

#

which I pass back to my calling code

#

which I run an insert into my DB

#

foreach (var pay in payment.List(lasttxn))
{
xobj.SetQuery("stripepaymentintent_insert");
xobj.SetParameter("pay_id", pay.ID);
xobj.SetParameter("pay_status", pay.Status);
xobj.SetParameter("pay_date", pay.Created);
xobj.SetParameter("pay_description", pay.Description);
xobj.SetParameter("pay_email", pay.Email);
xobj.SetParameter("pay_amount", pay.Amount);
xobj.SetParameter("create_date", DateTime.Now);

                xobj.Query();
            }
#

the id I should be dealing with is a pi_ id correct?

#

I'm wondering if my Linq last() is screwing me up. Gonna try something different there.

worn berry
#

yeah that's why I recommend adding a log line inside the foreach to compare

#

but if you move to auto-pagination your life would be easier!

marble pivot
#

I will. Gonna test this as-is for now.

#

I'm getting kicked out after 352 payments

worn berry
#

do you handle errors?

marble pivot
#

I do. I'm in code testing... but let me see if I missed catching any.

#

I use the term lightly ๐Ÿ™‚

#

no errrors. could something be logged to the dev dashboard? have I exceeded a rate limit?

worn berry
#

you can't exceed rate limits with sequential reads

#

sorry I can't really help without actionable information. Nothing "kicks you out" in our API without an error message

marble pivot
#

are we talking apples and oranges?

#

I'm downloading all payments from the UI and getting over 2,000 records. In code, I'm using the PaymentIntenService and Itterating over each payment from the List function and then checking and continuing when HasMore is true.

#

I'm setting my Starting after property like this:

            fetch = payments.HasMore;
            if (fetch)
                options.StartingAfter = lastpay.Id;
#

lastpay looks like this (I've removed the Linq call)

#

PaymentIntent lastpay = null;
foreach(var pay in payments)
{
lastpay = pay;

#

I have to go... but I look forward to your response.

worn berry
#

But I gave you multiple ideas of what to try. Auto-pagination is one, logging all payment intent ids in your code explicitly is a second one, and then comparing what you see in your export and diffing the list to find an example PI that was in the export and not your code export to understand the difference

#

I don't really have a better answer yet as it's mostly the same information as when we started, this is how you should debug this further

barren halo
#

Hi @marble pivot I am trying to catchup. Can you update here again how did it go?

marble pivot
#

Yes, thanks. I'm basing my failure on the fact that in the Strip User Dashboard, under payments, when I export I have more than 2,000 entries.

#

When I use the library PaymentIntentService and I try to capture ALL entries I only retrieve 352.

#

First I was using my own paging mechanism, using StartingAfter and my own While loop (C# code) and now have tried a foreach with ListAutoPaging and I am getting the exact same result, 352 entries.

#

Maybe I'm barking up the wrong tree?

barren halo
#

I believe you are in correct direction. In your code with AutoPaging, are you doing something similar to this?

var service = new CustomerService();
var options = new CustomerListOptions {
  Limit = 3
};

// Synchronously paginate
foreach (var customer in service.ListAutoPaging(options)) {
  // Do something with customer
}

// Asynchronously paginate
await foreach (var customer in service.ListAutoPagingAsync(options)) {
  // Do something with customer
}

(It's from our API reference doc)

marble pivot
#

I'm not using the CustomerService API at all.

#

Unless you just copied that here as a similar example

barren halo
#

Yes I know, it's just an example

#

"similar example" yes

marble pivot
#

ok, yep, doing exactly that.

barren halo
#

okie that's weird. Do you have the request Id (from your Dashboard log)?

marble pivot
#

Yes, 1 sec.

#

req_Po1d2qZIqTGTW5

deft prairie
#

Also when you mentioned

I'm downloading all payments from the UI and getting over 2,000 records.
How did you download the payments? and do you have example payment that was not returned in your request?

marble pivot
#

Yes, WSW, I'm using the Export options under the Payments tab.

#

So every Payment (intent) including Successes and Failures.

#

(and whatever other status is pulled down)

deft prairie
#

yup, I mean have you compared the two list 2000 records <> 352 and see which ones are missing?

#

Those will be useful too to troubleshoot

marble pivot
#

Well, sure but I was thinking that since the difference in count is so large that there was a more obvious reason for the discrpency.

#

Which ID should I be looking for exactly?

#

My CSV download include ch_, cus_, and card_ ID types.

deft prairie
#

o, you only care payment_intent right?

#

ch_, cus_ and card_

#

shouldn't matter

#

because what your code are doing is to pull payments

#

i think that's the reason

marble pivot
#

Yes, payment_intent. I need a complete accounting of every success and failure payments to use in my system.

deft prairie
#

you've downloaded a bunch of unrelated objects

#

cus_, card_ are not payment

#

only pi_ matters

#

you should filter your csv and only count pi_xxxx

marble pivot
#

Oh, well that is what is available in the UI.

#

let me see

#

on the Payments download in the Stripe Dashboard, can I specify to download the pi_ data?

#

with a filter I mean? (looking now)

deft prairie
#

which dashboard page are you downloading things now?

marble pivot
#

Stripe Payments

#

I see I can add PagmentIntent ID to my results

deft prairie
#

yeah, can you copy/paste the link

#

?

marble pivot
deft prairie
#

How did you export the list?

#

that's the payment page, should only contain payment

marble pivot
#

Right, but that is was I need (in code and in my system) a complete accounting of every transaction (success or fail)

deft prairie
#

correct, that's the page you should use to export

#

and you should only care about the record with pi_xxxx

#

because that's the payment records

marble pivot
#

Ah! I added PaymentIntent column to my results and now I am seeing that not every row actually has a pi_ number

#

Gotcha. But @deft prairie I also need the Failed transaction attemps. I them in here and indeed, they do not have a pi_xxxx number

deft prairie
#

pi_xxx will contain status, status will tell you if they are successful

#

only succeeded ones are completed payment

marble pivot
#

I understand but I need a list of both succeeded and failed attempts. I need to download the failed attempts. Is this available in the API?

deft prairie
#

no

#

you have to list all the success and failed one, then filter and group them yourself

marble pivot
#

Wait. I'm confused. 1) I'm not seeing any Failed attemps when i use the .NET API to retrieve ALL PaymentIntents, only successful ones. and 2) I'm not clear if there is another approach, withing the API to fetch the FAILED attemps.

deft prairie
#

Are you sure you only get the successful one?

marble pivot
#

Yes, with the built in options, yes. Is there an option to expand my filter? Maybe be default in only produces succesful results?

#

In the API, tested now several times with 2 different approaches is 352.

deft prairie
#

ok, for this req_Po1d2qZIqTGTW5 you just shared
you are pulling payment_intent using this parameter

{
  limit: "100",
  starting_after: "pi_1JA4BtG30Vl6ne6NyuBHeL3p"
}

this pi_1JA4BtG30Vl6ne6NyuBHeL3p status is cancelled

#

it is not a successful payment

marble pivot
#

So you are saying that is not a good staring_after object?

deft prairie
#

what I am saying is that, listing payment_intent API will return all the payments including successful and failed one

#

this pi_1JA4BtG30Vl6ne6NyuBHeL3p is an example of failed one (due to cancellation)

marble pivot
#

Here is the 1st request in my attempt at using ListAutoPaging: req_LDjFPknJ5lAucg

#

These are the next 3: req_WQlTWtoyNxcx4W, req_CHEzNtQYeZWAUq, req_O2kEiz3e2xCYN7

#

Right, but what I am saying is, my request for the PaymentIntents is not retrieving the complete set of PaymentIntents.

deft prairie
#

I thought we cleared that up because the way export the the payment_intent?

#

cus_, ch_xxx and card_ are not payment_intent and you should not compare them

marble pivot
#

I'm not using the export in my solution, that is just a proof of concept. I am going after the data programatically.

deft prairie
#

ok, then how can you tell you are missing data then?

marble pivot
#

Ahh... I have a know customer who paid, their credit card was declined and I can't find their failed/declined PaymentIntent record.

deft prairie
#

do you have your customer email or ID?

marble pivot
#

yes. 1 sec.

#

(is this chat here public?)

deft prairie
#

yes. you can dm me

marble pivot
#

done

deft prairie
#

Ok, with the email, it is much easier

#
  1. non-coding way, you can go to your dashboard, and search the email address xxxxx@xxxx.com
marble pivot
#

yes

deft prairie
#

it will show all the customer created using the email

#

filter by email xxxxx

#

you can find all the customers

marble pivot
#

I'm doing that already

deft prairie
#

then click into them and find all the payment done

marble pivot
#

Filters Status Failed.

deft prairie
#

there is no status

marble pivot
#

Perfect. Now how do I do this in code?

deft prairie
#

same thing

#

first

  1. find all the customers
marble pivot
#

There is Status on the Payments dashboard.

deft prairie
#

with email

marble pivot
#

So, for every customer, for every payment intent?

#

I can do that, but before I do that, are you saying that I can't get a list of failed payments using the API?

#

Your UI allows for it

deft prairie
#

no, you will get everything

#

succeeded and failed

marble pivot
#

but that is exactly what I want.

#

but my result does not include failed.

deft prairie
#

which one does not contain failed one?

marble pivot
#

This code here, it only return Succeeded and Canceled, no Faield.

        var service = new PaymentIntentService();
        foreach (var pay in service.ListAutoPaging(options))
        {
deft prairie
#

can you share the list of returned results?

#

this pi_1JA4BtG30Vl6ne6NyuBHeL3p was returned result and it failed

marble pivot
#

Status is cancelled. I will DM you.

deft prairie
#

its ok to discuss here, can you first try to implement by the customer

#

it will limit the returned list

#

since you want to check per customer

marble pivot
#

Wait.. I have an example of a failed payment intent but this failed payment intent is not showing up in the list of all PaymentIntetents I download. I not not want to loop through every customer. Why isn't this failed payment intent showing up in this list of all payment intents?

#

Can you reverse lookup the payment intent for the email I sent?

#

WAIT.. should I be looking at charges, success and failures instead?

deft prairie
#

Charge API will work too

marble pivot
#

Well, Payment API isn't working! Almost done with test code.

#

ok, have some to test.

#

ch_1IKNuUG30Vl6ne6Nb5Slc6FZ succeeded
ch_1IKAc0G30Vl6ne6NbKP4Qd3z succeeded
ch_1IK92dG30Vl6ne6NsEzCbwW9 succeeded
ch_1IK7UgG30Vl6ne6Nx8mLNYmq succeeded
ch_1IK23TG30Vl6ne6Ne5VqAnOP succeeded
ch_1IJqtlG30Vl6ne6NxISnl8gT failed
ch_1IJqr3G30Vl6ne6NWM9V103j failed
ch_1IJmLPG30Vl6ne6Nb1ZO0uSR failed

#

and I can retreive the balance transaction id, which is what I really really need.

#

ch_3JaQ7rG30Vl6ne6N0Ldo62ZP txn_3JaQ7rG30Vl6ne6N01BE7H01 succeeded

#

Hey @deft prairie I think I am all set! Thank you for all of this help. Goodnight. Bedtime here.