小编K. *_*wan的帖子

Stripe 400 错误“无效正整数”

我有一个真正的问题。我正在尝试为一个非营利组织建立一个捐赠页面,该页面通过 Stripe 向人们收费。我尝试进行的每次充电都会给我一个错误,内容如下:

解析的请求帖子正文

{
    "card"        : "TOKEN WAS HERE",
    "description" : "Donation by   ()",
    "amount"      : "0",
    "currency"    : "usd"
}
Run Code Online (Sandbox Code Playgroud)

响应机构:

{
    "error" :
    {
        "type"    : "invalid_request_error",
        "message" : "Invalid positive integer",
        "param"   : "amount"
    }
}
Run Code Online (Sandbox Code Playgroud)

认为我传递给 Stripe 的金额有问题(很明显,Stripe 认为它收到了一定数量的0- 我只是不确定它是否真的是) - 但我绝对无法弄清楚它是什么。这是我页面上代码的完整范围:

<?php
    require( 'Stripe/init.php' );

    // Load configuration settings
    $config = require( 'config.php' );

    // Force https
    if ( $config[ 'test-mode' ] &&
         $_SERVER[ 'HTTPS' ] != 'on' )
    { …
Run Code Online (Sandbox Code Playgroud)

php stripe-payments

5
推荐指数
1
解决办法
8993
查看次数

Elixir:尝试将地图写入CSV,写成流结果

我一直在这个问题上摸不着头脑.我正在尝试编写一个程序,将给定文本文件中每个单词的频率输出到.csv文件.我已经成功创建了查找每个单词频率的函数,并将其结果作为映射输出,但我的tocsv函数由于某种原因将结果写为Stream结果,我无法弄清楚原因,或者如何避免这种情况.这是我的代码:

defmodule WordFrequency do

  def wordCount(readFile) do
     readFile
     |> words
     |> count
     |> tocsv
  end

  defp words(file) do
    file
    |> File.stream!
    |> Stream.map(&String.trim_trailing(&1))
    |> Stream.map(&String.split(&1,~r{[^A-Za-z0-9_]}))
    |> Enum.to_list
    |> List.flatten

  end

  defp count(words) when is_list(words) do
    Enum.reduce(words, %{}, &update_count/2)
  end

  defp update_count(word, acc) do
    Map.update acc, String.to_atom(word), 1, &(&1 + 1)
  end

  defp tocsv(map) do
    file = File.open!("test.csv", [:write, :utf8])
    map
    |> IO.inspect
    |> Enum.map(&CSV.encode(&1))
    |> Enum.each(&IO.inspect(file, &1, []))
  end

end
Run Code Online (Sandbox Code Playgroud)

count(它是一个测试文件)的结果是:

bitterness: 1, fan: 1, respiration: 1, radiator: 1, ceiling: …
Run Code Online (Sandbox Code Playgroud)

csv stream elixir

1
推荐指数
1
解决办法
1717
查看次数

标签 统计

csv ×1

elixir ×1

php ×1

stream ×1

stripe-payments ×1