Apple Pay using the API

To work through the API, the merchant needs to register in the Apple system and be able to decrypt data that will later need to be transmitted to our system

Integration can only be carried out in a production environment

  • TerminalID – store ID
  • Customer ID – Customer ID
  • Client secret – Secret key

Data for test payments:

urlhttps://test-epay.homebank.kz
emailepay@halykbank.kz
passwordXZG1E@Mm
Client IDTest
clientSecretyF587AV9Ms94qN2QShFzVR3vFnWkhjbAK3sG
Terminal ID67e34d63-102f-4bd1-898e-370781d0074d

Getting a token for making a payment (for each operation, you need to receive and use the original token)

A MESSAGE WITH A PROD URL https://epay-oauth.homebank.kz/oauth2/token
``

### Request

``
grant_type: "client_credentials"
scope: "webapi usermanagement email_send statement verification payment statistics"
client_id: "Client ID"
client_secret: "Client secret"
Invoice ID: "Order number"
amount: 100
currency: "KZT"
terminal: "67e34d63-102f-4bd1-898e-370781d0074d"
``

### Response

``
{
"access_token": "DCEB8O_ZM5U7SO_T_U5EJQ",
"expires_in": 7200,
"scope": "webapi usermanagement email_send statement for checking payment statistics",
"token_type": "Bearer"
}
``

## Incoming parameters

| Field name | Description | Required/optional |
| -------- | -------- | -------- |
| amount | payment amount | required |
| currency| currency | required |
| name | cardholder name | required |
| cryptogram | encrypted payment card parameters | required |
| InvoiceID | Order number in the store | required |
| description | This field contains information about the goods or services for which payment is made | 
| Account ID | Customer ID in the merchant's system or other additional parameter at the merchant's discretion | optional |
| email | customer email | optional |
| phone | customer's phone | optional |
| Link to the publication | Link to send the authorization result to the store. | optional |
| failurePostLink | Link for sending an unsuccessful authorization result or error information to the store. | optional |
| cardSave| parameter saving the card, true - save the card, false - do not save, logical type | required |

## Cryptogram preparation

Cryptogram structure:
``
{
hpan string
  ExpDate string
cvc string
terminalId string
}

example:
{
"hpan":"AppleToken","ExpDate":"DDMMYY","cvc":"","terminalId":"67e34d63-102f-4bd1-898e-370781d0074d"
}


The structure must be encrypted using a public and RSA key, which is available at https://epay-api.homebank.kz/public.rsa

Making a payment

URL OF THE PUBLICATION https://epay-api.homebank.kz/payment/cryptopay

Request

Request header:

Content type: application/json Authorization: Bearer DCEB8O_ZM5U7SO_T_U5EJQ

Request body: `` { "amount": 10.0, "currency": "KZT", "name": "Arman Ali", "cryptogramApplePay": "Decrypted cryptogram from Apple", "cryptogram": "jkasDHJIHUIHDUIOHUI23HDUI2NUIBN2I23NDJIN2OIEN2IODN0I23J0M230IDJMI023MDKDMKLSFJSDF651454564SDFIOHF984N98HFIJ2HF " "InvoiceID": "163637162556226", "description": "Payment via ApplePay", "Account ID": "", "email": "armanali@gmail.com ", "phone": "+77771232380", "Backlink": "http://example/backLink ", "failureBackLink": "http://example/failureBackLink ", "postLink": "http://example/postLink ", "failurePostLink": "http://example/failurePostLink ", "PaymentType": "ApplePay" }


### Result of payment operation without 3DSecure


HTTP/1.1 200 OK

{ "id": "7943816b-58a8-47f6-a11e-67b63c4228c7", "amount": 100, "currency": "KZT", "InvoiceID": "938290483290", "AccountId": "uuid000001", "phone": "77777777777", "email":"jj@example.com ", "description":"test payment", "link":"114537489258", "language": "Russian" } ``