Reputation: 537
In my project GWT-RPC I use on server side the SDK merchant PayPal to use API Call in sandbox mode. On server side I have:
PayPalAPIInterfaceServiceService service=new PayPalAPIInterfaceServiceService(configMap);
PaymentDetailsType paymentDetails = new PaymentDetailsType();
paymentDetails.setPaymentAction(PaymentActionCodeType.fromValue("Sale"));
PaymentDetailsItemType item = new PaymentDetailsItemType();
BasicAmountType amt = new BasicAmountType();
amt.setCurrencyID(CurrencyCodeType.EUR);
String itemAmount = "10.00";
amt.setValue(itemAmount);
int itemQuantity = 1;
item.setQuantity(itemQuantity);
item.setName("pagamento su Movieuniverse");
item.setAmount(amt);
List<PaymentDetailsItemType> lineItems = new ArrayList<PaymentDetailsItemType>();
lineItems.add(item);
paymentDetails.setPaymentDetailsItem(lineItems);
BasicAmountType orderTotal = new BasicAmountType();
orderTotal.setCurrencyID(CurrencyCodeType.EUR);
orderTotal.setValue(((Double)(Double.parseDouble(itemAmount) * itemQuantity)).toString());
paymentDetails.setOrderTotal(orderTotal);
List<PaymentDetailsType> paymentDetailsList = new ArrayList<PaymentDetailsType>();
paymentDetailsList.add(paymentDetails);
SetExpressCheckoutRequestDetailsType setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
setExpressCheckoutRequestDetails.setReturnURL("http://127.0.0.1:8888/MovieUniverse.html#order_confirmed");
setExpressCheckoutRequestDetails.setCancelURL("http://127.0.0.1:8888/MovieUniverse.html#order_cancelled");
setExpressCheckoutRequestDetails.setPaymentDetails(paymentDetailsList);
SetExpressCheckoutRequestType setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails);
setExpressCheckoutRequest.setVersion("104.0");
SetExpressCheckoutReq setExpressCheckoutReq = new SetExpressCheckoutReq();
setExpressCheckoutReq.setSetExpressCheckoutRequest(setExpressCheckoutRequest);
SetExpressCheckoutResponseType res=service.setExpressCheckout(setExpressCheckoutReq);
String token=res.getToken();
return token;
In that way I obtain the token and using the in-context mode, using 2 scripts as written in PayPal Checkout Express in-context Documentation
window.paypalCheckoutReady=function(){
paypal.checkout.setup("2GF99UMQQF66A",{
environment:'sandbox',
container: "paypal"
});
}
ScriptInjector.fromString(JsResources.INSTANCE.scriptOpenPopupPaypal().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
ScriptInjector.fromUrl("http://www.paypalobjects.com/api/checkout.js").setWindow(ScriptInjector.TOP_WINDOW).inject();
Clicking on the payapal checkout button it opens this link in the popup( obtained by the two scripts)
https://www.sandbox.paypal.com/checkoutnow?useraction=commit&token=<TOKEN-OBTAINED>
I click on pay now, but the payment is not registered and after the closing of popup, it remains my page with the paypal loading note and under this the return page, here the screens:
I don't know what is wrong in the implementation and why remains the paypal loading, maybe the URL should be different. On paypal documentation is written that I should use:
<form id="myContainer" method="post" action="/checkout"></form>
,
but how can I give it the result from the API call? So I use directly the link=URL+token seen and I insert it in href (in order to be used by the script) in the html snippet:
<div class="container">
<a id='paypal'
href="">
</a>
</div>
So the link will be open in the popup window but it doesn't work for reasons previously explained. Thanks a lot!
Documentation: PayPal Checkout Express in-context
Upvotes: 2
Views: 810
Reputation: 1767
This integration method is deprecated as of January 1, 2017. PayPal continues to support existing merchants using this method, but please be advised new features and enhancements will not be applied to these integrations.
for more details visit documentation
The PayPal Express Checkout with In-Context flow gives your customers a simplified checkout experience that keeps them local to your website throughout the payment authorization process and enables them to use their PayPal balance, bank account, or credit card to pay without sharing or entering any sensitive information on your site.
For new integrations, see the PayPal Checkout Integration Guide.
Upvotes: 0