Loading Apple Pay Shipping Address No Street

I’m trying to get a shipping address extracted from the ABRecordRef provided by Apple. I have the following but my street is always returning as nil:

ABMultiValueRef addresses = ABRecordCopyValue(abRecordRef, kABPersonAddressProperty);

for (CFIndex index = 0; index < ABMultiValueGetCount(addresses); index++)
    CFDictionaryRef properties = ABMultiValueCopyValueAtIndex(addresses, index);
    NSString *street = [(__bridge NSString *)(CFDictionaryGetValue(properties, kABPersonAddressStreetKey)) copy];
    NSLog(@"street: %@", street);

What am I doing wrong?

  • What's the best way to create an ios app on windows 7?
  • Finding unused files in Xcode
  • How to have a UIScrollView scroll and have a gesture recognizer?
  • Swift iOS -UIImagePicker's Photo Library Is Presented On Simulator But Crashes (won't present) On Actual Device While Running Xcode
  • How to export Core Data entity to a CSV file
  • How do I set title for UIBarButtonItem?
  • Even when debugging with the following:

    - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                                    completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *methods, NSArray *items))completion
        NSLog(@"%@", ABRecordCopyValue(customShippingAddress, kABPersonAddressProperty);
        completion(PKPaymentAuthorizationStatusSuccess, ..., ...);

    I get this with no street:

    ABMultiValueRef 0x17227fbc0 with 1 value(s)
        0: Shipping (0x17227fa00) - {
        City = "Marina del Rey";
        Country = "United States";
        State = California;
        ZIP = 90292;
    } (0x172447440)


    I’m also experiencing issues with accessing names and phone attributes:

    NSString *name = (__bridge_transfer NSString *)(ABRecordCopyCompositeName(abRecordRef));
    NSString *fname = (__bridge_transfer NSString *)ABRecordCopyValue(abRecordRef, kABPersonFirstNameProperty);
    NSString *lname = (__bridge_transfer NSString *)ABRecordCopyValue(abRecordRef, kABPersonFirstNameProperty);
    if (!name && fname && lname) name = [NSString stringWithFormat:@"%@ %@", fname, lname]; 
    NSLog(@"name: %@", name); // nil

    This is how the PKPaymentRequest is being created:

    PKPaymentRequest *pr = [[PKPaymentRequest alloc] init];    
    [pr setMerchantIdentifier:@"********"];
    [pr setCountryCode:@"US"];
    [pr setCurrencyCode:@"USD"];
    [pr setMerchantCapabilities:PKMerchantCapability3DS];
    [pr setSupportedNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard]];
    [pr setPaymentSummaryItems:[self paymentSummaryItems]];
    [pr setRequiredBillingAddressFields:PKAddressFieldAll];
    [pr setRequiredShippingAddressFields:PKAddressFieldAll];
    [pr setShippingMethods:[self supportedShippingMethods]];

    Solutions Collect From Internet About “Loading Apple Pay Shipping Address No Street”

    Turns out Apple’s docs on this weren’t that great but the issue is that in the delegate callback for paymentAuthorizationViewController:didSelectShippingAddress:completion: a partial address is always returned. The fix is to also set it in the callback from:

    - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                           didAuthorizePayment:(PKPayment *)payment
                                    completion:(void (^)(PKPaymentAuthorizationStatus))completion
        // Use this instead.
        [payment shippingAddress];

    I also removed a call to setting the required billing addresses (maybe a separate bug).