/// <summary> /// Example for performing charge subscription request with Agreement. /// </summary> public void ChargeSubscriptionWithAgreement() { //Set up an agreement / setupSubscription / Reserving amount in order to charge it later PaymentResult createPaymentResult = ReserveAmount(Amount.Get(7777.00, Currency.EUR), AuthType.subscription, "IT_AGREEMENTS_UI_"); //Transaction ID is returned from the gateway when payment request was successful string transactionId = createPaymentResult.Payment.TransactionId; //WaitForDataToFlowIntoReporting Thread.Sleep(3000); //initialise charge subscription request class, this class is used for forwarding all the data needed for charging an agreement / charge subscription request var chargeSubscriptionRequest = new ChargeSubscriptionRequest() { AgreementId = transactionId, Amount = Amount.Get(7777, Currency.XXX), AgreementUnscheduledType = AgreementUnscheduledType.incremental, }; //call capture method SubscriptionResult subscriptionResult = _api.ChargeSubscription(chargeSubscriptionRequest); //Result property contains information if the request was successful or not if ((subscriptionResult.Result == Result.Success) && (createPaymentResult.Payment.TransactionId == subscriptionResult.Payment.TransactionId) && (subscriptionResult.Payment.TransactionStatus == "recurring_confirmed") && (subscriptionResult.RecurringPayment.TransactionStatus == "captured")) { //subscription charge was successful Transaction transaction = subscriptionResult.Payment; } else { //capture unsuccessful //error messages contain information about what went wrong string errorMerchantMessage = subscriptionResult.ResultMerchantMessage; string errorMessage = subscriptionResult.ResultMessage; } }
public void ChargeSubscriptionReturnsSuccess() { PaymentResult createPaymentResult = ReserveAmount(1.23, AuthType.subscription); this.WaitForDataToFlowIntoReporting(); var request = new ChargeSubscriptionRequest() { SubscriptionId = createPaymentResult.Payment.TransactionId, Amount = Amount.Get(1, Currency.XXX), }; SubscriptionResult result = _api.ChargeSubscription(request); Assert.AreEqual(Result.Success, result.Result); }
public void ChargeSubscriptionReturnsBothPayments() { PaymentResult createPaymentResult = ReserveAmount(1.23, AuthType.subscription); this.WaitForDataToFlowIntoReporting(); var request = new ChargeSubscriptionRequest() { SubscriptionId = createPaymentResult.Payment.TransactionId, Amount = Amount.Get(1, Currency.XXX), }; SubscriptionResult result = _api.ChargeSubscription(request); Assert.AreEqual(createPaymentResult.Payment.TransactionId, result.Payment.TransactionId); Assert.AreEqual("recurring_confirmed", result.Payment.TransactionStatus); Assert.AreEqual("captured", result.RecurringPayment.TransactionStatus); }
public void ChargeSubscriptionWithAgreementReturnsSuccess() { PaymentResult createPaymentResult = ReserveAmount(7.77, AuthType.subscription, "IT_AGREEMENTS_UI_"); this.WaitForDataToFlowIntoReporting(); var request = new ChargeSubscriptionRequest() { AgreementId = createPaymentResult.Payment.TransactionId, Amount = Amount.Get(7, Currency.XXX), AgreementUnscheduledType = AgreementUnscheduledType.incremental, }; SubscriptionResult result = _api.ChargeSubscription(request); Assert.AreEqual(Result.Success, result.Result); Assert.AreEqual(createPaymentResult.Payment.TransactionId, result.Payment.TransactionId); Assert.AreEqual("recurring_confirmed", result.Payment.TransactionStatus); Assert.AreEqual("captured", result.RecurringPayment.TransactionStatus); }