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

时间:2022-05-08 17:26:11

I want to check whether user entered address is correct with his credit card details, but I don't want to charge any user to verify credit card address. I have tried to verify address using stripe: http://stripe.com/docs/api#create_card_token but when I retrieve token address fields returns null.

我想用他的信用卡详细信息检查用户输入的地址是否正确,但我不想向任何用户收取验证信用卡地址的费用。我试图使用stripe验证地址: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 个解决方案

#1


You never entered an address when you created the card object, so there is no address to be verified.

您在创建卡对象时从未输入过地址,因此没有要验证的地址。

After you create the card object, update it to add the user's address, and then the address_line1_check should pass or fail.

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

\Stripe\Stripe::setApiKey("sk_test_BLAHBLAH");

$cu = \Stripe\Customer::retrieve("cus_BLAHBLAH");
$card = $cu->sources->retrieve("card_BLAHBLAH");
$card->address_line1 = "123 Bumbleberry Road";
$card->address_city = "Ridgewood";
$card->address_state = "NJ";
$card->address_zip = "07450";
$card->address_country = "US";
$card->save();

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

#2


I like to start with an array, and use json_encode. But that's me.

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

It turns out that is the RESPONSE you get to your request.

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

You have to use these parameter in curl:

你必须在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}

#1


You never entered an address when you created the card object, so there is no address to be verified.

您在创建卡对象时从未输入过地址,因此没有要验证的地址。

After you create the card object, update it to add the user's address, and then the address_line1_check should pass or fail.

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

\Stripe\Stripe::setApiKey("sk_test_BLAHBLAH");

$cu = \Stripe\Customer::retrieve("cus_BLAHBLAH");
$card = $cu->sources->retrieve("card_BLAHBLAH");
$card->address_line1 = "123 Bumbleberry Road";
$card->address_city = "Ridgewood";
$card->address_state = "NJ";
$card->address_zip = "07450";
$card->address_country = "US";
$card->save();

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

#2


I like to start with an array, and use json_encode. But that's me.

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

It turns out that is the RESPONSE you get to your request.

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

You have to use these parameter in curl:

你必须在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}