简体   繁体   English

Paypal 沙盒帐户响应在服务器上失败

[英]Paypal sandbox account response fails on server

I'm new to paypal and sandbox, however the algorithm works fine with my on the localhost, whereas it fails to complete the transaction on remote, I'm using php laravel我是 paypal 和沙箱的新手,但是该算法在本地主机上可以正常工作,而无法在远程完成交易,我正在使用 php laravel

the algorithm on my paypal controller:我的 paypal controller 上的算法:

 $request = new OrdersCreateRequest();
    $request->prefer('return=representation');
    $request->body = [
         "intent" => "CAPTURE",
         "purchase_units" => [[
             "reference_id" => rand(000000,999999),
             "amount" => [
                 "value" => number_format($amount, 2, '.', ''),
                 "currency_code" => \App\Models\Currency::findOrFail(get_setting('system_default_currency'))->code
             ]
         ]],
         "application_context" => [
              "cancel_url" => url('paypal/payment/cancel'),
              "return_url" => url('paypal/payment/done')
         ]
     ];

    try {
        //ddd($request);
        // Call API with your client and get a response for your call
        $response = $client->execute($request);
       // ddd($response);
   

        // If call returns body in response, you can get the deserialized version from the result attribute of the response
        return Redirect::to($response->result->links[1]->href);

    }catch (HttpException $ex) {

    }

When I dump the response it's as:当我转储响应时,它是:

PayPalHttp\HttpResponse {#2005 ▼
+statusCode: 201
 +result: {#2012 ▼
 +"id": "29F719283B401012X"
 +"intent": "CAPTURE"
 +"status": "CREATED"
 +"purchase_units": array:1 [▼
  0 => {#1944 ▼
    +"reference_id": "481922"
    +"amount": {#1948 ▼
      +"currency_code": "USD"
      +"value": "150.00"
    }
    +"payee": {#1975 ▼
      +"email_address": "sb-adxtx19866369@business.example.com"
      +"merchant_id": "MUJ4QB7EWSWDJ"
    }
  }
]
+"create_time": "2022-08-30T10:04:38Z"
+"links": array:4 [▼
  0 => {#1949 ▼
    +"href": "https://api.sandbox.paypal.com/v2/checkout/orders/29F719283B401012X"
    +"rel": "self"
    +"method": "GET"
  }
  1 => {#2017 ▼
    +"href": "https://www.sandbox.paypal.com/checkoutnow?token=29F719283B401012X"
    +"rel": "approve"
    +"method": "GET"
  }
  2 => {#2010 ▼
    +"href": "https://api.sandbox.paypal.com/v2/checkout/orders/29F719283B401012X"
    +"rel": "update"
    +"method": "PATCH"
  }
  3 => {#2009 ▼
    +"href": "https://api.sandbox.paypal.com/v2/checkout/orders/29F719283B401012X   /capture"
    +"rel": "capture"
    +"method": "POST"
    }
  ]
 }

} }

and The Exception i get:和我得到的例外:

PayPalHttp\HttpException
{"name":"UNPROCESSABLE_ENTITY","details":   [{"issue":"COMPLIANCE_VIOLATION","description":"Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"a548bb80c1863","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION","rel":"information_link","method":"GET"}]}

I've tried multiple ways to resolve it like: 1- Changing the sandbox account region from EGY to US.我尝试了多种解决方法,例如: 1- 将沙盒帐户区域从 EGY 更改为 US。 2- Changing the entire paypal account. 2-更改整个 paypal 帐户。

I would appreciate a little assistance here.我会很感激这里的一点帮助。 Thanks in advance.提前致谢。

COMPLIANCE_VIOLATION COMPLIANCE_VIOLATION

For sandbox testing: the receiving business account should not be from one of the countries listed here .对于沙盒测试:接收企业帐户不应来自此处列出的国家之一 So, it should work if you try again with eg a US receiver account (payer/sending account does not matter)因此,如果您再次尝试使用美国收款人帐户(付款人/发送帐户无关紧要),它应该可以工作

In the live environment: this answer has more details on the set up needed to receive payments in one of those countries with auto withdrawal to a card or bank.在实时环境中: 此答案提供了有关在其中一个可以自动提款到卡或银行的国家/地区接收付款所需的设置的更多详细信息

After a long debugging, the thing turn out to be after the payments.经过长时间的调试,事情原来是在付款之后。 nothing wrong with paypal. paypal 没有问题。 I debugged untill I found the payment status " completed " After the payment, I update my DB records.我调试直到我发现付款状态“ completed ”付款后,我更新了我的数据库记录。 in laravel I used findOrFail($id) method which turns out to be the problem It fails to find the record, I don't know why however this terminates the logic.在 laravel 中,我使用findOrFail($id)方法,结果证明是问题它无法找到记录,我不知道为什么但这会终止逻辑。

thank you guys.感谢你们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM