私の現在のJava/Springプロジェクトでは、PayPalとの統合段階にあります。 hereの指示に従って、支払い処理を処理するJavaクラスを設定した後、私は自分のアプリケーションを実行し、paypalで注文をチェックアウトしようとします。PayPal SDKが支払い確認ページからプロフィールページに移動
私はPayPalのログインページに正しくリダイレクトされ、ログイン後、この支払いレビューページにしています:
が、その後、私は代わりに支払いを完了するの、「続行」をクリックした後、プロフィールページにリダイレクトされています。ここで
私のコードです:
Paypal prop = this.paypalDao.get();
String clientId = prop.getClientID();
String clientSecret = prop.getClientSecret();
APIContext apiContext = new APIContext(clientId, clientSecret, "sandbox");
if(payerId != null) {
if(guid != null) {
Payment payment = new Payment();
payment.setId(map.get(guid));
PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.setPayerId(payerId);
payment.execute(apiContext, paymentExecution);
String url = request.getContextPath();
return url+"/orders";
}
} else {
List<Produto> lista_de_produtos = this.getListaDeProdutos(clienteId);
Double total = 0.0;
for(Produto produto : lista_de_produtos)
total = total + produto.getPreco();
DecimalFormat df = new DecimalFormat("0.00");
String svalue = df.format(total).replace(',', '.');
Details details = new Details();
details.setSubtotal(svalue);
Amount amount = new Amount();
amount.setCurrency("BRL");
amount.setTotal(svalue);
amount.setDetails(details);
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setDescription(lista_de_produtos.toString());
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
payment.setTransactions(transactions);
RedirectUrls redirectUrls = new RedirectUrls();
guid = UUID.randomUUID().toString();
String url = request.getContextPath();
redirectUrls.setCancelUrl(url+"/cart");
redirectUrls.setReturnUrl(url+"/paypal/checkout/"+clientId+"/?guid=" + guid);
payment.setRedirectUrls(redirectUrls);
Payment createdPayment = payment.create(apiContext);
Iterator<Links> links = createdPayment.getLinks().iterator();
while (links.hasNext()) {
Links link = links.next();
if (link.getRel().equalsIgnoreCase("approval_url")) {
map.put("redirectURL", link.getHref());
redirectURL = link.getHref();
}
}
map.put(guid, createdPayment.getId());
payment.setId(map.get(guid));
}
return redirectURL;
誰かが私がここで何をしないのです、教えてもらえますか?
少なくとも電話、電子メールIDなどのような個人的な詳細を隠します。 –
request.getContextPath()とは何ですか?これが相対URL(ドメイン名なし)の場合、PayPalはどこに顧客を送り返すかを知らない。 –