paypal / here-sideloader-api-samples

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

PayPal Here is not returning back to my app #41

Open latheesan-k opened 8 years ago

latheesan-k commented 8 years ago

I am using Titanium Appcelerator to build an iOS application that lets users charge their customer using PayPal Here sideloader api.

I open the paypal here app like this:

Titanium.Platform.openURL(
    'paypalhere://takePayment?accepted=card,paypal&' +
    'returnUrl=myappurlschema://takePayment/{result}?' +
    'PaymentType={Type}&InvoiceId={InvoiceId}&TxId={TxId}&' +
    'AmountDue='+ e.amountDue +'&DiscountAmount='+ e.discountAmount +
    '&DiscountReason='+ e.discountReason +'&UsePoints='+ e.usePoints +
    '&EarnPoints='+ e.earnPoints +'&GrandTotal={GrandTotal}&as=b64&' +
    'step=choosePayment&invoice=' + 
    Titanium.Utils.base64encode(JSON.stringify(paypalInvoice)));

This correctly opens the paypal here app with my basket contents (i.e. invoice lines).

I am able to select card payment type, enter my details and charge. Once the transaction is completed, I click No Receipt, but nothing happens.

I should be taken back to my app as per specified returnUrl.

I have already verified my app's url schema is registered by opening the safari browser and visiting myappurlschema://takePayment and it opens my app, therefore paypal should have no trouble opening my app also.

I've also tried wrapping the returnUrl value with encodeURIComponent() but that did not help either.

djMax commented 8 years ago

If you set the returnUrl to be a web page - like www.google.com or some such, what happens? Also, what if your return URL is myappurlschema://takePayment/ without the result bit?

latheesan-k commented 8 years ago

Hi.

Nothing happens. I've already tested this.

Sent from my iPhone

On 1 Mar 2016, at 21:23, Max Metral notifications@github.com<mailto:notifications@github.com> wrote:

If you set the returnUrl to be a web page - like www.google.comhttp://www.google.com or some such, what happens? Also, what if your return URL is myappurlschema://takePayment/ without the result bit?

Reply to this email directly or view it on GitHubhttps://github.com/paypal/here-sideloader-api-samples/issues/41#issuecomment-190911254.

latheesan-k commented 8 years ago

After many hours of trial and error, I sort of have a semi-working version now. This is what I have so far:

// Open paypal here
var retUrl = Titanium.Network.encodeURIComponent(
    "myappurlschema://takePayment/{result}?Done"+
    "&PaymentType={Type}"+
    "&InvoiceId={InvoiceId}"+
    "&TxId={TxId}"+
    "&GrandTotal={GrandTotal}"+
    "&AmountDue="+ e.amountDue +
    "&DiscountAmount="+ e.discountAmount +
    "&DiscountReason="+ e.discountReason +
    "&UsePoints="+ e.usePoints +
    "&EarnPoints="+ e.earnPoints);
var pphereUrl = "paypalhere://takePayment?accepted=card,paypal&returnUrl="+ retUrl;
    pphereUrl += "&as=b64&step=choosePayment";
var request = pphereUrl +"&invoice="+ Titanium.Utils.base64encode(JSON.stringify(paypalInvoice));
    request = request.replace(/(\r\n|\n|\r)/gm, "");
Titanium.Platform.openURL(request);

With the above; when code executes, this is the flow:

  1. PayPal Here App opens
  2. Select "Card" payment type
  3. Enter details & click "Charge"
  4. I get a success message with option to print/text receipt etc...
  5. Clicking on "No Receipt" -> nothing happens, i see another success window
  6. If I click on "New Sale" on this window, paypal here app returns you back to my app and at this point is where I actually get the results back (i.e. PaymentType, InvoiceId, TxId etc...)

So... I am not sure what happened. Did the flow get updated or something? I distinctly remember previously, when you clicked "No Receipt" it immediately returned you back to the app with the result. Now you have to click "No Receipt" and then "New Sale" to return to app with result.

hanji866 commented 4 years ago

Running into same problem. This work around didn't work for me. No Receipt to New Sale either does nothing or with v2 will just load the calling site, but not pass anything.