0
Square最近刪除了OAuth商家授權的要求,如「在您的應用中啓動Square註銷事項」部分中的here所述。iOS Square Register Popover OpenURL問題
當我的應用程序彈出在通往廣場的註冊程序,一個警報彈出出現在廣場的應用說:
"API Error: No client ID specified"
儘管我清楚地列出我「的client_id」在我的應用程序時,我打電話開放廣場。我的代碼如下。 任何想法如何解決它?
-(void)squarePaymentWithName:(NSString *)name{
//Specify amount of money to charge
float orderPriceFloat = [Order orderTotalPrice];
float orderPriceFloatCents = orderPriceFloat * 100;
NSInteger orderPriceFloatCentsInteger = [[NSNumber numberWithFloat:orderPriceFloatCents] integerValue];
NSString *amountString = [NSString stringWithFormat:@"%ld", (long)orderPriceFloatCentsInteger];
NSDictionary *squareDictionary = @{@"callback_url": @"<CALLBACK_URL>",
@"client_id": @"<CLIENT_ID>",
@"version": @"1.2",
@"amount_money":
@{@"amount": amountString,
@"currency_mode":@"USD"
},
@"options":
@{@"supported_tender_types": @[@"CREDIT_CARD", @"SQUARE_GIFT_CARD"],
@"auto_return": @"true"
}
};
NSString *jsonString = [NSString stringWithFormat:@"%@", squareDictionary];
NSString *encodedString = [jsonString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; //encode the string
NSString *scheme = [NSString stringWithFormat:@"square-commerce-v1://payment/create?data=%@", encodedString]; //input the string to the url
UIApplication *application = [UIApplication sharedApplication];
NSURL *URL = [NSURL URLWithString:scheme];
BOOL canOpen = [application canOpenURL:URL]; //open the url
[application openURL:URL];
}
jsonString的NSLog的是:
{
"amount_money" = {
amount = 250;
"currency_mode" = USD;
};
"callback_url" = CALLBACK_URL;
"client_id" = CLIENT_ID;
options = {
"auto_return" = true;
"supported_tender_types" = (
"CREDIT_CARD",
"SQUARE_GIFT_CARD"
);
};
version = "1.2";
}
而且,作爲一個說明, 'CALLBACK_URL' 和 'CLIENT_ID' 我的輸入是佔位符,因爲我不想把真正的價值。
謝謝!
您是否嘗試過使用我們的SDK?它使得你試圖做的事情變得相當簡單。 https://github.com/square/SquareRegisterSDK-iOS – tristansokol
我的原生iOS應用使用'SquareRegisterSDK'可可豆。請注意,我的應用程序是第三方應用程序,可將用戶放到Square進行付款,然後將其彈回到我的應用程序中。 – mdimarca
我想象的問題是將我創建的NSDictionary與數據轉換成字符串,但儘管修補了它仍然沒有得到它的工作。任何想法可能來自哪個問題? – mdimarca