【问题标题】:How to do payment using paypal payflow vaulted credit card without using PNREF (gateway token)?如何在不使用 PNREF(网关令牌)的情况下使用 paypal payflow 拱形信用卡付款?
【发布时间】:2017-08-30 14:44:54
【问题描述】:

我已使用以下休息脚本将信用卡添加到保险库。

如何使用这张信用卡在 magento 结帐页面上进行付款?

$clientId="XXXXXXXXXXXXXXXXXXXXX";
$secret='XXXXXXXXXXXXXXXXXXXXXXX';

    $ipnexec = curl_init();

    curl_setopt($ipnexec, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token"); // test url

    curl_setopt($ipnexec, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ipnexec, CURLOPT_POST, true);
    curl_setopt($ipnexec, CURLOPT_USERPWD, $clientId.":".$secret);
    curl_setopt($ipnexec, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
    //curl_setopt($ipnexec, CURLOPT_POSTFIELDS, $req);
    //curl_setopt($ipnexec, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ipnexec, CURLOPT_RETURNTRANSFER, true);
    //curl_setopt($ipnexec, CURLOPT_TIMEOUT, 30);
    $ipnresult = curl_exec($ipnexec);
    $result = json_decode($ipnresult);

    if(!isset($result->access_token))
   {
    $this->messageManager->addErrorMessage(
        __('Invalid Card data, please try again!')
    );

    return $this->_redirect('vault/cards/listaction');
   }

        //print_r($result);
        //die;
    //echo "<pre>";
    $access_token = $result->access_token;
    //die($access_token);
    //print_r($result->access_token);
    //$token_type = $result->token_type;  
    curl_close($ipnexec);


 $scope = "https://api.sandbox.paypal.com/v1/vault/credit-cards";


  $ch = curl_init();
  //curl_setopt($ch, CURLOPT_HTTPHEADER, 1);
 $data = '
 {
"external_customer_id":"'.$customer_id.'",
 "external_card_id":"'.$external_card_id.'",
"payer_id":"'.$payer_id.'",
"type":"visa",
 "cvv2" : "'.$cvv2.'",
 "number":"'.str_replace(" ","",$number).'",
 "expire_month":"'.$expire_month.'",
 "expire_year":"'.$expire_year.'",
 "first_name":"'.$first_name.'",
 "last_name":"'.$last_name.'"

 }
    ';

       curl_setopt($ch, CURLOPT_URL,$scope);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: 
      application/json","Authorization: Bearer ".$access_token));
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


     $result = curl_exec($ch);

  if(empty($result))die("Error: No response.");
  else
  {
$json = json_decode($result);
//echo "<pre>";
//print_r($json);
//die;

if(!isset($json->payer_id))
{
$this->messageManager->addErrorMessage(
        __('Invalid Card data, please try again!')
    );

    return $this->_redirect('vault/cards/listaction');
}

 }
curl_close($ch);

【问题讨论】:

  • 请解决您的问题,您的代码不清楚。

标签: php magento paypal magento2 payflowpro


【解决方案1】:

如果您使用 REST API 将信用卡数据保存在 Vault 中,要执行付款,您需要使用 REST API。 Magento 有不同的设置。

如果你想使用保险库,你需要使用下面的例子

curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H "Content-Type:application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
  "id":"CPPAY-13U467758H032001PKPIFQZI",
  "intent":"sale",
  "payer":{
    "payment_method":"credit_card",
    "funding_instruments":[
      {
        "credit_card_token":{
          "credit_card_id":"CARD-1MD19612EW4364010KGFNJQI",
          "external_customer_id":"joe_shopper408-334-8890"
        }
      }
    ]
  },
  "transactions":[
    {
      "amount":{
        "total":"6.70",
        "currency":"USD"
      },
      "description":"Payment by vaulted credit card."
    }
  ]
}'

【讨论】:

    猜你喜欢
    • 2017-10-09
    • 1970-01-01
    • 2013-09-16
    • 2013-05-31
    • 2012-07-18
    • 2012-02-08
    • 2015-11-26
    • 1970-01-01
    • 2023-03-23
    相关资源
    最近更新 更多