---
title: "addPaymentPassViewController(_:generateRequestWithCertificateChain:nonce:nonceSignature:completionHandler:)"
framework: passkit
role: symbol
role_heading: Instance Method
path: "passkit/pkaddpaymentpassviewcontrollerdelegate/addpaymentpassviewcontroller(_:generaterequestwithcertificatechain:nonce:noncesignature:completionhandler:)"
---

# addPaymentPassViewController(_:generateRequestWithCertificateChain:nonce:nonceSignature:completionHandler:)

Asks the delegate to create an add payment request.

## Declaration

```swift
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping @Sendable (PKAddPaymentPassRequest) -> Void)
```

```swift
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data) async -> PKAddPaymentPassRequest
```

## Parameters

- `controller`: The view controller asking for the add payment request.
- `certificates`: An array of NSData objects. Each object contains a DER encoded X.509 certificate, with the leaf first and root last. You must download the root CA to validate the entire chain.
- `nonce`: A one-time nonce value generated by Apple’s servers. This nonce must be included in the add payment request’s encrypted data.
- `nonceSignature`: The device-specific signature for the nonce.This signature must be included in the add payment request’s encrypted data.
- `handler`: A completion handler. Call this block after you have created your add payment request.

## Discussion

Discussion This method provides the data needed to create an add payment request. Pass the certificate chain to the issuer server. The server returns an encrypted JSON file containing the card data. After you receive the encrypted data, create a add payment request and call the handler. For more information on the encrypted card data, see encryptedPassData in PKAddPaymentPassRequest. important: Do not encrypt the card data on the device. You should encrypt the data on your server, and then pass the encrypted data to the device.

## See Also

### Requesting to add payment cards to Apple Pay

- [PKAddPaymentPassRequest](passkit/pkaddpaymentpassrequest.md)
- [addPaymentPassViewController(_:didFinishAdding:error:)](passkit/pkaddpaymentpassviewcontrollerdelegate/addpaymentpassviewcontroller(_:didfinishadding:error:).md)
