public void CaptureRefundTest() { try { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorization = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var cap = new Capture(); var amnt = new Amount(); amnt.total = "1"; amnt.currency = "USD"; cap.amount = amnt; var response = authorization.Capture(TestingUtil.GetApiContext(), cap); var fund = new Refund(); var refundAmount = new Amount(); refundAmount.total = "1"; refundAmount.currency = "USD"; fund.amount = refundAmount; var responseRefund = response.Refund(TestingUtil.GetApiContext(), fund); Assert.AreEqual("completed", responseRefund.state); } finally { TestingUtil.RecordConnectionDetails(); } }
public void SaleRefundTest() { try { // Create a credit card sale payment var payment = PaymentTest.CreatePaymentForSale(); // Get the sale resource var sale = payment.transactions[0].related_resources[0].sale; var refund = new Refund { amount = new Amount { currency = "USD", total = "0.01" } }; var response = sale.Refund(TestingUtil.GetApiContext(), refund); Assert.IsNotNull(response); Assert.AreEqual("completed", response.state); } finally { TestingUtil.RecordConnectionDetails(); } }
public void RefundIdTest() { try { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorization = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var cap = new Capture(); var amt = new Amount(); amt.total = "1"; amt.currency = "USD"; cap.amount = amt; var response = authorization.Capture(TestingUtil.GetApiContext(), cap); var fund = new Refund(); var refundAmount = new Amount(); refundAmount.total = "1"; refundAmount.currency = "USD"; fund.amount = refundAmount; var responseRefund = response.Refund(TestingUtil.GetApiContext(), fund); var retrievedRefund = Refund.Get(TestingUtil.GetApiContext(), responseRefund.id); Assert.AreEqual(responseRefund.id, retrievedRefund.id); } catch (ConnectionException ex) { TestingUtil.WriteConnectionExceptionDetails(ex); throw; } }
public void AuthorizationGetTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.NotNull(pay); Assert.NotNull(pay.transactions); Assert.True(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.NotNull(transaction.related_resources); Assert.True(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.NotNull(resource.authorization); var authorizationId = resource.authorization.id; var authorize = Authorization.Get(apiContext, authorizationId); this.RecordConnectionDetails(); Assert.Equal(authorizationId, authorize.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void AuthorizationVoidTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(pay); Assert.IsNotNull(pay.transactions); Assert.IsTrue(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.IsNotNull(transaction.related_resources); Assert.IsTrue(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.IsNotNull(resource.authorization); var authorize = Authorization.Get(apiContext, resource.authorization.id); this.RecordConnectionDetails(); var authorizationResponse = authorize.Void(apiContext); this.RecordConnectionDetails(); Assert.AreEqual("voided", authorizationResponse.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void RefundIdTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(pay); Assert.IsNotNull(pay.transactions); Assert.IsTrue(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.IsNotNull(transaction.related_resources); Assert.IsTrue(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.IsNotNull(resource.authorization); var authorization = Authorization.Get(apiContext, resource.authorization.id); this.RecordConnectionDetails(); var cap = new Capture { amount = new Amount { total = "1", currency = "USD" } }; var response = authorization.Capture(apiContext, cap); this.RecordConnectionDetails(); var fund = new Refund { amount = new Amount { total = "1", currency = "USD" } }; apiContext.ResetRequestId(); var responseRefund = response.Refund(apiContext, fund); this.RecordConnectionDetails(); var retrievedRefund = Refund.Get(apiContext, responseRefund.id); this.RecordConnectionDetails(); Assert.AreEqual(responseRefund.id, retrievedRefund.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void AuthorizationGetTest() { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorize = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); Assert.AreEqual(authorizationId, authorize.id); }
public void AuthorizationVoidTest() { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorize = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var authorizationResponse = authorize.Void(TestingUtil.GetApiContext()); Assert.AreEqual("voided", authorizationResponse.state); }
public static PaymentHistory GetPaymentHistory() { List <Payment> paymentList = new List <Payment>(); paymentList.Add(PaymentTest.GetPaymentForSale()); PaymentHistory history = new PaymentHistory(); history.count = 1; history.payments = paymentList; history.next_id = "1"; return(history); }
/// <summary> /// Tests that use this method must be ignored when run in an automated environment because executing an order /// will require approval via the executed payment's approval_url. /// </summary> /// <returns></returns> private Order GetExecutedPaymentOrder(PayPal.Api.APIContext apiContext) { var pay = PaymentTest.CreatePaymentOrder(apiContext); var paymentExecution = PaymentExecutionTest.GetPaymentExecution(); paymentExecution.payer_id = pay.id; paymentExecution.transactions[0].amount.details = null; var executedPayment = pay.Execute(apiContext, paymentExecution); var orderId = executedPayment.transactions[0].related_resources[0].order.id; return(Order.Get(apiContext, orderId)); }
public void AuthorizationCaptureTest() { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorize = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var cap = new Capture(); var amt = new Amount(); amt.total = "1"; amt.currency = "USD"; cap.amount = amt; var response = authorize.Capture(TestingUtil.GetApiContext(), cap); Assert.AreEqual("completed", response.state); }
public void AuthorizationGetTest() { try { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorize = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); Assert.AreEqual(authorizationId, authorize.id); } catch (ConnectionException ex) { TestingUtil.WriteConnectionExceptionDetails(ex); throw; } }
public void CaptureIdTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); var pay = PaymentTest.CreatePaymentAuthorization(apiContext); this.RecordConnectionDetails(); Assert.NotNull(pay); Assert.NotNull(pay.transactions); Assert.True(pay.transactions.Count > 0); var transaction = pay.transactions[0]; Assert.NotNull(transaction.related_resources); Assert.True(transaction.related_resources.Count > 0); var resource = transaction.related_resources[0]; Assert.NotNull(resource.authorization); var authorization = Authorization.Get(apiContext, resource.authorization.id); this.RecordConnectionDetails(); var cap = new Capture { amount = new Amount { total = "1", currency = "USD" } }; var responseCapture = authorization.Capture(apiContext, cap); this.RecordConnectionDetails(); Assert.NotNull(responseCapture); var returnCapture = Capture.Get(apiContext, responseCapture.id); this.RecordConnectionDetails(); Assert.Equal(responseCapture.id, returnCapture.id); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
public void CaptureIdTest() { try { var pay = PaymentTest.CreatePaymentAuthorization(); var authorizationId = pay.transactions[0].related_resources[0].authorization.id; var authorization = Authorization.Get(TestingUtil.GetApiContext(), authorizationId); var cap = new Capture(); var amt = new Amount(); amt.total = "1"; amt.currency = "USD"; cap.amount = amt; var responseCapture = authorization.Capture(TestingUtil.GetApiContext(), cap); var returnCapture = Capture.Get(TestingUtil.GetApiContext(), responseCapture.id); Assert.AreEqual(responseCapture.id, returnCapture.id); } finally { TestingUtil.RecordConnectionDetails(); } }
public void SaleRefundTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a credit card sale payment var payment = PaymentTest.CreatePaymentForSale(apiContext); this.RecordConnectionDetails(); // Get the sale resource var sale = payment.transactions[0].related_resources[0].sale; var refund = new Refund { amount = new Amount { currency = "USD", total = "0.01" } }; apiContext.ResetRequestId(); var response = sale.Refund(apiContext, refund); this.RecordConnectionDetails(); Assert.IsNotNull(response); Assert.AreEqual("completed", response.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }