public void TestCancelInvoice() { ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Initiated.json"); var invoice = Invoice.Fetch("some-random-id"); ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Canceled.json"); invoice.Cancel(); Assert.Equal(7000, invoice.Amount); Assert.Equal("canceled", invoice.Status); }
public void TestUpdateInvoice() { ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Initiated.json"); var invoice = Invoice.Fetch("f91065f7-d188-4ec8-8fc5-af97841ec14e"); ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Updated.json"); invoice.Update(); Assert.Equal(8000, invoice.Amount); Assert.Equal("USD", invoice.Currency); Assert.Equal("An 80 USD invoice just because", invoice.Description); }
public void TestCreateInvoice() { ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Initiated.json"); var invoice = Invoice.Create(GetValidInvoiceInfo()); Assert.IsType <Invoice>(invoice); Assert.Equal(7000, invoice.Amount); Assert.Equal("SAR", invoice.Currency); Assert.Equal("A 70 SAR invoice just because", invoice.Description); Assert.Equal(DateTime.Parse("2016-04-07T06:45:18.866Z").ToUniversalTime(), invoice.ExpiredAt); Assert.Equal("http://www.example.com/invoice_callback", invoice.CallbackUrl); }
public void TestPaymentListing() { ServiceMockHelper.MockJsonResponse("Fixtures/PaymentList.json"); var pagination = Payment.List(); Assert.IsType <CreditCard>(pagination.Items[0].Source); Assert.IsType <ApplePayMethod>(pagination.Items[1].Source); Assert.IsType <StcPayMethod>(pagination.Items[2].Source); Assert.Equal(2, pagination.CurrentPage); Assert.Equal(3, pagination.NextPage); Assert.Equal(1, pagination.PreviousPage); Assert.Equal(3, pagination.TotalPages); Assert.Equal(9, pagination.TotalCount); }
public async void RefundHigherAmountMustThrowException() { ServiceMockHelper.MockJsonResponse("Fixtures/CreditCard/Paid.json"); var payment = Payment.Fetch("b6c01c90-a091-45a4-9358-71668ecbf7ea"); var id = payment.Id; var amount = payment.Amount; ServiceMockHelper.MockJsonResponse("Fixtures/CreditCard/Refunded.json"); await Assert.ThrowsAsync <ValidationException> ( async() => await Task.Run(() => payment.Refund(amount + 1)) ); }
public void TestRefundPayment() { ServiceMockHelper.MockJsonResponse("Fixtures/CreditCard/Paid.json"); var payment = Payment.Fetch("b6c01c90-a091-45a4-9358-71668ecbf7ea"); var id = payment.Id; var amount = payment.Amount; ServiceMockHelper.MockJsonResponse("Fixtures/CreditCard/Refunded.json"); payment.Refund(); Assert.Equal(id, payment.Id); Assert.Equal("refunded", payment.Status); Assert.Equal(amount, payment.RefundedAmount); Assert.Equal(DateTime.Parse("2019-01-03T10:14:14.414Z").ToUniversalTime(), payment.RefundedAt); }
public void TestInvoiceListing() { ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/List.json"); var pagination = Invoice.List(); Assert.Equal(2, pagination.Items.Count); Assert.Equal(7000, pagination.Items[0].Amount); Assert.Equal("SAR", pagination.Items[0].Currency); Assert.Equal(DateTime.Parse("2016-04-07T06:45:18.866Z").ToUniversalTime(), pagination.Items[0].ExpiredAt); Assert.Equal("9e5c7df4-b796-4c83-9a61-e304c9c8fa51", pagination.Items[0].Metadata["order_id"]); Assert.Equal(2, pagination.CurrentPage); Assert.Equal(3, pagination.NextPage); Assert.Equal(1, pagination.PreviousPage); Assert.Equal(3, pagination.TotalPages); }
public void TestDeserializingStcPayPayment() { ServiceMockHelper.MockJsonResponse("Fixtures/StcPay/Paid.json"); var payment = Payment.Fetch("50559d3b-e67f-4b3a-8df8-509dde19fe38"); Assert.Equal(1000, payment.Amount); Assert.Equal("SAR", payment.Currency); Assert.Equal("Test Payment", payment.Description); Assert.Null(payment.CallbackUrl); Assert.IsType <StcPayMethod>(payment.Source); var method = (StcPayMethod)payment.Source; Assert.Equal("stcpay", method.Type); Assert.Equal("0555555555", method.Mobile); Assert.Equal("Paid", method.Message); }
public void TestDeserializingApplePayPayment() { ServiceMockHelper.MockJsonResponse("Fixtures/ApplePay/Paid.json"); var payment = Payment.Fetch("a4a144ba-adc3-43bd-98e8-c80f2925fdc4"); Assert.Equal(1000, payment.Amount); Assert.Equal("SAR", payment.Currency); Assert.Equal("Test Payment", payment.Description); Assert.Null(payment.CallbackUrl); Assert.IsType <ApplePayMethod>(payment.Source); var applePaySource = (ApplePayMethod)payment.Source; Assert.Equal("applepay", applePaySource.Type); Assert.Equal("XXXX-XXXX-XXXX-1111", applePaySource.Number); Assert.Equal("APPROVED", applePaySource.Message); Assert.Equal("moyasar_ap_je1iUidxhrh74257S891wvW", applePaySource.GatewayId); Assert.Equal("125478454231", applePaySource.ReferenceNumber); }
public void TestFetchInvoice() { ServiceMockHelper.MockJsonResponse("Fixtures/Invoice/Paid.json"); var invoice = Invoice.Fetch("f91065f7-d188-4ec8-8fc5-af97841ec14e"); Assert.Equal("f91065f7-d188-4ec8-8fc5-af97841ec14e", invoice.Id); Assert.Equal(7000, invoice.Amount); Assert.Equal("SAR", invoice.Currency); Assert.Equal("A 70 SAR invoice just because", invoice.Description); Assert.Equal(DateTime.Parse("2021-04-07T06:45:18.866Z").ToUniversalTime(), invoice.ExpiredAt); Assert.Equal("http://www.example.com/invoice_callback", invoice.CallbackUrl); Assert.Equal("de92988a-34bd-43a5-963f-b757cf02de7b", invoice.Metadata["order_id"]); Assert.Single(invoice.Payments); Assert.Equal("a4a144ba-adc3-43bd-98e8-c80f2925fdc4", invoice.Payments[0].Id); Assert.Equal(7000, invoice.Payments[0].Amount); Assert.Equal("SAR", invoice.Payments[0].Currency); Assert.Equal("A 70 SAR invoice just because", invoice.Payments[0].Description); }
public void TestDeserializingPayment() { ServiceMockHelper.MockJsonResponse("Fixtures/CreditCard/Paid.json"); var payment = Payment.Fetch("b6c01c90-a091-45a4-9358-71668ecbf7ea"); Assert.Equal("b6c01c90-a091-45a4-9358-71668ecbf7ea", payment.Id); Assert.Equal(1000, payment.Amount); Assert.Equal("SAR", payment.Currency); Assert.Equal("Test Payment", payment.Description); Assert.Equal("https://mystore.com/order/redirect-back", payment.CallbackUrl); Assert.Equal("5c02ba44-7fd1-444c-b82b-d3993b87d4b0", payment.Metadata["order_id"]); Assert.Equal("50", payment.Metadata["tax"]); Assert.IsType <CreditCard>(payment.Source); var ccSource = (CreditCard)payment.Source; Assert.Equal("Long John", ccSource.Name); Assert.Equal("XXXX-XXXX-XXXX-1111", ccSource.Number); Assert.Equal("moyasar_ap_je1iUidxhrh74257S891wvW", ccSource.GatewayId); Assert.Equal("125478454231", ccSource.ReferenceNumber); }