Exemplo n.º 1
0
        public void PrepareDeviceAndPay(string paymentAmount)
        {
            if (Payleven.Devices == null || Payleven.Devices.Count() == 0)
            {
                // Payleven: devices list is empty");
                StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusDeviceNotFound);
                return;
            }

            var device = Payleven.Devices.FirstOrDefault();

            device.PrepareWithCompletionHandler((completionHandler) =>
            {
                if (device.Ready)
                {
                    // Payleven: making payment, device is ready
                    Pay(device, paymentAmount);
                }
                else
                {
                    // Payleven: device is not ready, check error code
                    StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusDeviceIsNotReady);
                }
            });
        }
Exemplo n.º 2
0
 public void LogInAndPay(NSString userName, NSString userPassword, string amount)
 {
     if (Payleven.LoginState == PLVPaylevenLoginState.PLVPaylevenLoginStateLoggedIn)
     {
         // Payleven: prepare device and make payment
         PrepareDeviceAndPay(amount);
     }
     else
     {
         // Payleven: login user
         Payleven.LoginWithUsername(userName, userPassword, new NSString(ApiKey), (errorHandler) =>
         {
             if (errorHandler == null)
             {
                 // Payleven: login successful
                 PrepareDeviceAndPay(amount);
             }
             else
             {
                 // Payleven: login failed
                 StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusLoginError);
             }
         });
     }
 }
Exemplo n.º 3
0
        public void Pay(PLVDevice device, string paymentAmount)
        {
            if (device == null)
            {
                // Payleven: device not found
                StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusDeviceNotFound);
                return;
            }

            if (!LocationCoordinate.IsValid())
            {
                // Payleven: coordinates are not valid
                StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusCoordsIsNotValid);
                return;
            }

            var paymentRequest = new PLVPaymentRequest(PaymentHelper.GetRandomNSString(), PaymentHelper.LocaleAmount(paymentAmount),
                                                       Currency, LocationCoordinate);

            var paymentTask = Payleven.PaymentTaskWithRequest(paymentRequest, device, this);

            if (paymentTask == null)
            {
                // Payleven: error with creating payment
                StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusError);
                return;
            }
            else
            {
                // Payleven: payment has started!
                paymentTask.Start();
            }
        }
Exemplo n.º 4
0
 public override void PLVPaymentTask(PLVPaymentTask paymentTask, NSError error)
 {
     if (error != null)
     {
         // Payleven: task failed, you can check error code
         StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusError);
     }
 }
Exemplo n.º 5
0
 public override void PaymentTaskDidFinish(PLVPaymentTask paymentTask)
 {
     StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusOK);
 }