I am trying to implement InApp Provisioning - Apple Pay in Xamarin forms project but I didn't find much resources that explain the steps clearly. What is the correct setup? How to test it, and what about env (sandbox or production) ? Hope that I can find helpful answers Thank you!
var canaddpass = PKAddPaymentPassViewController.CanAddPaymentPass;
if (canaddpass)
{
var config = new PKAddPaymentPassRequestConfiguration(PKEncryptionScheme.Ecc_V2);
var addPaymentPassVC = new PKAddPaymentPassViewController(config, this);
View.BackgroundColor = UIColor.White;
Title = "My Custom View Controller";
var btn = UIButton.FromType(UIButtonType.System);
btn.Frame = new CGRect(20, 200, 280, 44);
btn.SetTitle("Click Me", UIControlState.Normal);
btn.TouchUpInside += (sender, e) => {
//this.ShowViewController(addPaymentPassVC, (Foundation.NSObject)sender); This line will also work
this.PresentViewControllerAsync(addPaymentPassVC, true);
};
View.AddSubview(btn);
}
I tried the above code but I got this exception:
System.Exception: Could not initialize an instance of the type 'PassKit.PKAddPaymentPassViewController': the native 'initWithRequestConfiguration:delegate:' method returned nil
PKAddPaymentPassViewController
, which requires the com.apple.developer.payment-pass-provisioning
entitlement key for your app.
To add this key following steps:
Go to Identifier section in the developer portal:
Select your identifier and go to Aditional Capabilities, enable option like this:
Got to iOS project, add this key to Entitlements.plist file:
<key>com.apple.developer.payment-pass-provisioning</key>
<true/>
<key>com.apple.developer.pass-type-identifiers</key>
<array>
<string>$(TeamIdentifierPrefix)*</string>
</array>`
According Apple Documentation you need special permission from Apple to submit apps with this key enabled. For more information, contact [email protected].