如何在条带中实现

如何在条带中实现

本文介绍了如何在条带中实现 3d 安全认证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//代码示例<?phpsession_start();require_once("F:\wamp64\www\lib\stripe-php-7.27.2\init.php");\Stripe\Stripe::setApiKey('sk_test_vXXXXXXXXXXXXXlmwqE');$name = $_SESSION['namex'];$email = $_SESSION['emailx'];$phno = $_SESSION['mobilex'];$目的 = $_SESSION['目的x'];$amount = $_SESSION['amountx'];$txn = $_SESSION['txnn'];$token = $_POST['stripeToken'];$fee = $amount*0.02;$tax = $fee*0.18;$famt = round($amount+$fee+$tax);//支付信息$charge = \Stripe\PaymentIntent::create(['金额' =>$famt*100,'货币' =>'inr','receipt_email'=>$电子邮件,]);$收费 ->确认(['payment_method' => 'pm_card_threeDSecureRequired','return_url' => 'http://localhost/chstripe.php']);#$charge ->捕获();print_r($charge);?><!DOCTYPE html><html lang="en" dir="ltr"><头><meta charset="utf-8"><title>付款状态|条纹<身体><div class="display-from"><表格><头></br>++++++++++++++++++++++++++++++++++++++++++++++++</br>下面给出最终细节</br>++++++++++++++++++++++++++++++++++++++++++++++ </br></thead><tr><td>名称:</td><td><?php echo $name;?></td></tr><tr><td>电子邮件:</td><td><?php echo $email;?></td></tr><tr><td>手机:</td><td><?php echo $phno;?></td></tr><tr><td>金额:</td><td><?php echo $amount;?></td></tr><tr><td>银行手续费:</td><td><?php echo $fee;?></br><span>(交易金额的 2%)</span></td></tr><tr><td>税:</td><td><?php echo $tax;?><br><span>(GST 18% 适用于银行费用)</span></td></tr></tbody>

</html>

//Stripe Payment Intent的响应日志POST/v1/payment_intents/pi_1GPrqLK91kC2EVK/确认200 正常查看日志详细信息请求参数{"payment_method": "pm_card_threeDSecureRequired","return_url": "http://localhost/chstripe.php"}响应体{"id": "pi_1GPrqLK91kC2EVK","object": "payment_intent",last_payment_error":空,实时模式":假,下一步行动":{redirect_to_url":{"return_url": "http://localhost/chstripe.php","url": "https://hooks.stripe.com/redirect/authenticate/src_1GPrqNK91kC2BHdNCUicA4Fq?client_secret=src_client_secret_kFR236NoiN07OUahwN0eR1JB"},类型":redirect_to_url"},"payment_method": "pm_1GPrqMK91kC2BHdNOzYpCnGS","status": "requires_action",金额":16200,"amount_capturable": 0,"amount_received": 0,应用程序":空,application_fee_amount":空,canceled_at":空,取消原因":空,"capture_method": "自动",费用":{对象":列表",数据": [],has_more":假,"total_count": 0,"url": "/v1/charges?payment_intent=pi_1GPrqLK91kC2EVK"},"client_secret": "pi_1GPrqVK4Z_secret_GL8c7Y7Wt","confirmation_method": "自动",创建":1584975933,"货币": "inr",客户":空,描述":空,发票":空,元数据":{},on_behalf_of":空,payment_method_options":{卡片": {分期付款":空,"request_three_d_secure": "自动"}},payment_method_types":[卡片"],"receipt_email": "[email protected]",评论":空,setup_future_usage":空,运输":空,来源":空,statement_descriptor":空,statement_descriptor_suffix":空,传输数据":空,transfer_group":空}

这是我用来处理用户付款的代码示例.我无法实施 3d 安全身份验证,因此我的付款失败,显示卡不支持此类付款.当我尝试联系支持人员时,他们说这是由于缺乏 3D 安全身份验证.谁能帮我解决这个问题.运行此代码后,我检查了条带仪表板中的日志,它显示 screenshot >>[ 事件活动/状态 ] <<响应 在上面的代码段中给出.

解决方案

前端看到status: requires_action需要使用handleCardAction() [0]在您已在后端确认的 PaymentIntent 上.有关该步骤的基本集成,请参阅 Stripe 的代码示例 [1].

[0] https://stripe.com/docs/js/payment_intents/handle_card_action

[1] https://stripe.com/docs/payments/accept-a-payment-synchronously#web-handle-next-actions

//Code Sample


