如何使用PHP自定义卷曲删除条带上的客户?

时间:2017-03-23 02:08:22

标签: php curl stripe-payments

code

上面的图片是我的代码的结果。我该如何删除它?我不想使用库,我想在使用库之前学习如何使用PHP curl。

<?php
function DeleteCustomer() {

    $array = array(
        'id' => 'cus_AKjDJGDrHovimg'
        );

    $ch = curl_init();
    $headers = array('Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx');
    curl_setopt($ch, CURLOPT_URL,'https://api.stripe.com/v1/customers');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
   curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array));
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $output=curl_exec($ch);
    curl_close($ch);
     $output = json_decode($output,true);
    return $output;
 }

$a = DeleteCustomer();
print_r($a);

?>

感谢那些愿意回答的人。

1 个答案:

答案 0 :(得分:0)

我设法使用此代码删除条带客户。 :d

<?php
function DeleteCustomer() {

    $ch = curl_init();
    $headers = array('Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx');
    curl_setopt($ch, CURLOPT_URL,'https://api.stripe.com/v1/customers/cus_AKjDJGDrHovimg');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($ch);
    $result = json_decode($result);
    curl_close($ch);

    return $result;

 }

$a = DeleteCustomer();
echo'<pre>';
print_r($a);

?>