Exemplo n.º 1
0
        public bool SendPayment(string userEmail, int points, string userId)
        {
            PaypalPaymentGateway paypalGatway   = new PaypalPaymentGateway();
            string            paymentNote       = string.Format("You have redeemed {0} points", points);
            decimal           amount            = (decimal)(points * 1.0);
            PayoutBatchHeader payoutBatchHeader = paypalGatway.SendPayment(userEmail, amount, paymentNote);

            SavePaymentTransaction(userId, PaymentMethodType.PayPal, payoutBatchHeader.payout_batch_id, amount, PaymentType.Redeem);
            UserGameInfo gameInfo = _GameDataAccess.GetGameInfoByUser(userId);
            int          point    = gameInfo.Point - points;

            _GameDataAccess.SaveUserPoint(userId, point);

            return(true);
        }
Exemplo n.º 2
0
 public Payment ExecutePayment(string payerId, string paymentId)
 {
     try
     {
         PaypalPaymentGateway paypalGatway = new PaypalPaymentGateway();
         var executedPayment = paypalGatway.ExecutePayment(payerId, paymentId);
         if (executedPayment.state.ToLower() != "approved")
         {
             throw new InvalidOperationException("Paypal payment faild.");
         }
         return(executedPayment);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        public Payment MakePayment(decimal amount)
        {
            PaypalPaymentGateway paypalGatway = new PaypalPaymentGateway();

            return(paypalGatway.CreatePayment(amount));
        }