Skip to content

Commit

Permalink
[PassKit] Add support Xcode15 Beta 7 (#19139)
Browse files Browse the repository at this point in the history
The bindings for PassKit Xcode15 Beta 7.

---------

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
  • Loading branch information
tj-devel709 and tj_devel709 committed Oct 23, 2023
1 parent af3fb85 commit 6d30e58
Show file tree
Hide file tree
Showing 15 changed files with 331 additions and 289 deletions.
37 changes: 36 additions & 1 deletion src/PassKit/PKEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public enum PKMerchantCapability : ulong {
ThreeDS = 1 << 0,
EMV = 1 << 1,
Credit = 1 << 2,
Debit = 1 << 3
Debit = 1 << 3,
[iOS (17, 0), Mac (14, 0), Watch (10, 0), NoTV, MacCatalyst (17, 0)]
InstantFundsOut = 1 << 7,
}

[NoMac]
Expand Down Expand Up @@ -386,4 +388,37 @@ public enum PKVehicleConnectionSessionConnectionState : long {
Connecting,
FailedToConnect,
}

[iOS (17, 0), Mac (14, 0), Watch (10, 0), TV (17, 0), MacCatalyst (17, 0)]
[Native]
public enum PKApplePayLaterAvailability : long {
Available,
UnavailableItemIneligible,
UnavailableRecurringTransaction,
}

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Native]
[ErrorDomain ("PKDisbursementErrorDomain")]
public enum PKDisbursementErrorCode : long {
UnknownError = -1,
UnsupportedCardError = 1,
RecipientContactInvalidError,
}

[NoWatch, NoTV, NoMac, iOS (17, 0), NoMacCatalyst]
[Native]
public enum PKPayLaterAction : long {
LearnMore = 0,
Calculator,
}

[NoWatch, NoTV, NoMac, iOS (17, 0), NoMacCatalyst]
[Native]
public enum PKPayLaterDisplayStyle : long {
Standard = 0,
Badge,
Checkout,
Price,
}
}
72 changes: 72 additions & 0 deletions src/PassKit/PKPayLaterView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Can be uncommented when this issue is resolved: # https://github.com/xamarin/xamarin-macios/issues/19271

// #nullable enable

// #if IOS && !__MACCATALYST__

// using System;
// using System.Runtime.InteropServices;
// using System.Runtime.CompilerServices;
// using ObjCRuntime;
// using Foundation;
// using PassKit;

// #if !NET
// using NativeHandle = System.IntPtr;
// #endif

// namespace PassKit {

// public partial class PKPayLaterView {

// #if !NET
// delegate void PKPayLaterValidateAmountCompletionHandler (IntPtr block, byte eligible);
// static PKPayLaterValidateAmountCompletionHandler static_ValidateAmount = TrampolineValidateAmount;

// [MonoPInvokeCallback (typeof (PKPayLaterValidateAmountCompletionHandler))]
// #else
// [UnmanagedCallersOnly]
// #endif
// static void TrampolineValidateAmount (IntPtr block, byte eligible)
// {
// var del = BlockLiteral.GetTarget<Action<bool>> (block);
// if (del is not null) {
// del (eligible != 0);
// }
// }

// #if NET
// [SupportedOSPlatform ("ios17.0")]
// [UnsupportedOSPlatform ("maccatalyst")]
// [UnsupportedOSPlatform ("macos")]
// [UnsupportedOSPlatform ("tvos")]
// #endif
// [BindingImpl (BindingImplOptions.Optimizable)]
// public static void ValidateAmount (NSDecimalNumber amount, string currencyCode, Action<bool> callback)
// {
// if (callback is null)
// ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (callback));

