Go to: https://cainluo.github.io/14739456388212.html


The author testimonials

I have already written a payment article about **WeChat SDK, then we will continue to study the next payment SDK, this time is national payment software AliPay, let’s see how to integrate AliPay SDK**. Finally: If you have better suggestions or dissatisfaction with this article, please contact me, I will refer to your opinions and then modify, when contacting me, please note AliPay SDK if you feel good, I hope you can also reward ~ hee hee ~ WISH you a happy learning ~ thank you ~


Introduction to the

As for why so many people like to use Alipay, I will not explain it here. We all understand it. However, due to the development of Alibaba, Alipay is gradually integrated with Ant Financial. Even the name of the open platform was changed to ** Ant Financial Open Platform **, but no matter what, Alipay is the most secure in the industry.


The preparatory work

In fact, the integration of AliPay SDK and WeChat SDK is somewhat similar, even the application of business ID**, **App ID application, the process is similar, I will not explain the details here, you can go to AliPay business service platform for understanding.


Download the SDK package

Due to the integration of Ant Financial and Alipay, even the SDK resources have been changed, you can go to ** open platform-document center ** to find resources to download.


Let’s go on with this nonsense

After downloading the SDK package, we went to the previous payment project to create our new project, named “AliPay-Objective-C”, and then we could continue integrating AliPay SDK**.


The configuration file

Now we have established the project, and like integrating **WeChat SDK, we need to configure the project, so that we can make AliPay SDK work normally. Now let’s open the project’s info.plist ** file and add some configuration.


Adding a dependency package

Like **WeChat SDK**, **AliPay SDK also needs to import a dependency package, but this dependency package is more than the WeChat SDK**, which is more painful.

  • UIKit.framework
  • CoreMotion.framework
  • CFNetWork.framework
  • Foundation.framework
  • CoreGraphics.framework
  • CoreText.framework
  • QuartzCore.framework
  • CoreTelephony.framework
  • SystemConfiguration.framework
  • libz.tbd
  • libc++.tbd

These are all required dependency libraries, which are really painful.


Register App ID

Since **AliPay SDK does not need to be registered in the appdelegate. m file, we ignore the step of registering App ID**.


Layout UI

The UI layout is just like the **WeChat SDK, just drag a UIButton and add an Action event.


Attention!!!!!!

Due to the AliPay revision, if the SDK of the old version needs to be updated to the latest, you must read the interface documentation well, because two additional libraries and some dependent signature files need to be added here, and these two libraries can be found in the resource package of AliPay.

Drag these dependency files into our project so that we can complete development normally


To integrate the SDK

All the preparatory work has been done before, now the focus, let us see how to realize alipay payment!

Then, we need to drag two important files into the project: ** AlipaysdK. bundle and alipaysdK. framework. These two files can also be found in the resource bundle of AliPay**.

Xcode says error when compiling after import!!

**NSObject

** is not imported into the corresponding file

A plaything 芔茻, a few problems solved, and a few others replayed. a plaything: I forgot to import libcrypto. I say how seem less two things, hurriedly import into ~

After the import, there is a mistake, I am also drunk…. Hell, this is playing me…. Before importing SDK that have so trouble ah… Looking through the documentation, I found a link to add a **Header…. I’m drunk too, this link is $(SRCROOT)/(project name), I’m writing $(SRCROOT)/AliPay-Objective-C**


Realize alipay payment

AliPayDemo = AliPayDemo = AliPayDemo = AliPayDemo = AliPayDemo

After adding, don’t forget to deal with the information back from AliPay, by the way, there will be two proxy methods here, one is iOS 9** after the new method, we can move small head, see how to package will be better ~

Here we have already integrated, because alipay Demo did not provide the **App ID and private key, so we show here the effect can only be. Users will have to apply for the App ID and private key


The project address

The address of the project: https://github.com/CainRun/PayProject


The last