public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIButton payWithCard = new UIButton();
            float    buttonWidth = (float)UIScreen.MainScreen.Bounds.Width - 80f;

            payWithCard.Frame = new CGRect(40f, 40f, buttonWidth, 40f);
            payWithCard.SetTitle("Pay 10 EUR with Card", UIControlState.Normal);
            payWithCard.BackgroundColor = UIColor.LightGray;

            payWithCard.TouchUpInside += (sender, e) =>
            {
                var merchantInfo = MerchantDetails.MerchantWithID("YOUR_MERCHANT_ID", true);

                CardPaymentProcess cardPayment = PaymentProcess.CardPaymentWithMerchant(merchantInfo, 1000, @"EUR");


                var controller = PiaSDK.ControllerForCardPaymentProcess(cardPayment, true,
                                                                        transactionCallback: (savecard, callback) => {
                    registerCardPaymnet(false, completionHandler: () => {
                        if (transactionInfo != null)
                        {
                            callback(CardRegistrationResponse.SuccessWithTransactionID(transactionInfo.TransactionID, transactionInfo.redirectUrl));
                        }
                        else
                        {
                            callback(CardRegistrationResponse.Failure(registrationError));
                        }
                    });;
                },
                                                                        success: (piaController) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert("Payment is successfull");
                        });
                    });
                },
                                                                        cancellation: (piaController) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert("transaction cancelled");
                        });
                    });
                },
                                                                        failure: (piaController, error) => {
                    InvokeOnMainThread(() => {
                        piaController.DismissViewController(true, completionHandler: () => {
                            showAlert(error.LocalizedDescription);
                        });
                    });
                });

                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCard = new UIButton();

            payWithSavedCard.Frame = new CGRect(40f, 120f, buttonWidth, 40f);
            payWithSavedCard.SetTitle("Pay 10 EUR with Saved Card", UIControlState.Normal);
            payWithSavedCard.BackgroundColor = UIColor.LightGray;

            payWithSavedCard.TouchUpInside += (sender, e) =>
            {
                var merchantId = "YOUR_MERCHANT_ID";

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(true, tokenCardInfo, merchantId, orderInfo, true);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCardSkipConfirmation = new UIButton();

            payWithSavedCardSkipConfirmation.Frame = new CGRect(40f, 200f, buttonWidth, 80f);
            payWithSavedCardSkipConfirmation.SetTitle("Pay 10 EUR - Saved Card(Skip confirmation)", UIControlState.Normal);
            payWithSavedCardSkipConfirmation.LineBreakMode   = UILineBreakMode.WordWrap;
            payWithSavedCardSkipConfirmation.BackgroundColor = UIColor.LightGray;

            payWithSavedCardSkipConfirmation.TouchUpInside += (sender, e) =>
            {
                var merchantInfo = new NPIMerchantInfo("YOUR_MERCHANT_ID", true, true);

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(tokenCardInfo, merchantInfo, orderInfo);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithMobilePay = new UIButton();

            payWithMobilePay.Frame = new CGRect(40f, 320f, buttonWidth, 40f);
            payWithMobilePay.SetTitle("Pay 10 EUR with MobilePay", UIControlState.Normal);
            payWithMobilePay.BackgroundColor = UIColor.LightGray;
            payWithMobilePay.TouchUpInside  += (sender, e) =>
            {
                if (!PiaSDK.LaunchWalletAppForWalletPaymentProcess(PaymentProcess.WalletPaymentForWallet(Wallet.MobilePayTest),
                                                                   (callback) => {
                    registerCallForWallets(MobileWallet.MobilePay, callback);
                },
                                                                   (redirectWithoutInterruption) => {
                    InvokeOnMainThread(() => {
                        PiaSDK.RemoveTransitionView();
                        if (redirectWithoutInterruption)
                        {
                            showAlert(@"Wallet redirected sucessfully, Please check transaction status from your backend");
                        }
                        else
                        {
                            showAlert(@"wallet redirected interrupt");
                        }
                    });
                }, (error) => {
                    InvokeOnMainThread(() =>
                    {
                        showAlert(error.LocalizedDescription);
                    });
                }))
                {
                    showAlert(@"failed to launch wallet app");
                }
                ;
            };


            UIButton payWithPaytrail = new UIButton();

            payWithPaytrail.Frame = new CGRect(40f, 400f, buttonWidth, 40f);
            payWithPaytrail.SetTitle("Pay 10 EUR with Paytrail", UIControlState.Normal);
            payWithPaytrail.BackgroundColor = UIColor.LightGray;
            payWithPaytrail.TouchUpInside  += (sender, e) =>
            {
                var merchantId = "YOUR_MERCHANT_ID";
                isPaytrail = true;

                PiaSDK.AddTransitionViewIn(this.View);

                registerCardPaymnet(false, completionHandler: () =>
                {
                    var controller          = new PiaSDKController(merchantId, transactionInfo, true);
                    PiaDelegate newDelegate = new PiaDelegate();
                    controller.PiaDelegate  = newDelegate;
                    newDelegate.vc          = this;
                    InvokeOnMainThread(() => {
                        PiaSDK.RemoveTransitionView();
                        this.PresentViewController(controller, true, null);
                    });
                });
            };

            this.View.AddSubview(payWithCard);
            this.View.AddSubview(payWithSavedCard);
            this.View.AddSubview(payWithSavedCardSkipConfirmation);
            this.View.AddSubview(payWithMobilePay);
            this.View.AddSubview(payWithPaytrail);
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIButton payWithCard = new UIButton();
            float    buttonWidth = (float)UIScreen.MainScreen.Bounds.Width - 80f;

            payWithCard.Frame = new CGRect(40f, 40f, buttonWidth, 40f);
            payWithCard.SetTitle("Pay 10 EUR with Card", UIControlState.Normal);
            payWithCard.BackgroundColor = UIColor.LightGray;

            payWithCard.TouchUpInside += (sender, e) =>
            {
                //#internal_code_section_start
                var merchantInfo = new NPIMerchantInfo("12002835", true);
                //#internal_code_section_end

                /*#external_code_section_start
                 * var merchantInfo = new NPIMerchantInfo("YOUR_MERCHANT_ID", true);
                 #external_code_section_end*/
                var         amount      = new NSNumber(10);
                var         orderInfo   = new NPIOrderInfo(amount, "EUR");
                var         controller  = new PiaSDKController(orderInfo, merchantInfo);
                PiaDelegate newDelegate = new PiaDelegate();
                newDelegate.vc         = this;
                controller.PiaDelegate = newDelegate;
                isPayingWithToken      = false;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCard = new UIButton();

            payWithSavedCard.Frame = new CGRect(40f, 120f, buttonWidth, 40f);
            payWithSavedCard.SetTitle("Pay 10 EUR with Saved Card", UIControlState.Normal);
            payWithSavedCard.BackgroundColor = UIColor.LightGray;

            payWithSavedCard.TouchUpInside += (sender, e) =>
            {
                //#internal_code_section_start
                var merchantId = "12002835";
                //#internal_code_section_end

                /*#external_code_section_start
                 * var merchantId = "YOUR_MERCHANT_ID";
                 #external_code_section_end*/

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(true, tokenCardInfo, merchantId, orderInfo, true);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithSavedCardSkipConfirmation = new UIButton();

            payWithSavedCardSkipConfirmation.Frame = new CGRect(40f, 200f, buttonWidth, 80f);
            payWithSavedCardSkipConfirmation.SetTitle("Pay 10 EUR - Saved Card(Skip confirmation)", UIControlState.Normal);
            payWithSavedCardSkipConfirmation.LineBreakMode   = UILineBreakMode.WordWrap;
            payWithSavedCardSkipConfirmation.BackgroundColor = UIColor.LightGray;

            payWithSavedCardSkipConfirmation.TouchUpInside += (sender, e) =>
            {
                //#internal_code_section_start
                var merchantInfo = new NPIMerchantInfo("12002835", true, false);
                //#internal_code_section_end

                /*#external_code_section_start
                 * var merchantInfo = new NPIMerchantInfo("YOUR_MERCHANT_ID", true, true);
                 #external_code_section_end*/

                var         amount        = new NSNumber(10);
                var         orderInfo     = new NPIOrderInfo(amount, "EUR");
                var         tokenCardInfo = new NPITokenCardInfo("492500******0004", SchemeType.Visa, "08/22", false);
                var         controller    = new PiaSDKController(tokenCardInfo, merchantInfo, orderInfo);
                PiaDelegate newDelegate   = new PiaDelegate();
                newDelegate.vc         = this;
                isPayingWithToken      = true;
                controller.PiaDelegate = newDelegate;
                this.PresentViewController(controller, true, null);
            };

            UIButton payWithVipps = new UIButton();

            payWithVipps.Frame = new CGRect(40f, 320f, buttonWidth, 40f);
            payWithVipps.SetTitle("Pay 10 NOK with Vipps", UIControlState.Normal);
            payWithVipps.BackgroundColor = UIColor.LightGray;
            payWithVipps.TouchUpInside  += (sender, e) =>
            {
                WalletDelegate newDelegate = new WalletDelegate();
                newDelegate.vc = this;
                if (!PiaSDK.InitiateVippsFromSender(this, newDelegate))
                {
                    showAlert("Vipps app not installed");
                }
            };

            UIButton payWithSwish = new UIButton();

            payWithSwish.Frame = new CGRect(40f, 400f, buttonWidth, 40f);
            payWithSwish.SetTitle("Pay 10 SEK with Swish", UIControlState.Normal);
            payWithSwish.BackgroundColor = UIColor.LightGray;
            payWithSwish.TouchUpInside  += (sender, e) =>
            {
                SwishDelegate newDelegate = new SwishDelegate();
                newDelegate.vc = this;
                if (!PiaSDK.InitiateSwishFromSender(this, newDelegate))
                {
                    showAlert("Swish app not installed");
                }
            };

            this.View.AddSubview(payWithCard);
            this.View.AddSubview(payWithSavedCard);
            this.View.AddSubview(payWithSavedCardSkipConfirmation);
            this.View.AddSubview(payWithVipps);
            this.View.AddSubview(payWithSwish);
        }