Integrating Apple Pay into iOS App: Quick Steps

 
PUNE, India - Sept. 4, 2023 - PRLog -- Make a merchant ID

To create a Merchant ID, start by generating an App ID. Head over to developer.apple.com and log in to your developer account. Next, access the "Certificates, Identifiers, & Profiles" section and proceed to the Identifier tab, where you should choose the App ID option. Ensure you check the Apple Pay box, then click Continue and follow the prompts to complete the App ID creation process, which is essential for managing iOS device IDs effectively.

Set up apple pay capabilities in Xcode

Once you have made your Merchant ID, you need to open your project in the Xcode & select Capabilities. Now turn Apple Pay on & add your Merchant ID and refresh the page. Once you have done it, on the developer portal, a Merchant ID list will be visible.

Make a sandbox user in iTunes connect

You're almost in the middle stage of the Apple Pay implementation process. After completing the above steps successfully, you need to make a Gmail account. For this, go to itunesconnect.apple.com & select the "Users and Roles" option.

Add a test card

In this step, you have to modify your iPhone region. All you need to do is logout from the current iCloud account & login with the sandbox user details. Now, you have to add a test card, for instance:
  • Funding Primary Account Number or FPAN: 1234 5678 8765 4321
  • Expiry Date: 09/2022
  • CVC: 123
Create a payment request

Next, you have to make a proper payment request for the project. For this, you can add any kind of button from a storyboard to a ViewController. After that, you need to connect IBAction with ViewController.swift. For effectively using Apple Pay, properly add Import PassKit to the ViewController. Once you have inserted it, set up a payment request for the purchaseItem.

@IBAction func purchaseItem(_ sender: Any) {

let request = PKPaymentRequest()

request.merchantIdentifier = "merchant.net.mobindustry.likeMe"

request.supportedNetworks = [PKPaymentNetwork.visa, PKPaymentNetwork.masterCard, PKPaymentNetwork.amex]

request.merchantCapabilities = PKMerchantCapability.capability3DS

request.countryCode = "US"

request.currencyCode = "USD"

request.paymentSummaryItems = [

PKPaymentSummaryItem(label: "Some Product", amount: 9.99)

]

let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)

self.present(applePayController!, animated: true, completion: nil)

}

Step 6: Manage the output

You have to insert "applePayController?.delegate = self" to purchaseItem(). Now, you have to create the following extension:

extension PaymentViewController:

PKPaymentAuthorizationViewControllerDelegate{

func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {

controller.dismiss(animated: true, completion: nil)

}

func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, handler completion: @escaping (PKPaymentAuthorizationResult) -> Void) {

completion(PKPaymentAuthorizationResult(status: PKPaymentAuthorizationStatus.success, errors: []))

}

}
https://www.sphinx-solution.com/portfolio-item/checkd/
End
Source: » Follow
Email:***@gmail.com
Tags:Apple Pay Development
Industry:Software
Location:Pune - Maharashtra - India
Account Email Address Verified     Account Phone Number Verified     Disclaimer     Report Abuse



Like PRLog?
9K2K1K
Click to Share