// unsafe {
// #if NET
// delegate* unmanaged<IntPtr, byte, void> trampoline = &TrampolineValidateAmount;
// using var block = new BlockLiteral (trampoline, callback, typeof (PKPayLaterView), nameof (TrampolineValidateAmount));
// #else
// using var block = new BlockLiteral ();
// block.SetupBlockUnsafe (static_ValidateAmount, callback);
// #endif
// var nsCurrencyCodePtr = NSString.CreateNative (currencyCode);
// try {
// PKPayLaterValidateAmount (amount.Handle, nsCurrencyCodePtr, &block);
// } finally {
// NSString.ReleaseNative (nsCurrencyCodePtr);
// }
// }
// }

// [DllImport (Constants.PassKitLibrary)]
// unsafe static extern void PKPayLaterValidateAmount (IntPtr /* NSDecimalNumber */ amount, IntPtr /* NSString */ currencyCode, BlockLiteral* callback);
// }
// }

// #endif
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,7 @@ PASSKIT_API_SOURCES = \

PASSKIT_SOURCES = \
PassKit/PKCompat.cs \
PassKit/PKPayLaterView.cs \
PassKit/PKPaymentRequest.cs \
PassKit/PKShareablePassMetadata.cs \

Expand Down
170 changes: 166 additions & 4 deletions src/passkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using UIViewController = AppKit.NSViewController;
using UIWindow = AppKit.NSWindow;
using UIControl = AppKit.NSControl;
using UIView = AppKit.NSView;
#else
using UIKit;
#if IOS
Expand Down Expand Up @@ -406,6 +407,10 @@ interface PKPaymentAuthorizationViewController {
[Export ("initWithPaymentRequest:")]
NativeHandle Constructor (PKPaymentRequest request);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Export ("initWithDisbursementRequest:")]
NativeHandle Constructor (PKDisbursementRequest request);

[Export ("delegate", ArgumentSemantic.UnsafeUnretained)]
[NullAllowed]
NSObject WeakDelegate { get; set; }
Expand All @@ -425,6 +430,21 @@ interface PKPaymentAuthorizationViewController {
[Static]
[Export ("canMakePaymentsUsingNetworks:capabilities:")]
bool CanMakePaymentsUsingNetworks (string [] supportedNetworks, PKMerchantCapability capabilties);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursements")]
bool SupportsDisbursements ();

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursementsUsingNetworks:")]
bool SupportsDisbursements (string [] supportedNetworks);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursementsUsingNetworks:capabilities:")]
bool SupportsDisbursements (string [] supportedNetworks, PKMerchantCapability capabilities);
}
#endif

Expand Down Expand Up @@ -646,6 +666,10 @@ interface PKPaymentRequest {
[NoWatch, Mac (13, 3), iOS (16, 4), MacCatalyst (16, 4), NoTV]
[Export ("deferredPaymentRequest", ArgumentSemantic.Strong)]
PKDeferredPaymentRequest DeferredPaymentRequest { get; set; }

[iOS (17, 0), Mac (14, 0), Watch (10, 0), NoTV, MacCatalyst (17, 0)]
[Export ("applePayLaterAvailability", ArgumentSemantic.Assign)]
PKApplePayLaterAvailability ApplePayLaterAvailability { get; set; }
}

[Mac (11, 0)]
Expand Down Expand Up @@ -1141,6 +1165,14 @@ interface PKPaymentNetwork {
[iOS (16, 0), Mac (13, 0), Watch (9, 0), NoTV, MacCatalyst (16, 0)]
[Field ("PKPaymentNetworkBancontact")]
NSString Bancontact { get; }

[iOS (17, 0), Mac (14, 0), Watch (10, 0), NoTV, MacCatalyst (17, 0)]
[Field ("PKPaymentNetworkPagoBancomat")]
NSString PagoBancomat { get; }

[iOS (17, 0), Mac (14, 0), Watch (10, 0), NoTV, MacCatalyst (17, 0)]
[Field ("PKPaymentNetworkTmoney")]
NSString Tmoney { get; }
}

