# Visa In-App Provisioning
Enable push provisioning to pay wallets from client mobile app 

## Version: 1

### Servers

| URL | Description |
| --- | ----------- |
| https://sandbox.api.visa.com | Sandbox server |

---
## In-App Provisioning for Apple Pay
In-App Provisioning for Apple Pay

### [POST] /inapp/provisioning/cardData/applePay
**Create Card Data Apple Pay**

Card data for provisioning a Visa Token in ApplePay using vCardId or encrypted card as input

#### Parameters

| Name | Located in | Description | Required | Schema | Style | Explode |
| ---- | ---------- | ----------- | -------- | ------ | ----- | ------- |
| apikey | query | API key from Visa Developer Platform (VDP) | Yes | string | form | Yes |
| Content-Type | header | application/json | Yes | string | simple | No |
| x-pay-token | header | API Key-Shared Secret Authentication. Please refer to https://developer.visa.com/pages/working-with-visa-apis/x-pay-token for more details. Resource path to be used while building x-pay-token must be 'provisioning/cardData/applePay'. | Yes | string | simple | No |

#### Request Body

Create Card Data for ApplePay provisioning using vCardID or Encrypted Card.

| Required | Schema |
| -------- | ------ |
|  Yes | **application/json**: { **"nonce"**: string, **"encCard"**: string, **"vCardID"**: string, **"deviceCert"**: string, **"productType"**: string, **"signingKeyID"**: string, **"nonceSignature"**: string, **"tokenServiceProvider"**: string, <br>**Available values:** "V", "M" }<br> |

#### Responses

| Code | Description | Schema |
| ---- | ----------- | ------ |
| 200 | OK | **application/json**: { **"vCardID"**: string, **"activationData"**: string, **"encryptedPassData"**: string, **"ephemeralPublicKey"**: string, **"paymentAccountReference"**: string }<br> |
| 400 | Bad Request | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"details"**: [ { **"message"**: string, **"location"**: string } ], **"message"**: string } }<br> |
| 401 | Unauthorized | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |
| 403 | Forbidden | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |
| 422 | Name on Card not Available. The card referenced in this request is already enrolled but has no nameOnCard value. And, there is no Customer associated with this card so that the nameOnCard can not be derived from Customer name. | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |
| 502 | Bad Gateway | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |
| 503 | Service Unavailable | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |
| 504 | Gateway Timeout | **application/json**: { **"errorResponse"**: { **"reason"**: string, **"status"**: integer, **"message"**: string } }<br> |

---
### Schemas

#### ValidationErrorResponse Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| errorResponse | { **"reason"**: string, **"status"**: integer, **"details"**: [ { **"message"**: string, **"location"**: string } ], **"message"**: string } |  | No |

#### ApplePayProvisioningResponse Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| vCardID | string | Visa-defined unique ID of the card to produce the provisioning card data for. | Yes |
| activationData | string | Activation data consisting of encrypted nonce, noncesignature, and authCode in base64 format. | Yes |
| encryptedPassData | string | Authentication data consisting of encrypted PAN, expiry and datetime in base64 format. | Yes |
| ephemeralPublicKey | string | VISA.ECC.ePK generated while creating MBPAD encryptedInformation. EC point with P-256 curve and uncompressed format. Base64 format. | Yes |
| paymentAccountReference | string | Payment Account Reference (PAR) is a unique reference value associated with a specific cardholder PAN. | No |

