Paypal更新定期付款

时间:2014-08-05 14:30:50

标签: java paypal

我使用PayPal的UpdateRecurringPaymentsProfile API操作来更新现有的PayPal定期付款。当我致电PayPalAPIInterfaceServiceService使用UpdateRecurringPaymentsProfileRequest更新定期付款时,花了一些时间才返回此回复:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header>
  <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType" />
  <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
     <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
        <Username xsi:type="xs:string">xxx</Username>
        <Password xsi:type="xs:string">xxx</Password>
        <Signature xsi:type="xs:string">xxx</Signature>
        <Subject xsi:type="xs:string" />
     </Credentials>
  </RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
  <SOAP-ENV:Fault>
     <faultcode>SOAP-ENV:Client</faultcode>
     <faultstring>Timeout processing request</faultstring>
  </SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这里也是我使用的代码:

    Logger logger = Logger.getLogger(this.getClass().toString());

    UpdateRecurringPaymentsProfileReq updateRecurringPaymentsProfileReq = new UpdateRecurringPaymentsProfileReq();

    UpdateRecurringPaymentsProfileRequestType updateRecurringPaymentsProfileRequestType = new UpdateRecurringPaymentsProfileRequestType();
    updateRecurringPaymentsProfileRequestType.setVersion("63.0");

    UpdateRecurringPaymentsProfileRequestDetailsType updateRecurringPaymentsProfileRequestDetailsType = new UpdateRecurringPaymentsProfileRequestDetailsType();
    updateRecurringPaymentsProfileRequestDetailsType.setProfileID(farmBoxOrder.getProfileId());

    BasicAmountType basicAmountType = new BasicAmountType();
    basicAmountType.setValue(Utilities.stringfyDoubleValue(farmBoxOrder.getFarmBoxSize().getPrice()));

    updateRecurringPaymentsProfileRequestDetailsType.setAmount(basicAmountType);

    BillingPeriodDetailsType_Update billingPeriodDetailsTypeUpdate = new BillingPeriodDetailsType_Update();
    billingPeriodDetailsTypeUpdate.setAmount(basicAmountType);
    billingPeriodDetailsTypeUpdate.setBillingFrequency(farmBoxOrder.getFrequency());

    BillingPeriodType billingPeriodType = null;

    if(farmBoxOrder.getFrequencyUnit().equals(FrequencyUnitEnum.DAY))
    {
        billingPeriodType = BillingPeriodType.DAY;
    }
    else if(farmBoxOrder.getFrequencyUnit().equals(FrequencyUnitEnum.WEEK))
    {
        billingPeriodType = BillingPeriodType.WEEK;
    }
    else if(farmBoxOrder.getFrequencyUnit().equals(FrequencyUnitEnum.MONTH))
    {
        billingPeriodType = BillingPeriodType.MONTH;
    }
    else if(farmBoxOrder.getFrequencyUnit().equals(FrequencyUnitEnum.YEAR))
    {
        billingPeriodType = BillingPeriodType.YEAR;
    }
    billingPeriodDetailsTypeUpdate.setBillingPeriod(billingPeriodType);

    updateRecurringPaymentsProfileRequestDetailsType.setPaymentPeriod(billingPeriodDetailsTypeUpdate);;

    updateRecurringPaymentsProfileRequestType.setUpdateRecurringPaymentsProfileRequestDetails(updateRecurringPaymentsProfileRequestDetailsType);
    updateRecurringPaymentsProfileReq.setUpdateRecurringPaymentsProfileRequest(updateRecurringPaymentsProfileRequestType);

    PayPalAPIInterfaceServiceService service = null;
    try {

        InputStream is = PaypalService.class
                .getResourceAsStream("/sdk_config.properties");

        service = new PayPalAPIInterfaceServiceService(is);
    } catch (IOException e) {
        logger.severe("Error Message : " + e.getMessage());
    }
    UpdateRecurringPaymentsProfileResponseType updateRecurringPaymentsProfileResponseType = null;
    try {
        // ## Making API call
        // Invoke the appropriate method corresponding to API in service
        // wrapper object
        updateRecurringPaymentsProfileResponseType = service
                .updateRecurringPaymentsProfile(updateRecurringPaymentsProfileReq);
    } catch (Exception e) {
        logger.severe("Error Message : " + e.getMessage());
    }

    // ## Accessing response parameters
    // You can access the response parameters using getter methods in
    // response object as shown below
    // ### Success values
    if (updateRecurringPaymentsProfileResponseType.getAck().getValue()
            .equalsIgnoreCase("success")) {

        // A unique identifier for future reference to the details of
        // this recurring payment.
        logger.info("Profile ID:"
                + updateRecurringPaymentsProfileResponseType
                        .getUpdateRecurringPaymentsProfileResponseDetails()
                        .getProfileID());
    }
    // ### Error Values
    // Access error values from error list using getter methods
    else {
        List<ErrorType> errorList = updateRecurringPaymentsProfileResponseType
                .getErrors();
        logger.severe("API Error Message : "
                + errorList.get(0).getLongMessage());
    }

...其中farmBoxOrder是一个存储创建/修改定期结算所需数据的bean。

这是请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:ebay:api:PayPalAPI" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ed="urn:ebay:apis:EnhancedDataTypes">
<soapenv:Header>
<ns:RequesterCredentials>
<ebl:Credentials>
<ebl:Username>XXXXXXX</ebl:Username>
<ebl:Password>XXXXXXX</ebl:Password>
<ebl:Signature>XXXXXXX</ebl:Signature>
</ebl:Credentials>
</ns:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<ns:UpdateRecurringPaymentsProfileReq>
<ns:UpdateRecurringPaymentsProfileRequest>
<ebl:Version>63.0</ebl:Version>
<ebl:UpdateRecurringPaymentsProfileRequestDetails>
<ebl:ProfileID>XXXXXXXX</ebl:ProfileID>
<ebl:PaymentPeriod>
<ebl:BillingPeriod>Week</ebl:BillingPeriod>
<ebl:BillingFrequency>1</ebl:BillingFrequency>
<ebl:Amount>29.00</ebl:Amount>
</ebl:PaymentPeriod>
</ebl:UpdateRecurringPaymentsProfileRequestDetails>
</ns:UpdateRecurringPaymentsProfileRequest>
</ns:UpdateRecurringPaymentsProfileReq>
</soapenv:Body>
</soapenv:Envelope>

用户名。密码,签名和profileId设置正确,我刚刚删除它们以保证安全。

0 个答案:

没有答案