public void AuthorizationGetTest() { 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 authorizationId = resource.authorization.id; var authorize = Authorization.Get(apiContext, authorizationId); this.RecordConnectionDetails(); Assert.AreEqual(authorizationId, authorize.id); } 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 AuthorizationCaptureTest() { 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 cap = new Capture { amount = new Amount { total = "1", currency = "USD" } }; var response = authorize.Capture(apiContext, cap); this.RecordConnectionDetails(); Assert.AreEqual("completed", response.state); } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }