简体   繁体   English

如何使用 symfony 和意图支付 API 完成我的条带支付?

[英]How to complete my stripe payment with symfony and intent payment API?

I try to put stripe on my website, it takes the payment but it still incomplete be cause "the customer doesn't have payement methods".我尝试在我的网站上添加条纹,它需要付款但仍然不完整,因为“客户没有付款方式”。 I dont understand how to resolve this issue.我不明白如何解决这个问题。

public function stripeAction(Request $request) {
    \Stripe\Stripe::setApiKey('sk_test_UYs0lRfiKXpBymFf0Qlp2BOe00c5XJG5q1');
    $paymethod =  \Stripe\PaymentMethod::create([
        'type' => 'card',
        'card' => [
            'number' => '4242424242424242',
            'exp_month' => 2,
            'exp_year' => 42,
            'cvc' => '424',
        ],
    ]);

    //    dd($paymethod['card']['checks']);

    $intent =  \Stripe\PaymentIntent::create([
        'amount' => 500,
        'currency' => 'eur',
        "payment_method_types" => ['card'],
        'metadata' => ['integration_check' => 'accept_a_payment']
    ]);
}

The error seems quite straightforward to me: you've create a PaymentIntent , without a payment_method property.这个错误对我来说似乎很简单:你创建了一个PaymentIntent ,没有一个payment_method属性。 As you also didn't set a customer property (which could imply a preferred payment_method ), Stripe does not know which payment method to use for the intent.由于您还没有设置customer属性(这可能意味着首选的payment_method ),Stripe 不知道该意图使用哪种付款方式。

$intent = \Stripe\PaymentIntent::create([
    'amount' => 500,
    'currency' => 'eur',
    'payment_method_types' => ['card'],
    'metadata' => ['integration_check' => 'accept_a_payment'],
    'payment_method' => $paymethod->id
]);

Docs here: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method此处的文档: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method

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

相关问题 如果不存在付款意向客户,如何创建客户 API 条带 PHP - How to create a customer if it does not exist with payment intent API stripe PHP 使用 Stripe API,如何获取创建 payment_intent Object 的 Checkout Session 的 session_id,来自 payment_intent.succeeded Webhook - With Stripe API, How To Get session_id of Checkout Session That Created a payment_intent Object, From payment_intent.succeeded Webhook 支付意图问题 Stripe Connect - Payment Intent issues Stripe Connect 将非活动订阅条纹化为付款意图 - Stripe inactive subscription as Payment Intent Stripe API 和 PHP:支付与支付意图/费用的关系 - Stripe API and PHP: Relationship of PAYOUTS to Payment Intent / Charges Symfony 付款后条纹断开 - Symfony Stripe Disconnect after Payment 如何计算条纹支付api中的gbp费用 - how to calculate gbp charges in stripe payment api 如何从 Stripe webhook/Payment Intent 获取更多数据 - How to get more data from Stripe webhook/Payment Intent Stripe Payment Intent : 我们可以保留付款金额一段时间吗? 如果是,那么需要多少时间? - Stripe Payment Intent : can we hold the payment Amount for some time. If yes then how much time? 如何在 Stripe Payment Intent 中修复客户端或服务器端的 3D 安全确认付款? - How to fix the 3D secure confirm Payment on client side or on server side in Stripe Payment Intent?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM