如何在条纹支付网关中获取交易ID

时间:2020-05-16 07:28:02

标签: stripe-payments payment-gateway

我在php中使用条纹支付网关。一切正常。但付款成功后不显示交易ID。如何获取交易ID?

if(isset($_POST['stripeToken']))
{
$amount_cents = str_replace(".","","1.00");  // Chargeble amount
$invoiceid = "14526321";                      // Invoice ID
$description = "Invoice #" . $invoiceid . " - " . $invoiceid;

try {

    $charge = Stripe_Charge::create(array(
                    "amount" => $amount_cents,
                    "currency" => "usd",
                    "source" => $_POST['stripeToken'],
                    "description" => $description)
    );
    // Payment has succeeded, no exceptions were thrown or otherwise caught

    $result = "success";

} catch(Stripe_CardError $e) {

    $error = $e->getMessage();
    $result = "declined";

} catch (Stripe_InvalidRequestError $e) {
    $result = "declined";
} catch (Stripe_AuthenticationError $e) {
    $result = "declined";
} catch (Stripe_ApiConnectionError $e) {
    $result = "declined";
} catch (Stripe_Error $e) {
    $result = "declined";
} catch (Exception $e) {


}

        // Charge the Customer instead of the card


if($result=="success") {
    $response = "<div class='col-sm-offset-3 col-sm-9 text-success'>Your Payment has been processed successfully.</div>";
} else{
    $response = "<div class='text-danger'>Stripe Payment Status : \".$result.</div>";
}
}
?>

以上代码用于表单提交后。

0 个答案:

没有答案
相关问题