paypal / here-sideloader-api-samples

Sideloader API samples that enable to integrate PayPal Here into other apps
Other
24 stars 32 forks source link

iOS PayPalHere return ignores "number" field in supplied invoice #21

Closed mcn100 closed 9 years ago

mcn100 commented 9 years ago

Hope you can help.

I'm supplying a "number" field in the invoice json object that goes to PayPalHere app. When returning from PayPalHere on iOS the return URL is missing the "number" that is supplied in the invoice. I've checked the json invoice to be valid json (This all works OK on the Android version of the app).

Is this a bug?

From the documentation "Note: In the JSON input object (containing the invoice data), you may provide a unique invoice ID (in the number field). It must be unique to the merchant. If you leave out the number field, an invoice ID will be assigned, but if you provide the number field with a repeated value, or no value, (for example, if you send “number”: “”, or send “number”: “12345” every time), unexpected behavior will result."

Many thanks

jaredegan commented 9 years ago

Hi, do you have the "{InvoiceId}" string present in your return URL?

mcn100 commented 9 years ago

Yes - InvoiceId is present and being populated in the return URL. Using the same code base and supplying similar parameters - running on Android I get back:

Type=CARD&Number=MCN100Y6F535614&InvoiceId=INV2-HDIY-4LJG-GL9V-Q9G5&Email=test.person@xyz.com

Running on iOS I get back:

Type=CARD&InvoiceId=INV2-UDKO-DJFY-BBWP-2AFF&Tip=0&Email=&TxId=

For the iOS app I need the supplied 'Number' field to be returned back from the app as well as the InvoiceId as per the android version.

iOS is at version 2.4 Build 24000 Android is at version 2.4.7 Build 2413

Any help appreciated

jaredegan commented 9 years ago

OK, can you paste me an example of a full paypalhere:// URL you use to trigger this on iOS?

jaredegan commented 9 years ago

Your return URL should have a {Number} key. On iOS we don't append extra parameters, I'm surprised that Android does that. Please let me know if that works and a full URL example.

dacology commented 9 years ago

I am seeing the same thing. All ok on Android, but no details in response on iOS (not sure if it is iOS or Safari issue?), I only get the invoice number back, no {number} or other.

As I am just prototyping for now, I ignored this and am just testing on android, but interested in this if others are seeing it.

Below is my url with return url and emails modified to remove my info.

paypalhere://takePayment?returnUrl=http%3A%2F%2Fexample.com%2FPaypalReturnUrl%3F%7Bresult%7D%3FType%3D%7BType%7D%26InvoiceId%3D%7BInvoiceId%7D%26Tip%3D%7BTip%7D%26Email%3D%7BEmail%7D%26TxId%3D%7BTxId%7D&accepted=cash,card,paypal&step=choosePayment&invoice=% 7B%22itemList%22%3A%7B%22item%22%3A%5B%7B%22name%22%3A%22GenWatt%20Diesel%201000kW%22%2C%22quantity%22%3A1%2C%22unitPrice%22%3A0.01%2C%22taxRate%22%3A%220.0%22%2C%22taxName%22%3A%22Tax%22%7D%2C%7B%22name%22%3A%22GenWatt%20Diesel%2010kW%22%2C%22quantity%22%3A2%2C%22unitPrice%22%3A0.02%2C%22taxRate%22%3A%220.0%22%2C%22taxName%22%3A%22Tax%22%7D%2C%7B%22name%22%3A%22GenWatt%20Diesel%20200kW%22%2C%22quantity%22%3A3%2C%22unitPrice%22%3A0.03%2C%22taxRate%22%3A%220.0%22%2C%22taxName%22%3A%22Tax%22%7D%5D%7D%2C%22number%22%3A%2234545%22%2C%22paymentTerms%22%3A%22DueOnReceipt%22%2C%22currencyCode%22%3A%22GBP%22%2C%22discountPercent%22%3A%220%22%2C%22merchantEmail%22%3A%22test@gmail.com %22%2C%22payerEmail%22%3A%22test@example.com %22%2C%22logoUrl%22%3A%22http%3A// thumbs2.ebaystatic.com/d/l225/m/m-NdWlox1pPcwyCQcBYVqpw.jpg%22%7D

