Search code examples
xamarinxamarin.formspaypalpayment-gatewaypayment

How to implement Paypal checkout option in Xamarin.Forms?


I am make an M-Commerce application with the use of Xamarin.Forms in that user is able to checkout with payment integration and I have to use paypal method for checkout option and I am using .NET Standard project and project is also refer to the UWP. I check default paypal with example but I am not getting help.

I have new in payment integration method.

Can anyone look into this and suggest me what should I have to do in that?


Solution

  • You can use the Paypal Forms plugin for this:

    In MainActivity(Android)/AppDelegate(iOS) after "Forms.Init()" call the Init method with your PayPal config value

    global::Xamarin.Forms.Forms.Init ();
    var config = new PayPalConfiguration(PayPalEnvironment.NoNetwork,"Your PayPal ID from 
    https://developer.paypal.com/developer/applications/")
    {
    //If you want to accept credit cards
    AcceptCreditCards = true,
    //Your business name
    MerchantName = "Test Store",
    //Your privacy policy Url
    MerchantPrivacyPolicyUri = "https://www.example.com/privacy",
    //Your user agreement Url
    MerchantUserAgreementUri = "https://www.example.com/legal",
    // OPTIONAL - ShippingAddressOption (Both, None, PayPal, Provided)
    ShippingAddressOption = ShippingAddressOption.Both,
    // OPTIONAL - Language: Default languege for PayPal Plug-In
    Language = "es",
    // OPTIONAL - PhoneCountryCode: Default phone country code for PayPal Plug-In
    PhoneCountryCode = "52",
    };
    
     //iOS
     CrossPayPalManager.Init(config);
    
    //Android
     CrossPayPalManager.Init(config, this);
     ...
    

    You can find all the important API's on their Github itself.

    In case of issues or anything of that sort feel free to revert