使用美国信用卡进行地址验证

时间:2015-05-12 05:19:37

标签: php

我想检查用户输入的地址是否与他的信用卡详细信息一致,但我不想向任何用户收取验证信用卡地址的费用。 我尝试使用条带验证地址: http://stripe.com/docs/api#create_card_token 但是当我检索令牌地址字段时,返回null

Stripe\Token JSON: {
"id": "tok_15xBRLBohZKQWMNn8j62VIZn",
"livemode": false,
"created": 1430376391,
"used": false,
"object": "token",
"type": "card",
"card": {
    "id": "card_15xBRLBohZKQWMNnFNlqKusp",
    "object": "card",
    "last4": "4242",
    "brand": "Visa",
    "funding": "credit",
    "exp_month": 8,
    "exp_year": 2016,
    "country": "US",
    "name": null,
    "address_line1": null,
    "address_line2": null,
    "address_city": null,
    "address_state": null,
    "address_zip": null,
    "address_country": null,
    "cvc_check": null,
    "address_line1_check": null,
    "address_zip_check": null,
    "dynamic_last4": null,
    "metadata": {
    }
  }
}

2 个答案:

答案 0 :(得分:1)

您在创建-showDetailViewController:sender:对象时从未输入过地址,因此无法验证地址。

创建card对象后,更新它以添加用户的地址,然后card应该通过或失败。

address_line1_check
  

https://stripe.com/docs/api#update_card

答案 1 :(得分:0)

我喜欢从数组开始,并使用json_encode。但那就是我。

事实证明,这是您收到请求的回复。

你必须在curl中使用这些参数:

curl https://api.stripe.com/v1/tokens \
   -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
   -d card[number]=4242424242424242 \
   -d card[exp_month]=12 \
   -d card[exp_year]=2016 \
   -d card[cvc]=123

示例响应

example response

$json = json_encode(array("id" => "tok_15xBRLBohZKQWMNn8j62VIZn",
"livemode" => false,
"created" => 1430376391,
"used" => false,
"object" => "token",
"type" => "card",
"card" => array(
    "id" => "card_15xBRLBohZKQWMNnFNlqKusp",
    "object" => "card",
    "last4" => "4242",
    "brand" => "Visa",
    "funding" => "credit",
    "exp_month" => 8,
    "exp_year" => 2016,
    "country" => "US",
    "name" => null,
    "address_line1" => null,
    "address_line2" => null,
    "address_city" => null,
    "address_state" => null,
    "address_zip" => null,
    "address_country" => null,
    "cvc_check" => null,
    "address_line1_check" => null,
    "address_zip_check" => null,
    "dynamic_last4" => null,
    "metadata" => '')
  ));

Stripe\Token JSON: {$json}