On 19 March 2015 at 20:46, Jared Egan notifications@github.com wrote:

Your return URL should have a {Number} key. On iOS we don't append extra parameters, I'm surprised that Android does that. Please let me know if that works and a full URL example.

— Reply to this email directly or view it on GitHub https://github.com/paypal/here-sideloader-api-samples/issues/21#issuecomment-83756142 .

jaredegan commented 9 years ago

Sorry, I could have been more specific. I meant when you send your return URL, it should have the text {Number} in it, which will get replaced. Try changing your return URL from

returnUrl=http://example.com/PaypalReturnUrl?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}

to be

returnUrl=http://example.com/PaypalReturnUrl?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&Number={Number}

I'll reach out internally about the inconsistency, but we probably won't change Android so we can maintain backwards compatibility.

Give that a go and let me know if it works.

dacology commented 9 years ago

Great, this really helps, I now get back the InvoiceID. There are still missing some data though. On Android I get back Email but not on iOS. Is &Email={Email} correct?

So in the examples (that I used) we are given this: var retUrl = encodeURIComponent(returnUrl + "?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&TxId={TxId}");

but it needs to be this: var retUrl = encodeURIComponent(returnUrl + "?{result}&Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&TxId={TxId}&Number={Number}");

Note that we have added &Number={Number} but also changed the ?Type={Type} to _&_Type={Type}

Thanks David

On 20 March 2015 at 00:12, Jared Egan notifications@github.com wrote:

Sorry, I could have been more specific. I meant when you send your return URL, it should have the text {Number} in it, which will get replaced. Try changing your return URL from

returnUrl= http://example.com/PaypalReturnUrl?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}

to be

returnUrl= http://example.com/PaypalReturnUrl?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&Number={Number}

I'll reach out internally about the inconsistency, but we probably won't change Android so we can maintain backwards compatibility.

Give that a go and let me know if it works.

— Reply to this email directly or view it on GitHub https://github.com/paypal/here-sideloader-api-samples/issues/21#issuecomment-83816254 .

mcn100 commented 9 years ago

Hi Jared, Thanks for looking into this.

Appending &Number={Number} to the end of the return URL causes the iOS app to return nothing.

The android version behaves the same regardless of whether &Number={Number} is present or not ie Number comes back as expected and InvoiceId comes back populated

I also tried changing ?{result}?Type={Type} to ?{result}&Type={Type} as suggested by David but that doesnt seem to make a difference to the Number field.

This is a decoded example URL sent to the paypal app with domains etc changed

paypalhere://takePayment?accepted=card,cash,paypal&returnUrl=http://myurl.com/paypalpayment?{result}&Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&TxId={TxId}&Number={Number}&step=choosePayment&invoice={"merchantEmail":"merchant@paypal.com","payerEmail":"customer@example.com","currencyCode":"GBP","paymentTerms":"DueOnReceipt","discountPercent":"0.00","discountAmount":"0.00","number":"MCN1009TS556636","itemList":{"item":[{"name":"Burn After Reading Sat 21 Mar 2015 13:10","description":"FULL PRICE","quantity":"1","unitPrice":"20.00","taxName":"Tax","taxRate":"0.00","discountPercent":"0.00","discountAmount":"0.00"}]}}

Thanks

mcn100 commented 9 years ago

Hi Jared

My error- I have now got the URL returning the number field by adding &Number={Number} to the return URL :) I was using a pipe symbol "|" in the number string as a separator which was confusing the iOS app. When I removed the pipe, the number came back in the URL. (Android version was not affected either way)

Many thanks for your help in sorting this.