Post

Replies

Boosts

Views

Activity

How to retrieve required Apple Pay parameters for PayFort payment request in Swift?
I'm integrating Apple Pay with PayFort in a Swift iOS application, and I’m currently working on preparing a valid purchase request using Apple Pay, as described in PayFort’s documentation: 🔗 https://docsbeta.payfort.com/docs/api/build/index.html?shell#apple-pay-authorization-purchase-request The documentation outlines the following required parameters: apple_data apple_signature apple_header apple_transactionId apple_ephemeralPublicKey apple_publicKeyHash apple_paymentMethod apple_displayName apple_network apple_type Optional: apple_applicationData I understand these should be derived from the PKPayment object after Apple Pay authorization, but I’m having trouble mapping everything correctly. Here’s what I’m seeing in code: payment.token // Returns something like: <PKPaymentToken: 0x28080ae80; transactionIdentifier: "..."; paymentData: 3780 bytes> payment.token.paymentData // Contains 3780 bytes of encrypted data payment.token.paymentData.base64EncodedString() // Returns a long base64 string, which at first glance seems like it could be used for apple_data, // but PayFort doesn't accept it as-is — so this value appears to be incomplete or incorrectly formatted I can successfully retrieve the following values from payment.token.paymentMethod: apple_displayName apple_network apple_type However, I’m still unsure how to extract or build the following in the format accepted by PayFort: apple_data apple_signature apple_header apple_transactionId apple_ephemeralPublicKey apple_publicKeyHash apple_paymentMethod These may be contained within the paymentData JSON, but I’m not sure how to decode it or if Apple allows decrypting it in a way that matches PayFort’s expected format. How can I correctly extract or build apple_data, apple_signature, and apple_header from the Apple Pay token? Also, how should I handle the decryption or decoding (if necessary) of paymentData to retrieve values like apple_transactionId, apple_ephemeralPublicKey, and apple_publicKeyHash? If anyone has successfully set this up or has example code that bridges Apple Pay and PayFort’s expected request format, it would be super helpful! Thanks in advance 🙏
0
0
71
Apr ’25