#if !WATCH
Expand Down Expand Up @@ -1229,6 +1261,25 @@ interface PKPaymentAuthorizationController {
[Async]
[Export ("dismissWithCompletion:")]
void Dismiss ([NullAllowed] Action completion);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursements")]
bool SupportsDisbursements ();

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursementsUsingNetworks:")]
bool SupportsDisbursements (string [] supportedNetworks);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
[Export ("supportsDisbursementsUsingNetworks:capabilities:")]
bool SupportsDisbursements (string [] supportedNetworks, PKMerchantCapability capabilities);

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Export ("initWithDisbursementRequest:")]
NativeHandle Constructor (PKDisbursementRequest request);
}

interface IPKPaymentAuthorizationControllerDelegate { }
Expand Down Expand Up @@ -1554,15 +1605,19 @@ interface PKPaymentErrorKeys {

interface IPKDisbursementAuthorizationControllerDelegate { }

#if !XAMCORE_5_0
[NoMac] // only used in non-macOS API
[NoWatch]
[iOS (12, 2)]
[MacCatalyst (13, 1)]
[Obsoleted (PlatformName.iOS, 17, 0, message: "No longer used.")]
[Obsoleted (PlatformName.MacCatalyst, 17, 0, message: "No longer used.")]
[Native]
public enum PKDisbursementRequestSchedule : long {
OneTime,
Future,
}
#endif

[NoWatch]
[iOS (12, 2)]
Expand All @@ -1571,11 +1626,57 @@ public enum PKDisbursementRequestSchedule : long {
[BaseType (typeof (NSObject))]
interface PKDisbursementRequest {

[NullAllowed, Export ("currencyCode")]
[Export ("currencyCode")]
string CurrencyCode { get; set; }

[NullAllowed, Export ("summaryItems", ArgumentSemantic.Copy)]
[Export ("summaryItems", ArgumentSemantic.Copy)]
PKPaymentSummaryItem [] SummaryItems { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("merchantIdentifier")]
string MerchantIdentifier { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("regionCode")]
string RegionCode { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("supportedNetworks", ArgumentSemantic.Copy)]
string [] SupportedNetworks { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("merchantCapabilities", ArgumentSemantic.Assign)]
PKMerchantCapability MerchantCapabilities { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("requiredRecipientContactFields", ArgumentSemantic.Strong)]
string [] RequiredRecipientContactFields { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[NullAllowed, Export ("recipientContact", ArgumentSemantic.Strong)]
PKContact RecipientContact { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[NullAllowed, Export ("supportedRegions", ArgumentSemantic.Copy)]
string [] SupportedRegions { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[NullAllowed, Export ("applicationData", ArgumentSemantic.Copy)]
NSData ApplicationData { get; set; }

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Export ("initWithMerchantIdentifier:currencyCode:regionCode:supportedNetworks:merchantCapabilities:summaryItems:")]
NativeHandle Constructor (string merchantIdentifier, string currencyCode, string regionCode, string [] supportedNetworks, PKMerchantCapability merchantCapabilities, PKPaymentSummaryItem [] summaryItems);

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Static]
[Export ("disbursementContactInvalidErrorWithContactField:localizedDescription:")]
NSError GetDisbursementContactInvalidError (string field, [NullAllowed] string localizedDescription);

[iOS (17, 0), NoMac, NoWatch, NoTV, NoMacCatalyst]
[Static]
[Export ("disbursementCardUnsupportedError")]
NSError DisbursementCardUnsupportedError { get; }
}

[Mac (11, 0)]
Expand Down Expand Up @@ -1671,12 +1772,12 @@ interface PKAddCarKeyPassConfiguration {
PKRadioTechnology SupportedRadioTechnologies { get; set; }

// headers say [Watch (9,0)] but PKAddSecureElementPassConfiguration is not supported for watch
[iOS (16, 0), Mac (13, 0), NoMacCatalyst, NoTV, NoWatch]
[iOS (16, 0), Mac (13, 0), MacCatalyst (16, 0), NoTV, NoWatch]
[Export ("manufacturerIdentifier")]
string ManufacturerIdentifier { get; set; }

// headers say [Watch (9,0)] but PKAddSecureElementPassConfiguration is not supported for watch
[iOS (16, 0), Mac (13, 0), NoMacCatalyst, NoTV, NoWatch]
[iOS (16, 0), Mac (13, 0), MacCatalyst (16, 0), NoTV, NoWatch]
[NullAllowed, Export ("provisioningTemplateIdentifier", ArgumentSemantic.Strong)]
string ProvisioningTemplateIdentifier { get; set; }
}
Expand Down Expand Up @@ -2645,4 +2746,65 @@ interface PKDeferredPaymentRequest {
[DesignatedInitializer]
NativeHandle Constructor (string paymentDescription, PKDeferredPaymentSummaryItem deferredBilling, NSUrl managementUrl);
}

[NoWatch, NoTV, NoMac, iOS (17, 0), NoMacCatalyst]
[BaseType (typeof (UIView))]
[DisableDefaultCtor]
interface PKPayLaterView {

[Export ("initWithAmount:currencyCode:")]
NativeHandle Constructor (NSDecimalNumber amount, string currencyCode);

[NullAllowed, Wrap ("WeakDelegate")]
IPKPayLaterViewDelegate Delegate { get; set; }

[NullAllowed, Export ("delegate", ArgumentSemantic.Assign)]
NSObject WeakDelegate { get; set; }

[Export ("amount", ArgumentSemantic.Copy)]
NSDecimalNumber Amount { get; set; }

[Export ("currencyCode")]
string CurrencyCode { get; set; }

[Export ("displayStyle", ArgumentSemantic.Assign)]
PKPayLaterDisplayStyle DisplayStyle { get; set; }

[Export ("action", ArgumentSemantic.Assign)]
PKPayLaterAction Action { get; set; }
}

interface IPKPayLaterViewDelegate { }

[NoWatch, NoTV, NoMac, iOS (17, 0), NoMacCatalyst]
#if NET
[Protocol, Model]
#else
[Protocol, Model (AutoGeneratedName = true)]
#endif
[BaseType (typeof (NSObject))]
interface PKPayLaterViewDelegate {
[Abstract]
[Export ("payLaterViewDidUpdateHeight:")]
void PayLaterViewDidUpdateHeight (PKPayLaterView view);
}

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[Static]
interface PKDirbursementError {
[Field ("PKDisbursementErrorContactFieldUserInfoKey")]
NSString ContactFieldUserInfoKey { get; }
}

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[BaseType (typeof (PKPaymentSummaryItem))]
[DisableDefaultCtor]
interface PKInstantFundsOutFeeSummaryItem : NSCoding, NSCopying, NSSecureCoding {
}

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[BaseType (typeof (PKPaymentSummaryItem))]
[DisableDefaultCtor]
interface PKDisbursementSummaryItem : NSCoding, NSCopying, NSSecureCoding {
}
}
5 changes: 5 additions & 0 deletions tests/introspection/ApiCtorInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,11 @@ protected virtual bool Match (ConstructorInfo ctor, Type type)
if (cstr == "Void .ctor(System.String, Foundation.NSBundle)")
return true;
break;
case "PKPayLaterView":
// headers have: (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
if (cstr == "Void .ctor(CoreGraphics.CGRect)")
return true;
break;
case "VNDetectedPoint":
// This class is not meant to be instantiated
if (cstr == "Void .ctor(Double, Double)")
Expand Down
Loading

6 comments on commit 6d30e58

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 6d30e583d35b8e93d6674fb174c803cc06ca0fa3 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻

All tests on macOS M1 - Mac Ventura (13.0) passed.

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 6d30e583d35b8e93d6674fb174c803cc06ca0fa3 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 235 tests passed 🎉

Tests counts

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 6 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 41 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 6d30e583d35b8e93d6674fb174c803cc06ca0fa3 [CI build]

Please sign in to comment.