private async Task ShouldQueryDisputes() { var from = DateTime.UtcNow.Subtract(TimeSpan.FromHours(24)); var to = DateTime.Now; // local timezone var request = new DisputesQueryFilter { Limit = 250, To = to, From = from }; var response = await PreviousApi.DisputesClient().Query(request); response.ShouldNotBeNull(); response.Limit.ShouldBe(250); response.Skip.ShouldNotBeNull(); response.TotalCount.ShouldNotBeNull(); response.To.ShouldNotBeNull(); response.From.ShouldNotBeNull(); if (response.TotalCount > 0) { var dispute = response.Data[0]; var disputeDetails = await PreviousApi.DisputesClient().GetDisputeDetails(dispute.Id); disputeDetails.ShouldNotBeNull(); disputeDetails.Id.ShouldBe(dispute.Id); disputeDetails.Category.ShouldBe(dispute.Category); disputeDetails.Status.ShouldBe(dispute.Status); disputeDetails.Amount.ShouldBe(dispute.Amount); disputeDetails.ReasonCode.ShouldBe(dispute.ReasonCode); disputeDetails.Payment.ShouldNotBeNull(); disputeDetails.Payment.Id.ShouldBe(dispute.PaymentId); } }
private async Task ShouldTestFullDisputesWorkflow() { //Make the payment var payment = await MakeCardPayment(true, 1040L); payment.ShouldNotBeNull(); var query = new DisputesQueryFilter { PaymentId = payment.Id }; //Query for dispute DisputesQueryResponse queryResponse = await Retriable(async() => await PreviousApi.DisputesClient().Query(query), HasItems); queryResponse.ShouldNotBeNull(); queryResponse.Data[0].PaymentId.ShouldBe(payment.Id); //Upload dispute evidence const string filePath = "./Resources/checkout.jpeg"; var fileResponse = await PreviousApi.DisputesClient().SubmitFile(filePath, "dispute_evidence"); //Provide dispute evidence var disputeEvidenceRequest = new DisputeEvidenceRequest { ProofOfDeliveryOrServiceFile = fileResponse.Id, ProofOfDeliveryOrServiceText = "proof of delivery or service text", InvoiceOrReceiptFile = fileResponse.Id, InvoiceOrReceiptText = "Copy of the invoice", CustomerCommunicationFile = fileResponse.Id, CustomerCommunicationText = "Copy of an email exchange with the cardholder", AdditionalEvidenceFile = fileResponse.Id, AdditionalEvidenceText = "Scanned document" }; var disputeId = queryResponse.Data[0].Id; var emptyResponse = await PreviousApi.DisputesClient().PutEvidence(disputeId, disputeEvidenceRequest); emptyResponse.ShouldNotBeNull(); emptyResponse.HttpStatusCode.ShouldNotBeNull(); emptyResponse.ResponseHeaders.ShouldNotBeNull(); //Verify the dispute evidence var evidence = await PreviousApi.DisputesClient().GetEvidence(disputeId); evidence.ShouldNotBeNull(); evidence.ProofOfDeliveryOrServiceFile.ShouldBe(disputeEvidenceRequest.ProofOfDeliveryOrServiceFile); evidence.ProofOfDeliveryOrServiceText.ShouldBe(disputeEvidenceRequest.ProofOfDeliveryOrServiceText); evidence.InvoiceOrReceiptFile.ShouldBe(disputeEvidenceRequest.InvoiceOrReceiptFile); evidence.InvoiceOrReceiptText.ShouldBe(disputeEvidenceRequest.InvoiceOrReceiptText); evidence.CustomerCommunicationFile.ShouldBe(disputeEvidenceRequest.CustomerCommunicationFile); evidence.CustomerCommunicationText.ShouldBe(disputeEvidenceRequest.CustomerCommunicationText); evidence.AdditionalEvidenceFile.ShouldBe(disputeEvidenceRequest.AdditionalEvidenceFile); evidence.AdditionalEvidenceText.ShouldBe(disputeEvidenceRequest.AdditionalEvidenceText); //Submit the dispute await PreviousApi.DisputesClient().SubmitEvidence(disputeId); }