Beispiel #1
0
        public static bool Cancel(string paymentGuidString)
        {
            Guid paymentGuid = Guid.Empty;

            if (!Guid.TryParse(paymentGuidString, out paymentGuid))
            {
                return(false);
            }

            Payment payment = Payment.CreateManager().Load(paymentGuid, GuidType.Internal);

            if (payment == null)
            {
                return(false);
            }

            ServiceLookupMethodMap slmm = ServiceLookupMethodMap.CreateManager(2).Load(payment.ServiceOffer.Service, payment.PaymentRequest.Customer.Country, LookupMethod.Wap);

            string referenceId = payment.ExternalPaymentGuid.Value.ToString();
            string username    = slmm.PaymentConfiguration.PaymentCredentials.Username;
            string password    = slmm.PaymentConfiguration.PaymentCredentials.Password;
            CancelSubscriptionRequest request = new CancelSubscriptionRequest(RequestMode.Synchronous, referenceId, username, password, payment.ExternalPaymentGuid.Value, SubscriptionCancellationMode.Interactive, null);
            SubscriptionClient        client  = new SubscriptionClient();

            client.AttachLogWriter(new CashflowLog(payment.ServiceOffer.Service));
            CancelSubscriptionResponse response = client.CancelSubscription(request);

            if (response == null || response.Status == null || response.Status.Code != MessageStatusCode.Success)
            {
                // TODO: logging error
                return(false);
            }
            // TODO: logging subscription canceled
            return(true);
        }
Beispiel #2
0
        public static TransactionResult GetTransaction(string transactionGuidInput, string paymentGuidInput, string transactioGroupInput)
        {
            Guid transactionGuid      = Guid.Empty;
            Guid paymentGuid          = Guid.Empty;
            Guid transactionGroupGuid = Guid.Empty;

            if (!Guid.TryParse(transactionGuidInput, out transactionGuid) || !Guid.TryParse(paymentGuidInput, out paymentGuid) || !Guid.TryParse(transactioGroupInput, out transactionGroupGuid))
            {
                return(null);
            }

            Payment payment = Payment.CreateManager().Load(paymentGuid, GuidType.Internal);

            if (payment == null)
            {
                return(null);
            }

            ServiceLookupMethodMap slmm = ServiceLookupMethodMap.CreateManager().Load(payment.ServiceOffer.Service, payment.PaymentRequest.Customer.Country, LookupMethod.Wap);

            TransactionClient transactionClient = new TransactionClient();

            transactionClient.AttachLogWriter(new CashflowLog(payment.ServiceOffer.Service));

            GetTransactionsRequest getTransactionRequest = new GetTransactionsRequest(RequestMode.Default,
                                                                                      payment.ExternalPaymentGuid.ToString(),
                                                                                      slmm.PaymentConfiguration.PaymentCredentials.Username,
                                                                                      slmm.PaymentConfiguration.PaymentCredentials.Password,
                                                                                      transactionGroupGuid,
                                                                                      null);

            GetTransactionsResponse getTransactionResponse = transactionClient.GetTransactions(getTransactionRequest, null);

            foreach (Cashflow.Message.Data.Transaction transaction in getTransactionResponse.Transactions)
            {
                if (transaction.TransactionID == transactionGuid)
                {
                    return new TransactionResult()
                           {
                               Transaction = transaction,
                               Username    = slmm.PaymentConfiguration.PaymentCredentials.Username,
                               Password    = slmm.PaymentConfiguration.PaymentCredentials.Password
                           }
                }
            }
            ;

            return(null);
        }