public void ShouldReturnSucessWhenAddSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "João Azevedo", this._document, this._address, this._email); this._subscription.AddPayment(payment); this._student.AddSubscription(this._subscription); Assert.IsTrue(this._student.Invalid); }
public void ShouldReturnSuccessWhenAddSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WayneCorp", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { // Check if document exists if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Document already exists"); } // Check if email exists if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Email already exists"); } var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, Domain.Enums.EDocumentType.CPF); var email = new Email(command.Email); var address = new Address( command.Street, command.Number, command.Neighborhood, command.City, command.State, command.County, command.ZipCode ); var student = new Student(name, document, email, address); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment( command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, address, email ); subscription.AddPayment(payment); student.AddSubscription(subscription); AddNotifications(name, document, email, address, student, subscription, payment); if (Invalid) { return(new CommandResult(false, "Unable to finish the subscription")); } _repository.CreateSubscription(student); _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome", "Your subscription was created"); return(new CommandResult(true, "Successful Subscription")); }
public void PayPalPaymentDidComplete(PayPalPayment completedPayment) { Debug.WriteLine ("PayPal Payment Success!"); this.CompletedPayment = completedPayment; // Payment was processed successfully; send to server for verification and fulfillment this.SendCompletedPaymentToServer (completedPayment); this.DismissViewController (false, null); }
public void ShouldReturnSuccessWhenHadNoActiveSubscription() { var payment = new PayPalPayment("1234545", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { // verificar se documento já está cadastrado if (_repository.DocucumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } // verificar se email ja esta cadastrado if (_repository.EmailExists(command.Document)) { AddNotification("Email", "Este e-mail já está em uso"); } // gerar VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Contry, command.ZipCode); // gerar entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment( command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email); // relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // agrupar as validações AddNotifications(name, document, email, address, student, subscription, payment); // salvar informações _repository.CreateSubscription(student); // enviar email de boas vindas _emailService.Send( student.Name.ToString(), student.Email.Address, "Bem vindo ao balta.io", "Sua assiantura foi criada" ); // retornar informações return(new CommandResult(true, "Asssinatura realizada com sucesso")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { // Fail fast validations command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Subscription were not created")); } // Validates if Document exists if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "This CPF is already in use"); } // Validates if Email exists if (_repository.EmailExists(command.Email)) { AddNotification("Email", "This E-mail is already in use"); } // Create VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Create Entities var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment(command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, new Email(command.PayerEmail)); // Relationships subscription.AddPayment(payment); student.AddSubscription(subscription); // Aggregate notifications AddNotifications(name, document, email, address, subscription, student, payment); // Check notifications if (Invalid) { return(new CommandResult(false, "It was not possible to create your subscription")); } // Save information _repository.CreateSubscription(student); // Send email _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome to this site", "Subscription created successfully"); // Returns return(new CommandResult(true, "Subscription created successfully")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { //Fail Fast Validation if (!command.Validate()) { AddNotifications(command); return(new CommandResult(false, "Não foi possivel realizar sua assinatura.")); } if (_studentRepository.DocumentExistis(command.DocumentNumber)) { AddNotification("Document", "CPF já em uso."); } if (_studentRepository.EmailExists(command.Email)) { AddNotification("Email", "E-mail já em uso."); } if (command.Valid) { var name = new Name(command.FirstName, command.LastName); var document = new Document(command.DocumentNumber, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment( command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, address, new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, email ); //Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); AddNotifications(name, document, email, address, student, subscription, payment); if (Valid) { _studentRepository.CreateSubscription(student); _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo", "Assinatura criada!"); return(new CommandResult(true, "Assinatura realizada com sucesso")); } } return(new CommandResult(false, "Não foi possivel realizar sua assinatura.")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { //verificar se documento está cadastrado, sem precisar do Banco if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Esse CPF já esta em uso"); } //verificar se email já está cadastrdo, sem precisar do Banco if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Esse Email já esta em uso"); } //Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Gerar as entidades, esa regiao muda de boleto para ca var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment( command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email); //relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); //agrupar as validacoes AddNotifications(name, document, email, address, student, subscription, payment); //checar as notificacoes if (Invalid) { return(new CommandResult(false, "Desculpe, Não foi possivel realizar sua assinatura")); } //salvar as informações _repository.CreateSubscription(student); //enviar e-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada"); //retornar informações return(new CommandResult(true, "Assinatura realizada com suceso")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { // Verificar se o Documento já está cadastrado if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } // Verificar se E-mail já está cadastrado if (_repository.EmailExists(command.Document)) { AddNotification("Email", "Este E-mail já está em uso"); } // Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Gerar as Entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); // Só munda a implementação do pagamento var payment = new PayPalPayment(command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email ); // Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // Agrupar as Validações AddNotifications(name, document, email, address, student, subscription, payment); if (Invalid) { return(new CommandResult(false, "Não foi possível realizar a sua assinatura")); } // Salvar as Informações _repository.CreateSubscription(student); // Enviar E-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada"); // Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso")); }
public void ShoudReturnErrorWhenHadNoActiveSubscription() { var payment = new PayPalPayment("5555555", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, _address, _document, "NCorp", _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
public override void PayPalPaymentViewController (PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment) { //throw new NotImplementedException (); Debug.WriteLine("PayPal Payment Success !"); paymentViewController.DismissViewController (true, () => { // send completed confirmaion to your server Debug.WriteLine ("Here is your proof of payment:" + completedPayment.Confirmation + "Send this to your server for confirmation and fulfillment."); ResultText = completedPayment.Description; }); }
public void ShouldReturnErrorWhenActiveHadSubscription() { var payment = new PayPalPayment("123456789", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Teste payer", _document, null, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("998899889988", DateTime.Now, DateTime.Now.AddDays(5), 80, 80, "Wayne Corp", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("123456789", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, _address, _email); var subscription = new Subscription(null); subscription.AddPayment(payment); _student.AddSubscription(subscription); _student.AddSubscription(subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadNoActiveSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now.AddDays(2), DateTime.Now.AddDays(5), 10, 8, "devlucasoliveira", _document, _address, _email); _subscription.AddPayment(payment); _subscription.Inactivate(); _student.AddSubscription(_subscription); Assert.AreEqual(_student.Valid, true); }
public void AddSubscription() { var subscription = new Subscription(null); var payment = new PayPalPayment("123423", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, _address , _document, "Cheio da grana Corporation LTDA.", _email); subscription.AddPayment(payment); _student.AddSubscriptions(subscription); Assert.IsTrue(_student.Valid); }
public void ShouldReturnSuccessWhenHadNoActiveSubscription() { var payment = new PayPalPayment("54984887", _email, DateTime.Now, DateTime.Now.AddDays(3), 600, 600, "DEV CORP", _document, _address); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.True(_student.Valid); }
public void ShoudReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("123456", "Wayne Corp", "4321", DateTime.Now, DateTime.Now, 10, 10, _address, _document, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldAddPayment() { var subscription = new Subscription(null); var payment = new PayPalPayment(DateTime.Now.AddDays(-1), DateTime.Now, 100, 100, string.Empty, null, null, null, string.Empty); subscription.AddPayment(payment); subscription.Payments.Count.Should().Be(1); subscription.Payments.First().Should().BeEquivalentTo(payment); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment(DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Manuel Gomes", _document, _address, _email, Guid.NewGuid().ToString().Replace("-", "").Substring(10)); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void Should_Return_Error_When_Had_Active_Subscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void DevoRetornarSucessoQuandoAdicionarInscricao() { var payment = new PayPalPayment(transactionCode: "1234567", paidDate: DateTime.Now.AddDays(-1), expireDate: DateTime.Now.AddDays(5), total: 10, totalPaid: 10, "NovaEmpresa", document: _document, address: _adress, email: _email); _subscription.AddPayment(payment); _student.AddSubscription(subscription: _subscription); Assert.IsTrue(_student.Valid); }
public void Should_Return_Errro_When_Had_Active_Subscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, this._student); this._subscription.AddPayment(payment); this._student.AddSubscription(this._subscription); this._student.AddSubscription(this._subscription); Assert.IsTrue(this._student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("2E846EE4D5D852", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", this._document, this._address, this._email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnSuccessWhenAddSubscription() { var subscription = new Subscription(null); var payment = new PayPalPayment("123456890", _address, _document, _email, "WAYNE CORP.", DateTime.Now, DateTime.Now.AddDays(5), 10, 10); subscription.AddPayment(payment); _student.AddSubscription(subscription); Assert.IsTrue(_student.Valid); }
public void ShouldReturnSuccessWhenNoActiveSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, "Bat Caverna, n.º 0", _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
// TODO: Expose this as a WeakDelegate through PayPalPaymentDelegate public void PayPalPaymentDidComplete(PayPalPayment completedPayment) { Debug.WriteLine("PayPal Payment Success!"); this.CompletedPayment = completedPayment; this.successView.Hidden = false; // Payment was processed successfully; send to server for verification and fulfillment this.SendCompletedPaymentToServer(completedPayment); this.DismissViewController(false, null); }
public void ShoulReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "BATIMA CORP", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void AddSubscription() { var payment = new PayPalPayment("1231asdasAS", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Test Payment", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("1234568", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, _address, "Rita Chita", _document, _email); _subscription.AddPayment(payment); _student.AddSubscriptions(_subscription); _student.AddSubscriptions(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnSuccessWhenAddSubscription() { var payment = new PayPalPayment("123123", DateTime.Now, DateTime.Now.AddDays(3), 20, 20, "Might Guy", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
public void OnBuyPressed(object sender, EventArgs e) { // PAYMENT_INTENT_SALE will cause the payment to complete immediately. // Change PAYMENT_INTENT_SALE to PAYMENT_INTENT_AUTHORIZE to only authorize payment and // capture funds later. var thingToBuy = new PayPalPayment(new BigDecimal("99.95"), "USD", "hipster jeans", PayPalPayment.PaymentIntentSale); var intent = new Intent(this, typeof(PaymentActivity)); intent.PutExtra(PaymentActivity.ExtraPayment, thingToBuy); StartActivityForResult(intent, RequestCodePayment); }
// Send confirmation to your server; your server should verify the proof of payment // and give the user their goods or services. If the server is not reachable, save // the confirmation and try again later. private async Task VerifyCompletedPayment (PayPalPayment completedPayment) { // We should send this to our server to ensure we store all payments made var error = new NSError (); var confirmation = completedPayment.Confirmation.ToString (); var jsonConfirmation = NSJsonSerialization.Serialize (completedPayment.Confirmation, NSJsonWritingOptions.PrettyPrinted, out error).ToString (); Console.WriteLine (jsonConfirmation); var paymentStatus = await API.VerifyCompletedPayment (jsonConfirmation, part); Console.WriteLine (paymentStatus); var alert = new UIAlertView ("Payment Result", paymentStatus, null, "Okay", null); alert.Show (); }
/* * This method shows use of optional payment details and item list. */ private PayPalPayment getStuffToBuy(string paymentIntent) { //--- include an item list, payment amount details PayPalItem[] items = { new PayPalItem("sample item #1", new Java.Lang.Integer(2), new BigDecimal("87.50"), "USD", "sku-12345678"), new PayPalItem("free sample item #2", new Java.Lang.Integer(1), new BigDecimal("0.00"), "USD", "sku-zero-price"), new PayPalItem("sample item #3 with a longer name", new Java.Lang.Integer(6), new BigDecimal("37.99"), "USD", "sku-33333") }; BigDecimal subtotal = PayPalItem.GetItemTotal(items); BigDecimal shipping = new BigDecimal("7.21"); BigDecimal tax = new BigDecimal("4.67"); PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails(shipping, subtotal, tax); BigDecimal amount = subtotal.Add(shipping).Add(tax); PayPalPayment payment = new PayPalPayment(amount, "USD", "sample item", paymentIntent); payment.Items(items).PaymentDetails(paymentDetails); //--- set other optional fields like invoice_number, custom field, and soft_descriptor payment.Custom("This is text that will be associated with the payment that the app can use."); return payment; }
partial void actPay(NSObject sender) { // Remove our last completed payment, just for demo purposes. CompletedPayment = null; var payment = new PayPalPayment { Amount = new NSDecimalNumber("9.95"), CurrencyCode = "USD", ShortDescription = "Hipster t-shirt", Intent = PayPalPaymentIntent.Sale }; if (!payment.Processable) { // This particular payment will always be processable. If, for // example, the amount was negative or the shortDescription was // empty, this payment wouldn't be processable, and you'd want // to handle that here. } _payPalConfig.AcceptCreditCards = AcceptCreditCards; _samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate(this); _paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, _samplePayPalPaymentDelegate); if (_paymentViewController.Handle == IntPtr.Zero) { Debug.WriteLine ("Failed to create PayPalPaymentViewController."); return; } PresentViewController (_paymentViewController, true, null); }
public override void DidCompletePayment (PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment) { VerifyCompletedPayment (completedPayment); paymentViewController.DismissViewController (true, null); }
private void BuyAnItemClicked(object sender, EventArgs e) { // Any customer identifier that you have will work here. Do NOT use a device- or // hardware-based identifier. string customerId = "user-11723"; var payment = new PayPalPayment () { Amount = new NSDecimalNumber("9.95"), CurrencyCode = "USD", ShortDescription = "Hipster t-shirt" }; // Set the environment: // - For live charges, use PayPalEnvironmentProduction (default). // - To use the PayPal sandbox, use PayPalEnvironmentSandbox. // - For testing, use PayPalEnvironmentNoNetwork. if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Mock) { PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentNoNetwork; } else if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Production) { PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentProduction; } else if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Sandbox) { PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentSandbox; } samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate (this); var paymentViewController = new PayPalPaymentViewController (AppConfig.kPayPalClientId, AppConfig.kPayPalReceiverEmail, customerId, payment, samplePayPalPaymentDelegate); if (paymentViewController.Handle == IntPtr.Zero) { Debug.WriteLine ("Failed to create PayPalPaymentViewController."); return; } // Setting the languageOrLocale property is optional. // // If you do not set languageOrLocale, then the PayPalPaymentViewController will present // its user interface according to the device's current language setting. // // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController // to use that language/locale. // // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h. paymentViewController.LanguageOrLocale = "en"; this.PresentViewController (paymentViewController, true, null); }
public override void PayPalPaymentViewController(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment) { Debug.WriteLine("PayPal Payment Success !"); paymentViewController.DismissViewController(true, () => { NSError err = null; NSData jsonData = NSJsonSerialization.Serialize(completedPayment.Confirmation, NSJsonWritingOptions.PrettyPrinted, out err); NSString first = new NSString(""); if (err == null) { first = new NSString(jsonData, NSStringEncoding.UTF8); } else { Debug.WriteLine(err.LocalizedDescription); } OnSuccess?.Invoke(first.ToString()); OnSuccess = null; }); }
private void PresentPayment () { var partNameForReal = string.Format ("{0} {1} {2} {3}", part.Year, part.Make, part.Model, part.PartName); var payment = new PayPalPayment () { Amount = new NSDecimalNumber (part.Price.ToString ()), CurrencyCode = "USD", Intent = PayPalPaymentIntent.Sale, ShortDescription = partNameForReal, Items = new NSObject[] { new PayPalItem { Currency = "USD", Name = partNameForReal, Price = new NSDecimalNumber (part.Price), Quantity = 1 } } } ; if (!payment.Processable) { var alert = new UIAlertView ("Error", "Could not create payment for this item.", null, "Okay", null); alert.Show (); } var paymentViewController = new PayPalPaymentViewController (payment, paymentConfiguration, paymentDelegate); PresentViewController (paymentViewController, true, null); }
private void SendCompletedPaymentToServer(PayPalPayment completedPayment) { // TODO: Send completedPayment.confirmation to server Dbg.WriteLine ("Here is your proof of payment:\n\n{0}\n\nSend this to your server for confirmation and fulfillment.", completedPayment.ToJSONObject().ToString(4)); }
public override void DidCompletePayment(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment) { _hostViewController.PayPalPaymentDidComplete(completedPayment); }
partial void actPay(NSObject sender) { // Remove our last completed payment, just for demo purposes. this.CompletedPayment = null; var payment = new PayPalPayment () { Amount = new NSDecimalNumber("9.95"), CurrencyCode = "USD", ShortDescription = "Hipster t-shirt" }; if (!payment.Processable) { // This particular payment will always be processable. If, for // example, the amount was negative or the shortDescription was // empty, this payment wouldn't be processable, and you'd want // to handle that here. } // Any customer identifier that you have will work here. Do NOT use a device- or // hardware-based identifier. string customerId = "user-11723"; // Set the environment: // - For live charges, use PayPalEnvironmentProduction (default). // - To use the PayPal sandbox, use PayPalEnvironmentSandbox. // - For testing, use PayPalEnvironmentNoNetwork. PayPalPaymentViewController.Environment = this.Environment; samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate (this); paymentViewController = new PayPalPaymentViewController (kPayPalClientId, kPayPalReceiverEmail, customerId, payment, samplePayPalPaymentDelegate); if (paymentViewController.Handle == IntPtr.Zero) { Debug.WriteLine ("Failed to create PayPalPaymentViewController."); return; } paymentViewController.HideCreditCardButton = !this.AcceptCreditCards; // Setting the languageOrLocale property is optional. // // If you do not set languageOrLocale, then the PayPalPaymentViewController will present // its user interface according to the device's current language setting. // // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController // to use that language/locale. // // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h. paymentViewController.LanguageOrLocale = "en"; this.PresentViewController (paymentViewController, true, null); }
void SendCompletedPaymentToServer(PayPalPayment completedPayment) { // TODO: Send completedPayment.confirmation to server Debug.WriteLine ("Here is your proof of payment:\n\n{0}\n\nSend this to your server for confirmation and fulfillment.", completedPayment.Confirmation); }
public override void PayPalPaymentDidComplete(PayPalPayment completedPayment) { HostViewController.PayPalPaymentDidComplete (completedPayment); }
public void BuyItems( PayPal.Forms.Abstractions.PayPalItem[] items, Deveel.Math.BigDecimal xfshipping, Deveel.Math.BigDecimal xftax, Action onCancelled, Action<string> onSuccess, Action<string> onError ) { OnCancelled = onCancelled; OnSuccess = onSuccess; OnError = onError; List<PayPalItem> nativeItems = new List<PayPalItem> (); foreach (var product in items) { nativeItems.Add (new PayPalItem ( product.Name, new Java.Lang.Integer ((int)product.Quantity), new BigDecimal (product.Price.ToString ()), product.Currency, product.SKU) ); } BigDecimal subtotal = PayPalItem.GetItemTotal (nativeItems.ToArray ()); BigDecimal shipping = new BigDecimal (xfshipping.ToString ()); BigDecimal tax = new BigDecimal (xftax.ToString ()); PayPalPaymentDetails paymentDetails = new PayPalPaymentDetails (shipping, subtotal, tax); BigDecimal amount = subtotal.Add (shipping).Add (tax); PayPalPayment payment = new PayPalPayment (amount, nativeItems.FirstOrDefault().Currency, "Multiple items", PayPalPayment.PaymentIntentSale); payment = payment.Items (nativeItems.ToArray ()).PaymentDetails (paymentDetails); Intent intent = new Intent (Context, typeof(PaymentActivity)); intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config); intent.PutExtra (PaymentActivity.ExtraPayment, payment); (Context as Activity).StartActivityForResult (intent, REQUEST_CODE_PAYMENT); }
/* * Enable retrieval of shipping addresses from buyer's PayPal account */ private void enableShippingAddressRetrieval(PayPalPayment paypalPayment, bool enable) { paypalPayment.EnablePayPalShippingAddressesRetrieval (enable); }
/* * Add app-provided shipping address to payment */ private void addAppProvidedShippingAddress(PayPalPayment paypalPayment) { ShippingAddress shippingAddress = new ShippingAddress ().RecipientName ("Mom Parker").Line1 ("52 North Main St.") .City ("Austin").State ("TX").PostalCode ("78729").CountryCode ("US"); paypalPayment.InvokeProvidedShippingAddress (shippingAddress); }
public void BuyItem( PayPal.Forms.Abstractions.PayPalItem item, Deveel.Math.BigDecimal xftax, Action onCancelled, Action<string> onSuccess, Action<string> onError ){ OnCancelled = onCancelled; OnSuccess = onSuccess; OnError = onError; BigDecimal amount = new BigDecimal (item.Price.ToString ()).Add (new BigDecimal (xftax.ToString ())); PayPalPayment payment = new PayPalPayment (amount, item.Currency, item.Name, PayPalPayment.PaymentIntentSale); Intent intent = new Intent (Context, typeof(PaymentActivity)); intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config); intent.PutExtra (PaymentActivity.ExtraPayment, payment); (Context as Activity).StartActivityForResult (intent, REQUEST_CODE_PAYMENT); }