Title: [202655] trunk/Source/WebCore
- Revision
- 202655
- Author
- ander...@apple.com
- Date
- 2016-06-29 15:41:15 -0700 (Wed, 29 Jun 2016)
Log Message
Add "type" and "paymentPass" properties in PaymentMethod
https://bugs.webkit.org/show_bug.cgi?id=159278
rdar://problem/26999112
Reviewed by Dean Jackson.
* Modules/applepay/cocoa/PaymentMethodCocoa.mm:
(WebCore::toString):
(WebCore::toDictionary):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (202654 => 202655)
--- trunk/Source/WebCore/ChangeLog 2016-06-29 22:34:03 UTC (rev 202654)
+++ trunk/Source/WebCore/ChangeLog 2016-06-29 22:41:15 UTC (rev 202655)
@@ -1,3 +1,15 @@
+2016-06-29 Anders Carlsson <ander...@apple.com>
+
+ Add "type" and "paymentPass" properties in PaymentMethod
+ https://bugs.webkit.org/show_bug.cgi?id=159278
+ rdar://problem/26999112
+
+ Reviewed by Dean Jackson.
+
+ * Modules/applepay/cocoa/PaymentMethodCocoa.mm:
+ (WebCore::toString):
+ (WebCore::toDictionary):
+
2016-06-29 Nan Wang <n_w...@apple.com>
AX: Crash in WebCore::Document::focusNavigationStartingNode(WebCore::FocusDirection) const + 128
Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm (202654 => 202655)
--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm 2016-06-29 22:34:03 UTC (rev 202654)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm 2016-06-29 22:41:15 UTC (rev 202655)
@@ -33,6 +33,56 @@
namespace WebCore {
+static NSString *toString(PKPaymentPassActivationState paymentPassActivationState)
+{
+ switch (paymentPassActivationState) {
+ case PKPaymentPassActivationStateActivated:
+ return @"activated";
+ case PKPaymentPassActivationStateRequiresActivation:
+ return @"requiresActivation";
+ case PKPaymentPassActivationStateActivating:
+ return @"activating";
+ case PKPaymentPassActivationStateSuspended:
+ return @"suspended";
+ case PKPaymentPassActivationStateDeactivated:
+ return @"deactivated";
+ default:
+ return nil;
+ }
+}
+
+static RetainPtr<NSDictionary> toDictionary(PKPaymentPass *paymentPass)
+{
+ auto result = adoptNS([[NSMutableDictionary alloc] init]);
+
+ [result setObject:paymentPass.primaryAccountIdentifier forKey:@"primaryAccountIdentifier"];
+ [result setObject:paymentPass.primaryAccountNumberSuffix forKey:@"primaryAccountNumberSuffix"];
+ if (NSString *deviceAccountIdentifier = paymentPass.deviceAccountIdentifier)
+ [result setObject:deviceAccountIdentifier forKey:@"deviceAccountIdentifier"];
+ if (NSString *deviceAccountNumberSuffix = paymentPass.deviceAccountNumberSuffix)
+ [result setObject:deviceAccountNumberSuffix forKey:@"deviceAccountNumberSuffix"];
+ if (NSString *activationState = toString(paymentPass.activationState))
+ [result setObject:activationState forKey:@"activationState"];
+
+ return result;
+}
+
+static NSString *toString(PKPaymentMethodType paymentMethodType)
+{
+ switch (paymentMethodType) {
+ case PKPaymentMethodTypeDebit:
+ return @"debit";
+ case PKPaymentMethodTypeCredit:
+ return @"credit";
+ case PKPaymentMethodTypePrepaid:
+ return @"prepaid";
+ case PKPaymentMethodTypeStore:
+ return @"store";
+ default:
+ return nil;
+ }
+}
+
RetainPtr<NSDictionary> toDictionary(PKPaymentMethod *paymentMethod)
{
auto result = adoptNS([[NSMutableDictionary alloc] init]);
@@ -43,6 +93,12 @@
if (NSString *network = paymentMethod.network)
[result setObject:network forKey:@"network"];
+ if (NSString *paymentMethodType = toString(paymentMethod.type))
+ [result setObject:paymentMethodType forKey:@"type"];
+
+ if (PKPaymentPass *paymentPass = paymentMethod.paymentPass)
+ [result setObject:toDictionary(paymentPass).get() forKey:@"paymentPass"];
+
return result;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes