支付寶和微信支付的各類坑

問題1. Util/base64.h:63:21: Cannot find interface declaration for ‘NSObject’, superclass of ‘Base64’php

解決辦法:html

這是base64.h中沒有加入#import 系統庫文件致使,這個錯誤報錯方法直接想噴它一臉。報錯方式太噁心。c++

問題2.截圖告知你什麼問題微信

616981-d6540c725f3801a4.jpg

解決辦法:網絡

這個問題能夠同上的,心情好,截圖再次說明下,在 openssl_wrapper.h中#import 庫便可app

問題3.Util/openssl_wrapper.m:11:9: ‘rsa.h’ file not founddom

解決辦法:oop

(1)萬年老坑,只要你接入支付寶百分百要遇到的問題,因此習覺得常吧微信支付

(2)在Build setting中搜索search,找到Header Search Paths,添加$(PROJECT_DIR)/openssl和$(PROJECT_DIR) 以下圖:ui

(3)重要問題說三遍,這是網絡找到的到答案後繼續有一樣的坑,本身的解決方案,

Header Search Paths $(PROJECT_DIR)/ali中輸入這個

Framework Search Paths 和 Library Search Paths 繼續是$(inherited) 和 $(PROJECT_DIR)/ali

‘rsa.h’ file not found的解決方案

(4)因爲後期多項目的接入,讓我知道一個算是萬能方法吧,就是始終保持Header Search Paths 和 Library Search Paths 都能找到你導入的openssl的正確路徑便可,已嘗試多遍,是能解決以上問題(求黑)

616981-b71f879b0c85fb6a.jpg

616981-e833ce4b6bd3cb57.jpg

問題4. 這類錯不少,大概有這些:這些多是庫文件沒有導入,致使的

「_CNCopyCurrentNetworkInfo」, referenced from:

Undefined symbols for architecture x86_64:

"CNCopyCurrentNetworkInfo", referenced from:

-[APayReachability wifiInterface] in AlipaySDK

+[internal_DeviceInfo getSSIDInfo] in AlipaySDK

+[internal_DeviceInfo getNetworkInfo] in AlipaySDK

"_CNCopySupportedInterfaces", referenced from:

-[APayReachability wifiInterface] in AlipaySDK

+[internal_DeviceInfo getSSIDInfo] in AlipaySDK

+[internal_DeviceInfo getNetworkInfo] in AlipaySDK

"_CTRadioAccessTechnologyCDMA1x", referenced from:

-[AliSecXReachability networkStatusForFlags:] in AlipaySDK

"_CTRadioAccessTechnologyEdge", referenced from:

-[AliSecXReachability networkStatusForFlags:] in AlipaySDK

"_CTRadioAccessTechnologyGPRS", referenced from:

-[AliSecXReachability networkStatusForFlags:] in AlipaySDK

"_CTRadioAccessTechnologyLTE", referenced from:

-[AliSecXReachability networkStatusForFlags:] in AlipaySDK

"_OBJC_CLASS$_CMMotionManager", referenced from:

objc-class-ref in AlipaySDK

"OBJC_CLASS$_CTTelephonyNetworkInfo", referenced from:

objc-class-ref in AlipaySDK

"SCNetworkReachabilityCreateWithAddress", referenced from:

+[APayReachability reachabilityWithAddress:] in AlipaySDK

+[AliSecXReachability reachabilityWithAddress:] in AlipaySDK

"_SCNetworkReachabilityCreateWithName", referenced from:

+[APayReachability reachabilityWithHostname:] in AlipaySDK

+[AliSecXReachability reachabilityWithHostName:] in AlipaySDK

"_SCNetworkReachabilityGetFlags", referenced from:

-[APayReachability isReachable] in AlipaySDK

-[APayReachability isReachableViaWWAN] in AlipaySDK

-[APayReachability isReachableViaWiFi] in AlipaySDK

-[APayReachability connectionRequired] in AlipaySDK

-[APayReachability isConnectionOnDemand] in AlipaySDK

-[APayReachability isInterventionRequired] in AlipaySDK

-[APayReachability reachabilityFlags] in AlipaySDK

...

"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:

-[AliSecXReachability startNotifier] in AlipaySDK

"_SCNetworkReachabilitySetCallback", referenced from:

-[APayReachability startNotifier] in AlipaySDK

-[APayReachability stopNotifier] in AlipaySDK

-[AliSecXReachability startNotifier] in AlipaySDK

"_SCNetworkReachabilitySetDispatchQueue", referenced from:

-[APayReachability startNotifier] in AlipaySDK

-[APayReachability stopNotifier] in AlipaySDK

"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:

-[AliSecXReachability stopNotifier] in AlipaySDK

"std::1::basic_string, std::1::allocator >::init(char const, unsigned long)", referenced from:

CAliSecXURL::encodeURIComponent(CAliSecXBuffer&) in AlipaySDK

"std::1::basic_string, std::1::allocator >::reserve(unsigned long)", referenced from:

CAliSecXURL::encodeURIComponent(CAliSecXBuffer&) in AlipaySDK

"std::1::basic_string, std::__1::allocator >::~basic_string()", referenced from:

CAliSecXURL::encodeURIComponent(CAliSecXBuffer&) in AlipaySDK

"std::nothrow", referenced from:

CAliSecXBuffer::CAliSecXBuffer(unsigned long) in AlipaySDK

CAliSecXBuffer::_copy(unsigned char const, unsigned long) in AlipaySDK

CAliSecXBuffer::resize(unsigned long) in AlipaySDK

"std::terminate()", referenced from:

clang_call_terminate in AlipaySDK

"operator delete", referenced from:

CAliSecXBuffer::~CAliSecXBuffer() in AlipaySDK

CAliSecXBuffer::release() in AlipaySDK

CAliSecXBuffer::~CAliSecXBuffer() in AlipaySDK

CAliSecXBuffer::operator=(CAliSecXBuffer const&) in AlipaySDK

CAliSecXBuffer::resize(unsigned long) in AlipaySDK

alisec_crypto_Hex2Bin(CAliSecXBuffer const&) in AlipaySDK

alisec_crypto_Bin2Hex(CAliSecXBuffer const&) in AlipaySDK

...

"operator new", referenced from:

CAliSecXBuffer::CAliSecXBuffer(unsigned long) in AlipaySDK

CAliSecXBuffer::_copy(unsigned char const*, unsigned long) in AlipaySDK

CAliSecXBuffer::resize(unsigned long) in AlipaySDK

"cxa_begin_catch", referenced from:

clang_call_terminate in AlipaySDK

"gxx_personality_v0", referenced from:

+[ASSStorageAccesser saveStorageModel:] in AlipaySDK

+[ASSStorageAccesser loadStorageModelFromKeychain] in AlipaySDK

+[ASSStorageAccesser loadPreviousApdid] in AlipaySDK

+[ASSStorageAccesser getRandomizedID] in AlipaySDK

+[ASSStorageAccesser getNewRadomizedID] in AlipaySDK

+[ASSStorageAccesser loadLastLoginTime] in AlipaySDK

+[ASSStorageAccesser saveCurrentLoginTime:] in AlipaySDK

...

"_deflate", referenced from:

+[ASSCommonUtils gzipData:] in AlipaySDK

+[DTGZipUtil compressGZip:] in AlipaySDK

"_deflateEnd", referenced from:

+[ASSCommonUtils gzipData:] in AlipaySDK

+[DTGZipUtil compressGZip:] in AlipaySDK

"_deflateInit2", referenced from:

+[ASSCommonUtils gzipData:] in AlipaySDK

+[DTGZipUtil compressGZip:] in AlipaySDK

"_kCNNetworkInfoKeyBSSID", referenced from:

+[UIDevice(APEX) networkDic] in AlipaySDK

"_kCNNetworkInfoKeySSID", referenced from:

+[UIDevice(APEX) networkDic] in AlipaySDK

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

解決辦法:

這種問題經過在General->Link Framework and Libraiies中添加如下framework解決:

- libz.tbd

- libc++.tbd

- Security.framework

- CoreMotion.Framework

- CFNetwork.framework

- CoreTelephony.framework

- SystemConfiguration.framework

截圖以下,因爲公司同時接入支付寶和微信支付,因此導入的庫就多了點咯:

616981-2e9fde123b91a6d5.jpg

問題5. Redefinition of 'RSA' as different kind of symbol 多爲sdk集成時產生的坑,由於咱們公司在集成支付寶以前,有用過RSA加密,致使重名問題

解決辦法:

(1)這個問題不是每一個公司均可能遇到的,但遇到也心煩

(2)因爲支付寶中的openssl中的rsa.h文件與RSA加密有重名衝突。改掉公司本身以前導入RSA的命名,若是你牛逼也能夠去改rsa.h中的

問題6. 系統庫導入問題

+++++++++++++

symbol(s) not found for architecture arm64

1464167743266924.png

解決辦法:

就是導入系統庫了

616981-3a750ed6a81bdc43.jpg

問題7:終於到微信了,接入微信,你就開心了

由於問題太少了,只能感謝下這兩個帖子的樓主了

解決辦法:

使用微信支付SDK1.5版本的支付demo

微信支付若是遇到跳轉只有一個肯定請看這裏

爲了一些懶人懶的去看帖子,簡單說,就是微信支付註冊放在友盟分享以後就ok了!

代碼示例:

1

2

3

4

// 友盟分享

    [self configUmengShare];

//向微信註冊

    [WXApi registerApp:@"wxb4ba3c02aa476ea1" withDescription:@"demo 2.0"];

問題7:拉起支付寶報錯:交易訂單處理失敗,請稍後再試(ALI64)

解決辦法:

從新生成私鑰和公鑰,執行步驟以下個問題

問題8:支付寶要從新生成私鑰和公鑰,並上傳修改公鑰 -- 爲你補充

解決辦法:

RSA密鑰生成命令步驟以下:

(1)先在終端鍵入 openssl

生成RSA私鑰

(2)openssl>genrsa -out rsa_private_key.pem 1024

生成RSA公鑰

(3)openssl>rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem

將RSA私鑰轉換成PKCS8格式

(4)openssl>pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt

注意:「>」符號後面的纔是須要輸入的命令。

使用

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

WuTiandeiMac:FPHClientNew wutianshi$ openssl

OpenSSL>

OpenSSL>

OpenSSL>

OpenSSL>

OpenSSL> genrsa -out rsa_private_key.pem 1024

Generating RSA private key, 1024 bit long modulus

....................++++++

.........++++++

e is 65537 (0x10001)

OpenSSL> rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem

writing RSA key

OpenSSL>

OpenSSL>

OpenSSL> pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt

-----BEGIN PRIVATE KEY-----

MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANOjnFDIjeQjyah1

1smthHNsiHyXE8EOWMyMZkLrIlbu6TCDVHk/hhJTpbDxVOz6f4cFdynP/wD9Tbnf

ZfJCKFDFJ9jPz3Euyb5/jLFbyAVblyLLPiv5bxRLaA9/w4Jtt+G7E/ti8HN6224x

4TT3owFuKqZTcAXeqXp7QMzZyEkZAgMBAAECgYBWYKRf5DrlLiYT92Rek89HPLjI

APEzDiP3+CWUkltFl+Tcw/0qL18NA87QVO8QeXyrIvPrwNSXFssuXZtCMPY6oqgh

21ixQ+w4Kk4Z8nkEbFNRjryrpOeGMQmZlkSqRiehnYPY6UT8ovKXj0D1HBoscfA7

z1Ioxpo3QEN3jsxkcQJBAPbgYhJYS7+/HB92eXaHckTpU0/ycosSj6ha02xs5+Sv

xJbkkDfrt/LVVgApBYlgJQG0WRcD/8+4cIyyAxGFp7MCQQDbdduyrvUTffsXeuad

XcHIAmX928y19YGvCU3+TJtGIfUMPoRsnidMnZh2s29G6bGy0fkrmMadogEkKqQX

AmYDAkBEmbdGx7hM0Oscpww7bonHMlrPNVy03nSC4LItR9nsRxdGor6ce2jDFpru

MnfyY4AFCDtVVOwpqWPFBNYrcUtXAkEAltAme2OKHawMmnUl9+zPV1B2oH6k7kJZ

rVy6kVA5wHdje9eWj0IcBaWjeacTiGreZ+Gt1sz1aKxFFoKLIxjN2wJADlpg/9iN

Bf+JylK9QEgOTw6PngSOiXeaVXdErOPbu4WkzvxhB0bm8HPEPiJpLg/3sNaaX3ou

TIEHO8o1EcEnrw==

-----END PRIVATE KEY-----

OpenSSL>

生成的文件:

616981-bf1bd390c88ef9da.png

把公鑰上傳到支付寶,而後把pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt 這條命令產生的私鑰用在下面設置中就好

而後設置

1

2

3

4

5

6

7

8

9

10

11

/*

*商戶的惟一的parnter和seller。

*簽約後,支付寶會爲每一個商戶分配一個惟一的 parnter 和 seller。

*/

/*============================================================================*/

/*=======================須要填寫商戶app申請的===================================*/

/*============================================================================*/

NSString *partner = PartnerID;//合做夥伴身份(PID):

NSString *seller = SellerID;//商戶支付寶帳戶

//獲取私鑰並將商戶信息簽名,外部商戶能夠根據狀況存放私鑰和簽名,只須要遵循RSA簽名規範,並將簽名字符串base64編碼和UrlEncode

NSString *privateKey = PartnerPrivKey;// 剛第三端命令生成的去頭去尾

若有問題,繼續分享咯,總結才能讓問題愈來愈少!

相關文章
相關標籤/搜索