我正在尝试使用PayPal设置支付系统,以便在付款确认时不收取费用。我理解这是“创建”操作类型的用途,您进行付款然后使用执行付款来实际收取帐户费用。不幸的是,根据我在沙盒中看到的情况,买方立即收取费用,执行付款会返回“付款已用于付款”错误。 IPN通知同样告诉我付款已经发生。
我目前正在使用2个接收器进行自适应支付。我正在从Java发送请求,使用下面粘贴的代码来获取付费密钥。然后我将用户重定向到paypal,付款完成(并收费)。
我错过了什么吗?
List<PaymentReceiver> receiverList = setReceiversSingleProject(order);
Element root = new Element("PayRequest");
root.addNamespaceDeclaration("ns2", "http://svcs.paypal.com/types/ap");
// requestEnvelope and errorLanguage
Element requestEnvelopeElement = new Element("requestEnvelope");
Element errorLanguageElement = new Element("errorLanguage");
errorLanguageElement.appendChild(errorLanguage);
requestEnvelopeElement.appendChild(errorLanguageElement);
root.appendChild(requestEnvelopeElement);
// cancelUrl
Element cancelUrlElement = new Element("cancelUrl");
cancelUrlElement.appendChild(themeDisplay.getPortalURL()+"/basket");
root.appendChild(cancelUrlElement);
// actionType
Element actionTypeElement = new Element("actionType");
actionTypeElement.appendChild("CREATE");
root.appendChild(actionTypeElement);
// currencyCode
Element currencyCodeElement = new Element("currencyCode");
String projectCurrency = order.getMainProject().getCurrency();
Currency currency = CurrencyLocalServiceUtil.getCurrency(projectCurrency);
currencyCodeElement.appendChild(currency.getPaypalCode());
root.appendChild(currencyCodeElement);
// receiverList
Element receiverListElement = new Element("receiverList");
for (PaymentReceiver receiver : receiverList) {
Element receiverElement = new Element("receiver");
Element amountElement = new Element("amount");
amountElement.appendChild(String.valueOf(receiver.getAmount()));
Element emailElement = new Element("email");
emailElement.appendChild(receiver.getEmail());
Element primaryElement = new Element("primary");
primaryElement.appendChild(receiver.isPrimary()?"true":"false");
receiverElement.appendChild(amountElement);
receiverElement.appendChild(emailElement);
receiverElement.appendChild(primaryElement);
receiverListElement.appendChild(receiverElement);
}
root.appendChild(receiverListElement);
// returnUrl
Element returnUrlElement = new Element("returnUrl");
returnUrlElement.appendChild(returnURL);
root.appendChild(returnUrlElement);
// notifyUrl
Element notifyUrlElement = new Element("ipnNotificationUrl");
notifyUrlElement.appendChild(notifyURL);
root.appendChild(notifyUrlElement);
// Create document object
Document doc = new Document(root);
String result = doc.toXML();
return result;