Showing posts with label refund-payment-stripe-api. Show all posts
Showing posts with label refund-payment-stripe-api. Show all posts

Wednesday, September 27, 2017

Stripe Payment GateWay | Refund Stripe VIA API | Stripe API Refund Payment

Stripe Payment GateWay | Refund Stripe VIA API | Stripe API Refund Payment



<?php
include_once "curl.php";
$key = "sk_test_eXF4nNy........rcHK95rwj";

$params = array(
    "charge" => "ch_1B3bkMFIwfarG3vBaBs0hodp",
    "amount" => 10,
    "metadata" => array(
        "Refund-reason" => "Some reason to fail",
        "Refund-by" => "Pritom Kumaar"
    )
);

$url = "https://api.stripe.com/v1/refunds";

$headers[] = "Authorization: Bearer " . $key;
$headers[] = "Content-Type: application/x-www-form-urlencoded";

$response = CurlExecutor::execute($url, "POST", $params, null, $headers);
$response["response"] = json_decode($response["response"]);
CurlExecutor::prettyPrint($response);

And output would be like below:

Array
(
    [code] => 200
    [response] => stdClass Object
        (
            [id] => re_1B6h5DFIwfarG3vBvFwcbNl9
            [object] => refund
            [amount] => 10
            [balance_transaction] => txn_1B6h5DFIwfarG3vBALLuMSUw
            [charge] => ch_1B3bkMFIwfarG3vBaBs0hodp
            [created] => 1506524659
            [currency] => aud
            [metadata] => stdClass Object
                (
                    [Refund-reason] => Some reason to fail
                    [Refund-by] => Pritom Kumaar
                )

            [reason] => 
            [receipt_number] => 
            [status] => succeeded
        )

)