paypal / paypal-here-sdk-ios-distribution

Add credit card (tap, insert, swipe & key-in) capabilities to your iOS app
Other
81 stars 91 forks source link

[1.6] Calling processPaymentUsingUIWithPaymentType receives "Error 580029, missing field merchantInfo" #60

Closed rleiwang closed 8 years ago

rleiwang commented 8 years ago

I've got the following error. I didn't find where to set merchantInfo in PPHInvoice

2015-10-03 09:41:42.489 [1304:175641] 16:41:41.0802      Main thread | PayPalHere: 
--- _OBSCURO_EMFJSONRequest (POST https://www.sandbox.paypal.com/webapps/hereapi/merchant/v1/invoices) 

Headers: {
    "Accept-Encoding" = "gzip,deflate";
    Authorization = "Bearer A015J-w7uycNWhMNeX6VMlmxKfuySaB9ptqmudgLSUBm2yM";
    "Content-Length" = 366;
    "Content-Type" = "application/json; charset=UTF-8";
    "X-PAYPAL-REQUEST-SOURCE" = "MPA-DEVICE_iOS_iPad4,4_8.3_SDK_1.6_org.reactjs.native.example._1.0_L0";
}

Data: {"invoiceDate":"2015-10-03T16:41:41Z","merchantEmail":"biz@gmail.com","currencyCode":"USD","taxInclusive":"false","paymentTerms":"DueOnReceipt","payerEmail":"noreply@here.paypal.com","partnerReferrerCode":"App, Inc","taxCalculatedAfterDiscount":"true","items":[{"quantity":"1","taxName":"taxRate","unitPrice":"10.01","taxRate":10,"name":"itemName"}]}
2015-10-03 09:41:42.490 [1304:175641] 16:41:42.0079 <NSThread: 0x17506e740>{number = 15, name = (null)} | PayPalHere: 
--- _OBSCURO_EMFJSONResponse https://www.sandbox.paypal.com/webapps/hereapi/merchant/v1/invoices

Headers: {
  "Server" : "Apache",
  "Set-Cookie" : "SPARTAJSESSIONID=157f4d4d72917; Domain=.paypal.com; Path=\/; Secure; HttpOnly, SPARTAJSESSIONID=7f93720b00086; Domain=.paypal.com; Path=\/; Secure; HttpOnly, SPARTAJSESSIONIDV2=-96utO3ySDsnO-akpxQbCTwcHbx8BDutM5vMFC3OJIWFDRtKtYsekUQdl8oeQl4QACCOys.-CX46b-fYrHV9C6k3lvvLiOznQZNrR5YI1Svd.6CMxHN8NQ; Domain=.paypal.com; Path=\/; Secure; HttpOnly, X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dhereapispartaweb%26TIME%3D1157959766; domain=.paypal.com; path=\/; Secure; HttpOnly, X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT",
  "Paypal-Debug-Id" : "8eedaa062cbc7",
  "Strict-Transport-Security" : "max-age=14400",
  "Content-Type" : "application\/json;charset=utf-8",
  "Date" : "Sat, 03 Oct 2015 16:41:41 GMT",
  "Content-Length" : "151",
  "X-Cnection" : "close",
  "Content-Encoding" : "gzip",
  "Vary" : "Accept-Encoding,Authorization"
}

Error: (null)

Data: {"correlationId":"8eedaa062cbc7","errorCode":580029,"message":"Missing field: merchantInfo","developerMessage":"Your request is missing a field: merchantInfo","errorType":"missing_field"}
rleiwang commented 8 years ago

I used the following to setup PPH SDK

  [PayPalHereSDK setupWithCredentials: [JSON objectForKey:@"access_token"]
                           refreshUrl: @"http://192.168.2.9:9090/paypal/refresh"
                     tokenExpiryOrNil: [JSON objectForKey:@"expires_in"]
                thenCompletionHandler:^(PPHInitResultType status, PPHError *error, PPHMerchantInfo *info)
   {
     if (status == ePPHAccessResultSuccess)
     {
       self.merchant = info;
     }
   }];
djMax commented 8 years ago

it should get setup by setupWithCredentials. Do you see a call to a URL with "userInfo" in it between the setup call and the create invoice call?

rleiwang commented 8 years ago

Yes, I saw the the following after setupWithCredentials, before processing payment

2015-10-03 09:40:47.347 [1304:175641] 16:40:46.0872 <NSThread: 0x174e7e940>{number = 11, name = (null)} | PayPalHere: 
--- _OBSCURO_EMFJSONResponse https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/userinfo?schema=openid

Headers: {
  "Server" : "Apache",
  "Set-Cookie" : "X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Didentityspartaweb%26TIME%3D201658454; domain=.paypal.com; path=\/; Secure; HttpOnly, X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT",
  "Strict-Transport-Security" : "max-age=14400",
  "Content-Type" : "application\/json;charset=UTF-8",
  "Date" : "Sat, 03 Oct 2015 16:40:44 GMT",
  "Paypal-Debug-Id" : "6857d28f3b146, 89fef8bbb17e0",
  "Content-Length" : "150",
  "Connection" : "Keep-Alive, Keep-Alive",
  "Content-Encoding" : "gzip",
  "Vary" : "Accept-Encoding,Authorization",
  "Keep-Alive" : "timeout=5, max=99"
}

Error: (null)

Data: {"email":"biz@gmail.com","user_id":"https://www.paypal.com/webapps/auth/identity/user/uOzMMmHE7a5YnrJqxhCtaREg9r4TXvvT-3Y9D942ElY"}
djMax commented 8 years ago

Hmmm. That seems like too little info. What scopes are you requesting for your token?

rleiwang commented 8 years ago

Only three

https://uri.paypal.com/services/paypalhere openid email
djMax commented 8 years ago

Our samples request: "email openid https://uri.paypal.com/services/paypalhere https://uri.paypal.com/services/paypalattributes/business address phone profile" which is why we get a bunch more stuff back. I think you could set it manually also, but if the additional scopes work for you, that's probably the better route.

rleiwang commented 8 years ago

Thanks @djMax for the quick response. I will try with the same scope.

I just want to learn the alternative you mentioned, do you mind to show the code snippet on how to set it manually?

rleiwang commented 8 years ago

@djMax just to confirm the transaction went through with scope "email openid https://uri.paypal.com/services/paypalhere https://uri.paypal.com/services/paypalattributes/business address phone profile". Thanks for your help

ppmtscory commented 8 years ago

Thanks for the confirmation, @rleiwang.