Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PassKit] Add support Xcode15 Beta 7 #19139

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1443,6 +1443,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; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fun fact, 'TMoney' was my fake rapper name in Jr. Highschool

}

#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
tj-devel709 marked this conversation as resolved.
Show resolved Hide resolved

[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
Loading