使用SetPaymentsOptionsRequest处理交易时出错

本文关键字:出错 交易 处理 SetPaymentsOptionsRequest 使用 | 更新日期: 2023-09-27 18:06:48

我正致力于将PayPal整合到客户的电子商务网站。使用沙盒,我们让一切工作正常。我现在需要添加SetPaymentOptionsRequest来防止用户更改他的送货地址(他们在我们的网站上输入它,所以他们不能在PayPal上更改它,因为我们网站上计算的运费不同)。它似乎工作得很好,但我得到一个3005错误,当登录到PayPal沙箱网站确认交易。下面是相关代码(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);
}

使用SetPaymentsOptionsRequest处理交易时出错

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

登录您的Paypal账户。你应该在"概览"选项卡中。

点击您的电子邮件地址,在"商业帐户概述"下,您将被带到一个列出您的Paypal电子邮件地址的网页。

选择您的主地址。

点击"确认"按钮。

问题是我传递给国家的东西;我输入的是"USA",应该是"US"