Apple Pay
Note that at the moment Apple Pay payments are only supported with the Gestpay (Axerve) provider.
Gestpay
Making a payment
The service is expecting a JSON representation of a ApplePayPKPaymentToken described as below:
{
paymentData: {
data: string,
signature: string,
version: string,
header: {
ephemeralPublicKey: string,
publicKeyHash: string,
transactionId: string,
}
},
transactionIdentifier: string
paymentMethod: {
network: string,
type: string,
displayName: string
}
}
How to retrieve the payment token
Few steps are required in order to obtain a payment dictionary compliant to the structure expected above.
After making a PKPaymentRequest using Apple's PassKit framework, you can retrieve the PKPayment object from the PKPaymentAuthorizationViewController didAuthorizePayment completion callback.
-
Create a Foundation object from the given
payment.token.paymentDatadata:NSData *paymentData = payment.token.paymentData;NSError *serializationError = nil;id dict = [NSJSONSerialization JSONObjectWithData:paymentData options:NSJSONReadingFragmentsAllowed error:&serializationError];// error handling with serializationError -
Create the payment method dictionary:
// ...NSDictionary *paymentMethodDictionary = @{@"network": payment.token.paymentMethod.network,@"type": [NSNumber numberWithUnsignedLongLong:payment.token.paymentMethod.type],@"displayName":payment.token.paymentMethod.displayName};// ... -
Create the payment information dictionary and convert it as JSON data:
// ...NSError *dataWritingError = nil;NSDictionary *paymentDictionary = @{@"paymentData":dict,@"transactionIdentifier":payment.token.transactionIdentifier,@"paymentMethod":paymentMethodDictionary};NSData *data = [NSJSONSerialization dataWithJSONObject:paymentDictionary options:NSJSONWritingFragmentsAllowed error:&dataWritingError];// error handling with dataWritingError -
Initialize a NSString with the data to be used as token to be provided to the
/payendpoint:// ...NSString *paymentDataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];// ...