Apple Pay Payments
Submit customer payments initiated online or over the phone using the Payment Request. Payments will authorise and capture the funds for settlement in one step.
When using Your Payment Page
There are various stages to performing an Apple Pay payment which need to be completed in your JavaScript code as documented by Apple. Once you have checked Apple Pay is available, created an Apple Pay session and validated the merchant you can proceed to making the payment. Once the payment has been authorised Apple will provide the payment token. It will be provided in the Apple SDK session.onpaymentauthorized event. This is the token that needs to be put in the payment request to Access PaySuite. To see this in the example below please look at the paymentMethod key.
session.onpaymentauthorized = function( event ) {
var token = event.payment.token;
// The function authorise(token) will make an ajax call to the site server, which will in turn call
//the Access PaySuite service /acceptor/rest/transactions/{instId}/payment
authorise(token).done( ( response ) => {
// determine success by response from merchant server. In this example the response is outcome.status
//from the Access PaySuite api response returned to your server
var success = "SUCCESS" === response;
var authorizationResult = {
status: ( success ? ApplePaySession.STATUS_SUCCESS : ApplePaySession.STATUS_FAILURE ),
errors: []
};
session.completePayment( authorizationResult ); // hides the Apple Pay sheet
if ( success ) {
showConfirmation( response );
} else {
showDecline( data );
}
} );
};API examples
Process payment
POST /acceptor/rest/transactions/{instId}/payment{
"transaction": {
"currency": "GBP",
"amount": 1000.0,
"description": "Sample Transaction",
"merchantRef": "mer_txn_1234556",
"commerceType": "ECOM",
"channel": "WEB"
},
"paymentMethod": {
"applepay": {
"paymentData" : {
"version" : "EC_v1",
"data" : "3+f4oOTwPa6f1UZ6tG...CE=",
"signature" : "MIAGCSqGSIb3DQ...AAAA==",
"header": {
"applicationData" : "DYkwEK...Yu==",
"ephemeralPublicKey" : "MFkwEK...Md==",
"publicKeyHash" : "l0CnXdMv...D1I=",
"transactionId" : "32b...4f3"
}
},
"paymentMethod" : {
"displayName" : "Visa 1234",
"network" : "Visa",
"type" : "debit"
},
"transactionIdentifier" : "32b...4f3"
},
"billingAddress": {
"line1": "1 Some Street",
"city": "Metropolis",
"postcode": "AA1 1AA",
"countryCode": "GBR"
}
},
"customer": {
"merchantRef": "mer_cust_131241413",
"displayName": "John Smith",
"billingAddress": {
"line1": "1 Some Street",
"city": "Metropolis",
"postcode": "AA1 1AA",
"countryCode": "GBR"
},
"email": "[email protected]",
"telephone": "0123 456 789",
"defaultCurrency": "GBP",
"ip": "212.58.253.67"
}
}curl -X POST "{targetEnvironmentPath}/acceptor/rest/transactions/{instId}/payment" \
-u "{apiUser}:{apiPassword}" \
-H "Content-Type: application/json" \
-d '{
"transaction": {
"currency": "GBP",
"amount": 1000.0,
"description": "Sample Transaction",
"merchantRef": "mer_txn_1234556",
"commerceType": "ECOM",
"channel": "WEB"
},
"paymentMethod": {
"applepay": {
"paymentData" : {
"version" : "EC_v1",
"data" : "3+f4oOTwPa6f1UZ6tG...CE=",
"signature" : "MIAGCSqGSIb3DQ...AAAA==",
"header": {
"applicationData" : "DYkwEK...Yu==",
"ephemeralPublicKey" : "MFkwEK...Md==",
"publicKeyHash" : "l0CnXdMv...D1I=",
"transactionId" : "32b...4f3"
}
},
"paymentMethod" : {
"displayName" : "Visa 1234",
"network" : "Visa",
"type" : "debit"
},
"transactionIdentifier" : "32b...4f3"
},
"billingAddress": {
"line1": "1 Some Street",
"city": "Metropolis",
"postcode": "AA1 1AA",
"countryCode": "GBR"
}
},
"customer": {
"merchantRef": "mer_cust_131241413",
"displayName": "John Smith",
"billingAddress": {
"line1": "1 Some Street",
"city": "Metropolis",
"postcode": "AA1 1AA",
"countryCode": "GBR"
},
"email": "[email protected]",
"telephone": "0123 456 789",
"defaultCurrency": "GBP",
"ip": "212.58.253.67"
}
}'HTTP/1.1 201
{
"processing": {
"authResponse": {
"statusCode": "00",
"message": "ACQUIRER OK",
"authCode": "100000",
"gatewayReference": "5896345970448890-PASS",
"gatewaySettlement": "2014-10-29",
"gatewayCode": "0900.000.000",
"gatewayMessage": "Transaction succeeded",
"avsAddressCheck": "FULL_MATCH",
"avsPostcodeCheck": "FULL_MATCH",
"status": "AUTHORISED"
},
"route": "PAYON"
},
"paymentMethod": {
"applepay": {
"cardType": "VISA_DEBIT",
"cardUsageType": "DEBIT",
"cardScheme": "VISA"
},
"billingAddress": {
"line1": "1 Some Street",
"city": "Metropolis",
"postcode": "AA1 1AA",
"country": "United Kingdom",
"countryCode": "GBR"
},
"paymentClass": "CARD"
},
"transaction": {
"transactionId": "13501566687",
"merchantRef": "mer_txn_1234556",
"status": "SUCCESS",
"type": "PAYMENT",
"amount": 1000,
"consumerSpend": 1000,
"currency": "GBP",
"transactionTime": "2014-01-06T12:25:30.902Z",
"receivedTime": "2014-01-06T12:25:30.902Z",
"channel": "WEB",
"customerInitiated": true,
"stage": "COMPLETE"
},
"outcome": {
"status": "SUCCESS",
"reasonCode": "S100",
"reasonMessage": "Authorised"
}
}More information about objects in the request body can be found in the Apple documentation — https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/1778020-onpaymentauthorized.
When using the PaySuite Payment Page
Create a hosted session for the payment, then send your customer to the redirectUrl we return. Apple Pay is offered on the hosted payment page once your account and skin support it — see Getting started with Apple Pay.
PaySuite Payment Page examples
Submit a payment
POST /hosted/rest/sessions/{instId}/payments{
"session": {
"preAuthCallback": {
"url": "http://www.example.com/callback/preAuth?status=SUSPEND",
"format": "REST_XML"
},
"returnUrl": {
"url": "http://www.example.com/transactionResult?MERCHANTREF=761585761585"
}
},
"transaction": {
"merchantReference": "761585761585",
"money": {
"amount": {
"fixed": 100
},
"currency": "GBP"
}
},
"customer": {
"identity": {
"merchantCustomerId": "1111111111111"
},
"details": {
"name": "given1 Family1",
"address": {
"line1": "matched",
"line2": "initialCustomer1AddresssLine2",
"city": "initalCustomer1City",
"region": "initalCustomer1Region",
"postcode": "AVS111",
"countryCode": "GBR"
},
"telephone": "0044111111111",
"emailAddress": "[email protected]",
"ipAddress": "1.1.1.1",
"defaultCurrency": "GBP"
}
},
"financialServices": {
"dateOfBirth": "19870818",
"surname": "Smith",
"accountNumber": "123ABC",
"postCode": "BS20"
}
}curl -X POST "{targetEnvironmentPath}/hosted/rest/sessions/{instId}/payments" \
-u "{apiUser}:{apiPassword}" \
-H "Content-Type: application/json" \
-d '{
"session": {
"preAuthCallback": {
"url": "http://www.example.com/callback/preAuth?status=SUSPEND",
"format": "REST_XML"
},
"returnUrl": {
"url": "http://www.example.com/transactionResult?MERCHANTREF=761585761585"
}
},
"transaction": {
"merchantReference": "761585761585",
"money": {
"amount": {
"fixed": 100
},
"currency": "GBP"
}
},
"customer": {
"identity": {
"merchantCustomerId": "1111111111111"
},
"details": {
"name": "given1 Family1",
"address": {
"line1": "matched",
"line2": "initialCustomer1AddresssLine2",
"city": "initalCustomer1City",
"region": "initalCustomer1Region",
"postcode": "AVS111",
"countryCode": "GBR"
},
"telephone": "0044111111111",
"emailAddress": "[email protected]",
"ipAddress": "1.1.1.1",
"defaultCurrency": "GBP"
}
},
"financialServices": {
"dateOfBirth": "19870818",
"surname": "Smith",
"accountNumber": "123ABC",
"postCode": "BS20"
}
}'HTTP/1.1 201 Created
{
"sessionId": "5280f295-b7ea-4eaa-8e3b-ebd6fa67cc58",
"redirectUrl": "https://secure.mite.pay360.com/hosted/8f2c9ec4-f9e6-44a7-b14a-39a47d3aeb65/begin/5280f295-b7ea-4eaa-8e3b-ebd6fa67cc58",
"status": "SUCCESS"
}Retrieve session endpoint
The status of a hosted session can be retrieved while it is in use, and for a limited time (up to 1 hour) afterwards. This is the recommended way to find out the id of the transaction after the user has been returned to your site. The full details of the transaction can then be retrieved using retrieve a transaction.
Retrieve session examples
Retrieve session
GET /hosted/rest/sessions/{instId}/{sessionId}/statuscurl -X GET "{targetEnvironmentPath}/hosted/rest/sessions/{instId}/{sessionId}/status" \
-u "{apiUser}:{apiPassword}" \
-H "Accept: application/json"HTTP/1.1 200
{
"status": "SUCCESS",
"hostedSessionStatus": {
"sessionId": "SMjo-nVACrY1K8pP7Vfs-iQOF",
"context": "https://secure.mite.pay360.com/hosted",
"sessionState": "STARTED",
"transactionState": {
"transactionState": "PROCESSING"
}
}
}HTTP/1.1 200
{
"status": "SUCCESS",
"hostedSessionStatus": {
"sessionId": "SMjo-nVACrY1K8pP7Vfs-iQOF",
"context": "https://secure.mite.pay360.com/hosted",
"sessionState": "TERMINATED",
"transactionState": {
"id": "11802480907",
"transactionState": "SUCCESS"
}
}
}HTTP/1.1 404
{
"status": "FAILED",
"reasonCode": "exception.sessionState.noSession",
"reasonMessage": "Session not found"
}