PayPal交易在商家帐户中不可见

时间:2018-10-11 20:51:25

标签: paypal payment-gateway paypal-sandbox paypal-rest-sdk merchant-account

我正在使用带有.net core 2.1 webapi的SDK 2.0.0-beta版本,以使用重定向流在沙盒环境中与paypal集成。

我能够将其成功地与Paypal集成,并且付款过程会以成功的响应完成。 但是当我查看商家帐户时,那里没有交易。

请在下面找到我的代码:

public string CreatePayment()

{

var clientId = "XXXXXXXXXXX";
var secret = "XXXXXXXXXXXXXXXXX";
var environment = new SandboxEnvironment(clientId, secret);
var client = new PayPalHttpClient(environment);

var request = BuildPaymentRequest(paymentDetails);

var result = ExecutePaymentRequest(client, request);

return result;

}

private PaymentCreateRequest PaymentRequest()
{
     var payment = new PayPal.v1.Payments.Payment()
     {
         Intent = "sale",

         Transactions = new List()
         {
                new Transaction()
               {
                  Amount = new Amount()
                  {
                     Total = "10",
                     Currency = "USD"
                  }
                }
         },
         RedirectUrls = new RedirectUrls() 
         {
             ReturnUrl = "http://test.com/success",
             CancelUrl = ""http://test.com/cancel""
         },
         Payer = new Payer()
        {
            PaymentMethod = "PayPal"
        }
      };

         PaymentCreateRequest request = new PaymentCreateRequest();
         return request.RequestBody(payment);
 }


private async string ExecutePayment(PayPalHttpClient client, 
 PaymentCreateRequest request)
 {
    System.Net.HttpStatusCode statusCode;
     PaymentDetails paymentDetails = null;

    BraintreeHttp.HttpResponse response = await client.Execute(request);
    statusCode = response.StatusCode;
    Payment result = response.Result<Payment>();
    string redirectUrl =
        result.Links.Where(x => x.Rel.Equals("approval_url")).Select(y => y.Href).SingleOrDefault();

   return redirectUrl ;

}

使用此代码可以完成多次交易,但它们都不会出现在商家沙箱帐户中。商户沙箱帐户的创建过程如下:

登录到:https://developer.paypal.com/developer/applications/

创建了商家和买方帐户的“帐户帐户”部分

转到MyApps和凭据

在REST API应用中创建新应用

点击该应用并获取客户端ID和机密

在.net核心项目中使用客户端ID和密码。

有人可以帮我吗?

0 个答案:

没有答案