I'm trying to set a paypal adaptive payment flow to create a Chained payment. After many troubles the desktop version of my payment works correctly, it sends payment to all the receivers and it redirect correctly to my site. My problem now is in real mobile browsers ( setting user agent of my desktop browser solve all the problems, but this naturally it isn't the real mobile user experience). This is my code : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Paypal test</title>
</head>
<body>
<!--MINI-->
<script src="https://www.paypalobjects.com/js/external/apdg.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
//this function register the order in my system
function saveOrder() {
//call an internal api to get the paypal api key for this transaction $.ajax({ url: "http://www.example.com/ajax/getPayKey.php", success: function(datakey) { arrData = datakey.split("|");
var paykey=arrData[0];
//with the obtained api key i set the value of the hidden field in the form $("#paykey").val(paykey);
}
});
}
var returnFromPayPal = function(){
// returning from paypal flow i need to know the transaction status to redirect the user to the correct page in my site $.ajax({ url: "<?php echo URL_SITO; ?>/ajax/PaymentDetails.php?pay_key="+ $("#paykey").val(), success: function(data_return) {
//with the url returned i redirect user document.location.href=data_return;
}
});
}
//init the paypal flow
var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'submitBtn', expType: 'mini', callbackFunction: 'returnFromPayPal'});
</script>
<!--Start pay key process-->
<div onclick="saveOrder();">Pay Order</div>
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" class="standard" id="paypal_form_adaptive">
<!--Start payment flow-->
<input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
<input id="type" type="hidden" name="expType" value="mini">
<input id="paykey" type="hidden" name="paykey" value="insert_pay_key">
</form>
</body>
</html> I have read in paypal documentation that i can use three types of flow for an adaptive payments, i have found problems with all this flow types. I have choose the "mini" options beacause it is the nearest to solution. Anyway, with the code above i mostly complete the flow, the "mini" open a new tab in my Iphone, i complete the payment but the redirect is wrong. Paypal returns in my payment page but the callbackFunction: 'returnFromPayPal' is never called. Without callback i can't redirect user. How i can do to complete correctly this flow on mobile?
... View more