#### ApplePayProvisioningRequest Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| nonce | string | 32 digit random number generated by Apple. | Yes |
| encCard | string | <div> <p><code>Conditional.</code> </p>   <p> Either of <code>vCardId</code> or <code>encCard</code> is required.</p>  <p> <code>vCardId</code> will take precedence in case both <code>vCardId</code> and <code>encCard</code> is part of the request body.</p>   <div>   <p>Encrypted <code>CardInfo</code></p> <h3>Example</h3> <pre><code>{   "accountNumber": "4000000000000000",   "nameOnCard": "Digital Issuance",   "cvv2": "123",   "expirationDate": {       "month": "01",       "year": "2021"   },   "billingAddress": {     "name": "Digital Issuance",     "line1": "12301 Research Boulevard",     "line2": "Research Boulevard",     "line3": "Visa USA",     "city": "Austin",     "state": "TX",     "countryCode": "US",     "postalCode": "78759"   } } </code></pre> <h3>CardInfo Schema</h3> <table style="border-collapse: collapse;"> <thead> <tr><th>Field</th><th>Type</th><th>Description</th></tr> </thead> <tbody> <tr><td>accountNumber</td><td>string<br>required<br>minLength: 12<br>maxLength: 18</td><td>PAN (Primary Account Number) of the card to be provisioned or enrolled</td></tr> <tr><td>paymentAccountReference</td><td>string<br>optional</td><td>A Payment Account Reference (PAR) is a unique reference value associated with a specific cardholder PAN</td></tr> <tr><td>cvv2</td><td>string<br>conditional<br>minLength: 3<br>maxLength: 3</td><td>CVV2 value associated with the PAN on the card</td></tr> <tr><td>nameOnCard</td><td>string<br>conditional<br>minLength: 0<br>maxLength: 256</td><td>The full name on the card associated with the issued/enrolled card</td></tr> <tr><td>expirationDate</td><td><code>ExpirationDate</code><br>required</td><td>Card’s expiration date</td></tr> <tr><td>billingAddress</td><td><code>Address</code><br>optional</td><td>Billing address associated with the card</td></tr> </tbody> </table> <h3>ExpirationDate Schema</h3> <table style="border-collapse: collapse;"> <thead> <tr><th>Field</th><th>Type</th><th>Description</th></tr> </thead> <tbody> <tr><td>month</td><td>string<br>required<br>minLength: 2<br>maxLength: 2</td><td>The month that the card is set to expire</td></tr> <tr><td>year</td><td>string<br>required<br>minLength: 4<br>maxLength: 4</td><td>The year that the card is set to expire</td></tr> </tbody> </table> <h3>Address Schema</h3> <table style="border-collapse: collapse;"> <thead> <tr><th>Field</th><th>Type</th><th>Description</th></tr> </thead> <tbody> <tr><td>name</td><td>string<br>optional<br>maxLength: 100</td><td>The name of the addressee</td></tr> <tr><td>line1</td><td>string<br>optional<br>maxLength: 140</td><td>First line of the address</td></tr> <tr><td>line2</td><td>string<br>optional<br>maxLength: 140</td><td>Second line of the address</td></tr> <tr><td>line3</td><td>string<br>optional<br>maxLength: 140</td><td>Third line of the address</td></tr> <tr><td>city</td><td>string<br>optional<br>maxLength: 100</td><td>Name of the city</td></tr> <tr><td>state</td><td>string<br>conditional</td><td>Second part of the “country-subdivision” (State or Province) code in ISO 3166-2 format of the country, eg \\"TX\\"</td></tr> <tr><td>postalCode</td><td>string<br>optional<br>minLength: 3<br>maxLength: 16</td><td>The postal code associated with the address, such as zip code</td></tr> <tr><td>countryCode</td><td>string<br>required</td><td>ISO 3166-1 alpha-2 formatted country code associated with the address</td></tr> </tbody> </table> </div>  | No |
| vCardID | string | <div> <p><code>Conditional.</code> </p>   <p> Either of <code>vCardId</code> or <code>encCard</code> is required.</p> <p>Visa-defined unique ID of the card to produce the ApplePay provisioning card data for. <code>vCardId</code> will take precedence in case both <code>vCardId</code> and <code>encCard</code> is part of the request body.  </p></div>   | No |
| deviceCert | string | Apple device X.509 certificates received from mobile application. | Yes |
| productType | string | Specifies the product type for push provisioning. This value is provided by Apple's team based on the card program. If not specified, it defaults to the Visa/Mastercard default productType value. Visa's default productType is <code>DEFAULT_VISA</code> and Mastercard's default productType is <code>DEFAULT_MASTERCARD</code>. | No |
| signingKeyID | string | Token service provider specific signing key identifier | No |
| nonceSignature | string | Signature signed by Apple on nonce in SE. | Yes |
| tokenServiceProvider | string, <br>**Available values:** "V", "M" | Indicates which token service provider will process the card data generated for provisioning. The default value is "V".<br>*Enum:* `"V"`, `"M"` | No |

#### Error Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| reason | string | Reason Code for the error condition. Error handling business logic should be driven by this field. | No |
| status | integer | 3-digit HTTP Status Code | No |
| message | string | Message describing the error condition with additional information wherever applicable. | No |

#### ErrorDetails Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| message | string | The specific error for this field. | No |
| location | string | The value of this field is using XPATH expression to point to the field, which failed validation. | No |

#### ValidationError Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| reason | string | Reason Code for the error condition. Error handling business logic should be driven by this field. | No |
| status | integer | 3-digit HTTP Status Code | No |
| details | [ { **"message"**: string, **"location"**: string } ] | Array of fields - Data validation errors should use this field to specify which fields failed the validation using location field. | No |
| message | string | Message describing the error condition with additional information wherever applicable. | No |

#### ErrorResponse Schema

| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| errorResponse | { **"reason"**: string, **"status"**: integer, **"message"**: string } |  | No |
