コード例 #1
0
        public void Find_ReturnsPayPalAccountByToken()
        {
            Result <Customer> customerResult = gateway.Customer.Create(new CustomerRequest());

            Assert.IsTrue(customerResult.IsSuccess());

            var request = new PaymentMethodRequest
            {
                CustomerId         = customerResult.Target.Id,
                PaymentMethodNonce = Nonce.PayPalFuturePayment
            };
            Result <PaymentMethod> result = gateway.PaymentMethod.Create(request);

            Assert.IsTrue(result.IsSuccess());
            Assert.IsNotNull(result.Target.ImageUrl);

            PayPalAccount found = gateway.PayPalAccount.Find(result.Target.Token);

            Assert.IsNotNull(found);
            Assert.IsNotNull(found.Email);
            Assert.IsNotNull(found.ImageUrl);
            Assert.IsNotNull(found.CreatedAt);
            Assert.IsNotNull(found.UpdatedAt);
            Assert.AreEqual(found.Email, ((PayPalAccount)result.Target).Email);
        }
コード例 #2
0
        public PayPalAccount CreatePayPalAccount(PayPalAccount paypalAccount)
        {
            var request = new RestRequest("/paypal_accounts", Method.POST);

            request.AddParameter("user_id", paypalAccount.UserId);
            request.AddParameter("paypal_email", paypalAccount.PayPal.Email);

            var response = SendRequest(Client, request);

            return(JsonConvert.DeserializeObject <IDictionary <string, PayPalAccount> >(response.Content).Values.First());
        }
コード例 #3
0
        public ActionResult EditPayPalAccount([Bind(Include = "Id,ClubId,PayPalClientId,PayPalClientSecret")] PayPalAccount payPalAccount)
        {
            if (ModelState.IsValid)
            {
                db.Entry(payPalAccount).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ViewPayPalAccount", new { clubId = payPalAccount.ClubId }));
            }

            ViewBag.ClubId = new SelectList(db.Clubs, "Id", "name", payPalAccount.ClubId);
            return(View(payPalAccount));
        }
コード例 #4
0
        public void SampleNotification_ReturnsANotificationForPaymentMethodRevokedByCustomer()
        {
            Dictionary <string, string> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER, "my_payment_method_token");

            WebhookNotification notification = gateway.WebhookNotification.Parse(sampleNotification["bt_signature"], sampleNotification["bt_payload"]);

            Assert.AreEqual(WebhookKind.PAYMENT_METHOD_REVOKED_BY_CUSTOMER, notification.Kind);
            RevokedPaymentMethodMetadata metadata = notification.RevokedPaymentMethodMetadata;

            Assert.AreEqual("my_payment_method_token", metadata.Token);
            Assert.IsTrue(metadata.RevokedPaymentMethod is PayPalAccount);
            PayPalAccount paypalAccount = (PayPalAccount)metadata.RevokedPaymentMethod;

            Assert.IsNotNull(paypalAccount.RevokedAt);
        }
コード例 #5
0
        // GET: PayPalAccounts/Details/5
        // detail information of paypal Client ID and Client Secret
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PayPalAccount payPalAccount = db.PayPalAccounts.Find(id);

            if (payPalAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(payPalAccount));
        }
コード例 #6
0
        public ActionResult DeletePayPalAccount(int Id)
        {
            PayPalAccount payPalAccount = db.PayPalAccounts.Find(Id);

            if (payPalAccount == null)
            {
                return(HttpNotFound());
            }

            int AffectedClubId = payPalAccount.ClubId;

            db.PayPalAccounts.Remove(payPalAccount);
            db.SaveChanges();
            return(RedirectToAction("ViewPayPalAccount", new { clubId = AffectedClubId }));
        }
コード例 #7
0
        // GET: PayPalAccounts/Delete/5
        // The club office can delete Client ID and Client Secret
        public ActionResult DeletePayPalAccount(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PayPalAccount payPalAccount = db.PayPalAccounts.Find(Id);

            if (payPalAccount == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Id     = Id;
            ViewBag.ClubId = payPalAccount.ClubId;

            return(View(payPalAccount));
        }
コード例 #8
0
        // GET: PayPalAccounts/Edit/5
        // The club office can modify the current Client ID and Client Secret values
        public ActionResult EditPayPalAccount(int?Id, int?clubId)
        {
            if (Id == null || clubId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // CanEditClubData check
            string userId = User.Identity.GetUserId();
            List <ClubMembership> list = db.ClubMemberships.Where(c => c.ClubId == clubId && c.UserId == userId).ToList();

            if (list.Count == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            bool canEdit = false;

            foreach (ClubMembership item in list)
            {
                canEdit |= item.CanEditClubData;
            }

            if (canEdit == false)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PayPalAccount payPalAccount = db.PayPalAccounts.Find(Id);

            if (payPalAccount == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Id     = Id;
            ViewBag.ClubId = clubId;

            return(View(payPalAccount));
        }
コード例 #9
0
        public void CreatePayPalAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/paypal_account_create.json");
            var client  = GetMockClient(content);
            var repo    = new PayPalAccountRepository(client.Object);

            var userId  = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new PayPalAccount
            {
                UserId = userId,
                Active = true,
                PayPal = new PayPal
                {
                    Email = "*****@*****.**"
                }
            };
            var createdAccount = repo.CreatePayPalAccount(account);

            Assert.IsNotNull(createdAccount);
            Assert.IsNotNull(createdAccount.Id);
            Assert.AreEqual("AUD", createdAccount.Currency); // It seems that currency is determined by country
            Assert.IsNotNull(createdAccount.CreatedAt);
            Assert.IsNotNull(createdAccount.UpdatedAt);
        }