条纹支付不适用于实时环境

Posted

技术标签:

【中文标题】条纹支付不适用于实时环境【英文标题】:stripe payment not working on live environment 【发布时间】:2017-08-26 15:04:30 【问题描述】:
// Create a customer 
       $customer = \Stripe\Customer::create(array(
                  "email" => $email,
                  "metadata" => array("name" => $full_name),
                  "source" => $token, // obtained with Stripe.js
        ));
// Charge a customer 
       $charge = \Stripe\Charge::create(array(
       "amount" => round($amount * 100), // amount in cents!,
       "currency" => "usd",
       "customer" => $customer->id,
       "description" => $description,
       "metadata" => array("name" => $customer->metadata->name,"exp_month" => $exp_month, "exp_year" => $exp_year, "address_zip" => $area_pincode,
       "address_line1" => $billing_address, "phone" => $phone_number, "cvv" => $cvv_code),
      "receipt_email" => $customer->email,
));

此代码运行良好,但在创建费用后,我在源密钥上获得了 null 名称,任何人都可以帮我弄清楚,因为付款在实时环境中不起作用。这是充电响应

 Stripe\Charge Object

( [_opts:protected] => Stripe\Util\RequestOptions 对象 ( [标题] => 数组 ( )

        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
    )

[_values:protected] => Array
    (
        [id] => ch_1A3jQVG5CbtVORSys2Ho0vYD
        [object] => charge
        [amount] => 5600
        [amount_refunded] => 0
        [application] => 
        [application_fee] => 
        [balance_transaction] => txn_1A3jQVG5CbtVORSyduH3NX76
        [captured] => 1
        [created] => 1491042347
        [currency] => usd
        [customer] => 
        [description] => hello world
        [destination] => 
        [dispute] => 
        [failure_code] => 
        [failure_message] => 
        [fraud_details] => Array
            (
            )

        [invoice] => 
        [livemode] => 
        [metadata] => Stripe\AttachedObject Object
            (
                [_opts:protected] => Stripe\Util\RequestOptions Object
                    (
                        [headers] => Array
                            (
                            )

                        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
                    )

                [_values:protected] => Array
                    (
                        [name] => kartik
                        [exp_month] => 03
                        [exp_year] => 25
                        [address_zip] => 1745236
                        [address_line1] => palampur
                        [phone] => 8956235689
                        [cvv] => 123
                    )

                [_unsavedValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_transientValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_retrieveOptions:protected] => Array
                    (
                    )

                [_lastResponse:protected] => 
            )

        [on_behalf_of] => 
        [order] => 
        [outcome] => Stripe\StripeObject Object
            (
                [_opts:protected] => Stripe\Util\RequestOptions Object
                    (
                        [headers] => Array
                            (
                            )

                        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
                    )

                [_values:protected] => Array
                    (
                        [network_status] => approved_by_network
                        [reason] => 
                        [risk_level] => normal
                        [seller_message] => Payment complete.
                        [type] => authorized
                    )

                [_unsavedValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_transientValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_retrieveOptions:protected] => Array
                    (
                    )

                [_lastResponse:protected] => 
            )

        [paid] => 1
        [receipt_email] => 
        [receipt_number] => 
        [refunded] => 
        [refunds] => Stripe\Collection Object
            (
                [_requestParams:protected] => Array
                    (
                    )

                [_opts:protected] => Stripe\Util\RequestOptions Object
                    (
                        [headers] => Array
                            (
                            )

                        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
                    )

                [_values:protected] => Array
                    (
                        [object] => list
                        [data] => Array
                            (
                            )

                        [has_more] => 
                        [total_count] => 0
                        [url] => /v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds
                    )

                [_unsavedValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_transientValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_retrieveOptions:protected] => Array
                    (
                    )

                [_lastResponse:protected] => 
            )

        [review] => 
        [shipping] => 
        [source] => Stripe\Card Object
            (
                [_opts:protected] => Stripe\Util\RequestOptions Object
                    (
                        [headers] => Array
                            (
                            )

                        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
                    )

                [_values:protected] => Array
                    (
                        [id] => card_1A3jQSG5CbtVORSysMV7SyBs
                        [object] => card
                        [address_city] => 
                        [address_country] => 
                        [address_line1] => 
                        [address_line1_check] => 
                        [address_line2] => 
                        [address_state] => 
                        [address_zip] => 
                        [address_zip_check] => 
                        [brand] => Visa
                        [country] => US
                        [customer] => 
                        [cvc_check] => pass
                        [dynamic_last4] => 
                        [exp_month] => 3
                        [exp_year] => 2025
                        [fingerprint] => EJUqgq2clF6JUp8f
                        [funding] => credit
                        [last4] => 4242
                        [metadata] => Stripe\AttachedObject Object
                            (
                                [_opts:protected] => Stripe\Util\RequestOptions Object
                                    (
                                        [headers] => Array
                                            (
                                            )

                                        [apiKey] => sk_test_UsVZ1TRkIExFae3jiWUHvb2r
                                    )

                                [_values:protected] => Array
                                    (
                                    )

                                [_unsavedValues:protected] => Stripe\Util\Set Object
                                    (
                                        [_elts:Stripe\Util\Set:private] => Array
                                            (
                                            )

                                    )

                                [_transientValues:protected] => Stripe\Util\Set Object
                                    (
                                        [_elts:Stripe\Util\Set:private] => Array
                                            (
                                            )

                                    )

                                [_retrieveOptions:protected] => Array
                                    (
                                    )

                                [_lastResponse:protected] => 
                            )

                        [name] => 
                        [tokenization_method] => 
                    )

                [_unsavedValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_transientValues:protected] => Stripe\Util\Set Object
                    (
                        [_elts:Stripe\Util\Set:private] => Array
                            (
                            )

                    )

                [_retrieveOptions:protected] => Array
                    (
                    )

                [_lastResponse:protected] => 
            )

        [source_transfer] => 
        [statement_descriptor] => 
        [status] => succeeded
        [transfer_group] => 
    )

[_unsavedValues:protected] => Stripe\Util\Set Object
    (
        [_elts:Stripe\Util\Set:private] => Array
            (
            )

    )

[_transientValues:protected] => Stripe\Util\Set Object
    (
        [_elts:Stripe\Util\Set:private] => Array
            (
            )

    )

[_retrieveOptions:protected] => Array
    (
    )

[_lastResponse:protected] => Stripe\ApiResponse Object
    (
        [headers] => Array
            (
                [Server] => nginx
                [Date] => Sat, 01 Apr 2017 10:25:47 GMT
                [Content-Type] => application/json
                [Content-Length] => 1926
                [Connection] => keep-alive
                [Access-Control-Allow-Credentials] => true
                [Access-Control-Allow-Methods] => GET, POST, HEAD, OPTIONS, DELETE
                [Access-Control-Allow-Origin] => *
                [Access-Control-Max-Age] => 300
                [Cache-Control] => no-cache, no-store
                [Request-Id] => req_AOWT4rpoHd0H0A
                [Stripe-Version] => 2017-02-14
                [Strict-Transport-Security] => max-age=31556926; includeSubDomains
            )

        [body] => 

"id": "ch_1A3jQVG5CbtVORSys2Ho0vYD", “对象”:“收费”, “金额”:5600, “金额退款”:0, “应用程序”:空, “申请费”:空, “balance_transaction”:“txn_1A3jQVG5CbtVORSyduH3NX76”, “捕获”:是的, “创建”:1491042347, “货币:美元”, “客户”:空, “描述”:“你好世界”, “目的地”:空, “争议”:空, “故障代码”:空, “failure_message”:空, “欺诈细节”:, “发票”:空, “现场模式”:假, “元数据”: “名称”:“卡蒂克”, "exp_month": "03", "exp_year": "25", "address_zip": "1745236", “address_line1”:“palampur”, “电话”:“8956235689”, “简历”:“123” , “on_behalf_of”:空, “订单”:空, “结果”: “network_status”:“approved_by_network”, “原因”:空, "risk_level": "正常", "seller_message": "付款完成。", “类型”:“授权” , “付费”:是的, “receipt_email”:空, “收据编号”:空, “退款”:假, “退款”: “对象”:“列表”, “数据”: [], “has_more”:假, “总数”:0, "url": "/v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds" , “审查”:空, “航运”:空, “资源”: "id": "card_1A3jQSG5CbtVORSysMV7SyBs", “对象”:“卡片”, “地址城市”:空, “地址国家”:空, “address_line1”:空, “address_line1_check”:空, “address_line2”:空, “地址状态”:空, “地址_zip”:空, “address_zip_check”:空, “品牌”:“签证”, “国家”:“美国”, “客户”:空, “cvc_check”:“通过”, “dynamic_last4”:空, “exp_month”:3, "exp_year": 2025, “指纹”:“EJUqgq2clF6JUp8f”, “资金”:“信用”, "last4": "4242", “元数据”:, “名称”:空, “标记化方法”:空 , “source_transfer”:空, “statement_descriptor”:空, “状态”:“成功”, “转移组”:空

        [json] => Array
            (
                [id] => ch_1A3jQVG5CbtVORSys2Ho0vYD
                [object] => charge
                [amount] => 5600
                [amount_refunded] => 0
                [application] => 
                [application_fee] => 
                [balance_transaction] => txn_1A3jQVG5CbtVORSyduH3NX76
                [captured] => 1
                [created] => 1491042347
                [currency] => usd
                [customer] => 
                [description] => hello world
                [destination] => 
                [dispute] => 
                [failure_code] => 
                [failure_message] => 
                [fraud_details] => Array
                    (
                    )

                [invoice] => 
                [livemode] => 
                [metadata] => Array
                    (
                        [name] => kartik
                        [exp_month] => 03
                        [exp_year] => 25
                        [address_zip] => 1745236
                        [address_line1] => palampur
                        [phone] => 8956235689
                        [cvv] => 123
                    )

                [on_behalf_of] => 
                [order] => 
                [outcome] => Array
                    (
                        [network_status] => approved_by_network
                        [reason] => 
                        [risk_level] => normal
                        [seller_message] => Payment complete.
                        [type] => authorized
                    )

                [paid] => 1
                [receipt_email] => 
                [receipt_number] => 
                [refunded] => 
                [refunds] => Array
                    (
                        [object] => list
                        [data] => Array
                            (
                            )

                        [has_more] => 
                        [total_count] => 0
                        [url] => /v1/charges/ch_1A3jQVG5CbtVORSys2Ho0vYD/refunds
                    )

                [review] => 
                [shipping] => 
                [source] => Array
                    (
                        [id] => card_1A3jQSG5CbtVORSysMV7SyBs
                        [object] => card
                        [address_city] => 
                        [address_country] => 
                        [address_line1] => 
                        [address_line1_check] => 
                        [address_line2] => 
                        [address_state] => 
                        [address_zip] => 
                        [address_zip_check] => 
                        [brand] => Visa
                        [country] => US
                        [customer] => 
                        [cvc_check] => pass
                        [dynamic_last4] => 
                        [exp_month] => 3
                        [exp_year] => 2025
                        [fingerprint] => EJUqgq2clF6JUp8f
                        [funding] => credit
                        [last4] => 4242
                        [metadata] => Array
                            (
                            )

                        [name] => 
                        [tokenization_method] => 
                    )

                [source_transfer] => 
                [statement_descriptor] => 
                [status] => succeeded
                [transfer_group] => 
            )

        [code] => 200
    )

) 这里

【问题讨论】:

您能否正确格式化您的问题 - 您的代码和响应示例都应该在格式化的代码块中。您还需要准确说明您遇到了什么错误 - 如果响应不是您所期望的,请指出响应中的无效项目以引起注意。 【参考方案1】:

我遇到了同样的问题。从 php 中返回的应该是:

echo (json_encode(变量));

这将为您提供可以使用的结果

【讨论】:

以上是关于条纹支付不适用于实时环境的主要内容,如果未能解决你的问题,请参考以下文章

Firestore 实时更新不适用于 recyclerview

Verbatim PHP 代码适用于当前的实时站点,但不适用于新站点(本地或实时)

实时查询插件不适用于可见属性选择器

数据表不适用于实时更新数据

标头位置不适用于实时服务器,但适用于 localhost

Swift UI 实时预览画布不适用于 macOS Catalina 和 Xcode 11.0