使用SetPaymentsOptionsRequest时事务处理出错

时间:2014-06-05 14:40:56

标签: c# paypal paypal-sandbox

我正在努力将PayPal集成到客户的电子商务网站中。使用沙箱,我们让一切正常。我现在需要添加SetPaymentOptionsRequest以防止用户更改他的送货地址(他们在我们的网站上输入它,因此他们无法在PayPal更改它,因为我们网站上计算的运费不同)。它看起来工作正常,但登录PayPal沙箱网站以确认交易时收到3005错误。以下是相关代码(C#):

public string MakeChainedPayment(params params) {
  var request = new PayRequest {
    requestEnvelope = new RequestEnvelope("en_us"),
    actionType = "CREATE",
    cancelUrl = this._cancelUrl,
    currencyCode = this._currencyCode,
    returnUrl = this._returnUrl,
    ipnNotificationUrl = this._ipnNotificationUrl
  };

  // Some code to generate receivers, not important for this problem, I don't think

  var response = this._paymentService.Pay(request);

  switch (response.paymentExecStatus) {
    // This always returns "CREATED", as I'd want, so good up to here.
    case "CREATED":
      // If I leave this code out, PayPal works fine, but I need 
      // this part to do the shipping address verification.

      var p = new SetPaymentOptionsRequest();
      p.senderOptions = new SenderOptions();
      p.senderOptions.addressOverride = false;
      p.senderOptions.shippingAddress = new ShippingAddressInfo {
        // Setting from params: city, country, zip, state, street1, street2
      };

      p.payKey = response.payKey;
      p.requestEnvelope = request.requestEnvelope;

      SetPaymentOptionsResponse r = _paymentService.SetPaymentOptions(payOptsReq);
      break;

      // This always retuns r.error.Count = 0, r.responseEnvelope.ack = "SUCCESS",
      // so I think I'm good to go.
  }

  if (this._useSandbox) {
    return string.Concat("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=", response.payKey);
  }

    return string.Concat("https://www.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=", response.payKey);

}

2 个答案:

答案 0 :(得分:0)

当您的Paypal帐户的电子邮件地址尚未经过验证时,Paypal会返回此消息。要验证您的Paypal电子邮件帐户,请按以下步骤操作:

登录您的Paypal帐户。您应该位于“概览”标签中。

点击您的电子邮件地址,在“商家帐户概述”下,您将进入一个列出您的Paypal电子邮件地址的网页。

选择您的主要地址。

点击“确认”按钮。

按照Paypal的其他说明进行操作。

答案 1 :(得分:0)

问题是我为国家传递的问题;我发送的是“美国”,应该是“美国”。