Changeset 202655 in webkit


Ignore:
Timestamp:
Jun 29, 2016 3:41:15 PM (8 years ago)
Author:
andersca@apple.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202647 r202655  
     12016-06-29  Anders Carlsson  <andersca@apple.com>
     2
     3        Add "type" and "paymentPass" properties in PaymentMethod
     4        https://bugs.webkit.org/show_bug.cgi?id=159278
     5        rdar://problem/26999112
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Modules/applepay/cocoa/PaymentMethodCocoa.mm:
     10        (WebCore::toString):
     11        (WebCore::toDictionary):
     12
    1132016-06-29  Nan Wang  <n_wang@apple.com>
    214
  • trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm

    r202309 r202655  
    3434namespace WebCore {
    3535
     36static NSString *toString(PKPaymentPassActivationState paymentPassActivationState)
     37{
     38    switch (paymentPassActivationState) {
     39    case PKPaymentPassActivationStateActivated:
     40        return @"activated";
     41    case PKPaymentPassActivationStateRequiresActivation:
     42        return @"requiresActivation";
     43    case PKPaymentPassActivationStateActivating:
     44        return @"activating";
     45    case PKPaymentPassActivationStateSuspended:
     46        return @"suspended";
     47    case PKPaymentPassActivationStateDeactivated:
     48        return @"deactivated";
     49    default:
     50        return nil;
     51    }
     52}
     53
     54static RetainPtr<NSDictionary> toDictionary(PKPaymentPass *paymentPass)
     55{
     56    auto result = adoptNS([[NSMutableDictionary alloc] init]);
     57
     58    [result setObject:paymentPass.primaryAccountIdentifier forKey:@"primaryAccountIdentifier"];
     59    [result setObject:paymentPass.primaryAccountNumberSuffix forKey:@"primaryAccountNumberSuffix"];
     60    if (NSString *deviceAccountIdentifier = paymentPass.deviceAccountIdentifier)
     61        [result setObject:deviceAccountIdentifier forKey:@"deviceAccountIdentifier"];
     62    if (NSString *deviceAccountNumberSuffix = paymentPass.deviceAccountNumberSuffix)
     63        [result setObject:deviceAccountNumberSuffix forKey:@"deviceAccountNumberSuffix"];
     64    if (NSString *activationState = toString(paymentPass.activationState))
     65        [result setObject:activationState forKey:@"activationState"];
     66
     67    return result;
     68}
     69
     70static NSString *toString(PKPaymentMethodType paymentMethodType)
     71{
     72    switch (paymentMethodType) {
     73    case PKPaymentMethodTypeDebit:
     74        return @"debit";
     75    case PKPaymentMethodTypeCredit:
     76        return @"credit";
     77    case PKPaymentMethodTypePrepaid:
     78        return @"prepaid";
     79    case PKPaymentMethodTypeStore:
     80        return @"store";
     81    default:
     82        return nil;
     83    }
     84}
     85
    3686RetainPtr<NSDictionary> toDictionary(PKPaymentMethod *paymentMethod)
    3787{
     
    4393    if (NSString *network = paymentMethod.network)
    4494        [result setObject:network forKey:@"network"];
     95
     96    if (NSString *paymentMethodType = toString(paymentMethod.type))
     97        [result setObject:paymentMethodType forKey:@"type"];
     98
     99    if (PKPaymentPass *paymentPass = paymentMethod.paymentPass)
     100        [result setObject:toDictionary(paymentPass).get() forKey:@"paymentPass"];
    45101
    46102    return result;
Note: See TracChangeset for help on using the changeset viewer.