<?php
session_start();
require_once("F:\wamp64\www\lib\stripe-php-7.27.2\init.php");
\Stripe\Stripe::setApiKey('sk_test_vXXXXXXXXXXXXXlmwqE');
$name = $_SESSION['namex'];
$email = $_SESSION['emailx'];
$phno = $_SESSION['mobilex'];
$purpose = $_SESSION['purposex'];
$amount = $_SESSION['amountx'];
$txn =   $_SESSION['txnn'];
$token = $_POST['stripeToken'];
$fee  = $amount*0.02;
$tax  = $fee*0.18;
$famt = round($amount+$fee+$tax);
// payment information
$charge = \Stripe\PaymentIntent::create([
  'amount' => $famt*100,
  'currency' => 'inr',
  'receipt_email'=> $email,
]);
$charge -> confirm(['payment_method' => 'pm_card_threeDSecureRequired','return_url' => 'http://localhost/chstripe.php']);
#$charge -> capture();
print_r($charge);
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Payment Status | STRIPE</title>
  </head>
  <body>
    <div class="display-from">
      <table>
<thead> </br> ++++++++++++++++++++++++++++++++++++++++++++++</br>
Final Details Are Given Below </br>++++++++++++++++++++++++++++++++++++++++++++++ </br>
</thead>
<tbody>
  <tr><td>Name:</td><td><?php echo $name; ?></td></tr>
  <tr><td>Email:</td><td><?php echo $email; ?></td></tr>
  <tr><td>Mobile:</td><td><?php echo $phno; ?></td></tr>
  <tr><td>Amount:</td><td><?php echo $amount; ?></td></tr>
  <tr><td>Bank Charge:</td><td><?php echo $fee; ?> </br> <span>(2% of Transaction Amount)</span> </td></tr>
  <tr><td>Tax:</td><td><?php echo $tax; ?> <br><span>(GST 18% Applicable on Bank Charge)</span> </td></tr>
</tbody>
      </table>
    </div>
  </body>
</html>

//Response Log for Stripe Payment Intent




POST /v1/payment_intents/pi_1GPrqLK91kC2EVK/confirm

200 OK


View log detail


Request parameters
{
  "payment_method": "pm_card_threeDSecureRequired",
  "return_url": "http://localhost/chstripe.php"
}



Response body
{
  "id": "pi_1GPrqLK91kC2EVK",
  "object": "payment_intent",
  "last_payment_error": null,
  "livemode": false,
  "next_action": {
    "redirect_to_url": {
      "return_url": "http://localhost/chstripe.php",
      "url": "https://hooks.stripe.com/redirect/authenticate/src_1GPrqNK91kC2BHdNCUicA4Fq?client_secret=src_client_secret_kFR236NoiN07OUahwN0eR1JB"
    },
    "type": "redirect_to_url"
  },
  "payment_method": "pm_1GPrqMK91kC2BHdNOzYpCnGS",
  "status": "requires_action",
  "amount": 16200,
  "amount_capturable": 0,
  "amount_received": 0,
  "application": null,
  "application_fee_amount": null,
  "canceled_at": null,
  "cancellation_reason": null,
  "capture_method": "automatic",
  "charges": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/charges?payment_intent=pi_1GPrqLK91kC2EVK"
  },
  "client_secret": "pi_1GPrqVK4Z_secret_GL8c7Y7Wt",
  "confirmation_method": "automatic",
  "created": 1584975933,
  "currency": "inr",
  "customer": null,
  "description": null,
  "invoice": null,
  "metadata": {
  },
  "on_behalf_of": null,
  "payment_method_options": {
    "card": {
      "installments": null,
      "request_three_d_secure": "automatic"
    }
  },
  "payment_method_types": [
    "card"
  ],
  "receipt_email": "[email protected]",
  "review": null,
  "setup_future_usage": null,
  "shipping": null,
  "source": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "transfer_data": null,
  "transfer_group": null
}

This is the code sample I use to process payment from user. I cannot able to implement 3d secure authentication so my payments are failed showing card doesn't support this type of payment. When I try to contact support they say it's due to lack of 3D secure authentication.Can anyone help me with this. After running this code I check log in stripe dashboard, and it says screenshot >>[ Event Activity/Status ] << and response is given in above snippet.

解决方案

You need to use handleCardAction() [0] on the frontend when you see status: requires_action on a PaymentIntent that you've confirmed on the backend. See Stripe's code example [1] for a basic integration of that step.

[0] https://stripe.com/docs/js/payment_intents/handle_card_action

[1] https://stripe.com/docs/payments/accept-a-payment-synchronously#web-handle-next-actions

这篇关于如何在条带中实现 3d 安全认证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:24