Saturday, July 15, 2017

BrainTree Payment API | Get Payment | Retrieve Payment | Get Payment Details

For merchant ID, public key and private key you can have a look at below link:

http://pritomkumar.blogspot.com/2017/07/braintree-create-payment-token-store.html



Full example to get payment/sale details from BrainTree given below:

<?php
require_once "CurlExecutor.php";
require_once "BrainTreeUtils.php";

define("MERCHANT_ID", "k9y........xj6");
define("PUBLIC_KEY", "85d........hh7");
define("PRIVATE_KEY", "510d.........................8a00");

$base = "/transactions/1689k3ra";
$test = "https://api.sandbox.braintreegateway.com:443/merchants/" . MERCHANT_ID . $base;
$live = "https://api.braintreegateway.com:443/merchants/" . MERCHANT_ID . $base;

$headers[] = "Accept: application/xml";
$headers[] = "Content-Type: application/xml";
$headers[] = "X-ApiVersion: 4";
$closure = function(&$curl) {
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, PUBLIC_KEY . ':' . PRIVATE_KEY);
};
$result = CurlExecutor::execute(
    $test, "GET", null, null, $headers, $closure
);
CurlExecutor::prettyPrint(BrainTreeUtils::arrayFromXml($result["response"]));


And response from BrainTree API end:


Array
(
    [transaction] => Array
        (
            [id] => 1689k3ra
            [status] => authorized
            [type] => sale
            [currencyIsoCode] => USD
            [amount] => 1.00
            [merchantAccountId] => fj3q............z2
            [subMerchantAccountId] => 
            [masterMerchantAccountId] => 
            [orderId] => ORDER_ID_1500093236
            [createdAt] => DateTime Object
                (
                    [date] => 2017-07-15 04:33:54.000000
                    [timezone_type] => 3
                    [timezone] => UTC
                )

            [updatedAt] => DateTime Object
                (
                    [date] => 2017-07-15 04:33:54.000000
                    [timezone_type] => 3
                    [timezone] => UTC
                )

            [customer] => Array
                (
                    [id] => 
                    [firstName] => 
                    [lastName] => 
                    [company] => 
                    [email] => 
                    [website] => 
                    [phone] => 
                    [fax] => 
                )

            [billing] => Array
                (
                    [id] => 
                    [firstName] => 
                    [lastName] => 
                    [company] => 
                    [streetAddress] => 
                    [extendedAddress] => 
                    [locality] => 
                    [region] => 
                    [postalCode] => 
                    [countryName] => 
                    [countryCodeAlpha2] => 
                    [countryCodeAlpha3] => 
                    [countryCodeNumeric] => 
                )

            [refundId] => 
            [refundIds] => Array
                (
                )

            [refundedTransactionId] => 
            [partialSettlementTransactionIds] => Array
                (
                )

            [authorizedTransactionId] => 
            [settlementBatchId] => 
            [shipping] => Array
                (
                    [id] => 
                    [firstName] => 
                    [lastName] => 
                    [company] => 
                    [streetAddress] => 
                    [extendedAddress] => 
                    [locality] => 
                    [region] => 
                    [postalCode] => 
                    [countryName] => 
                    [countryCodeAlpha2] => 
                    [countryCodeAlpha3] => 
                    [countryCodeNumeric] => 
                )

            [customFields] => 
            [avsErrorResponseCode] => 
            [avsPostalCodeResponseCode] => I
            [avsStreetAddressResponseCode] => I
            [cvvResponseCode] => I
            [gatewayRejectionReason] => 
            [processorAuthorizationCode] => 7NZ9S2
            [processorResponseCode] => 1000
            [processorResponseText] => Approved
            [additionalProcessorResponse] => 
            [voiceReferralNumber] => 
            [purchaseOrderNumber] => 
            [taxAmount] => 
            [taxExempt] => 
            [creditCard] => Array
                (
                    [token] => 
                    [bin] => 444433
                    [last4] => 1111
                    [cardType] => Visa
                    [expirationMonth] => 12
                    [expirationYear] => 2018
                    [customerLocation] => US
                    [cardholderName] => Test
                    [imageUrl] => https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox
                    [prepaid] => Unknown
                    [healthcare] => Unknown
                    [debit] => Unknown
                    [durbinRegulated] => Unknown
                    [commercial] => Unknown
                    [payroll] => Unknown
                    [issuingBank] => Unknown
                    [countryOfIssuance] => Unknown
                    [productId] => Unknown
                    [uniqueNumberIdentifier] => 
                    [venmoSdk] => 
                )

            [statusHistory] => Array
                (
                    [0] => Array
                        (
                            [timestamp] => DateTime Object
                                (
                                    [date] => 2017-07-15 04:33:54.000000
                                    [timezone_type] => 3
                                    [timezone] => UTC
                                )

                            [status] => authorized
                            [amount] => 1.00
                            [user] => j234lk2342342j3l4
                            [transactionSource] => api
                        )

                )

            [planId] => 
            [subscriptionId] => 
            [subscription] => Array
                (
                    [billingPeriodEndDate] => 
                    [billingPeriodStartDate] => 
                )

            [addOns] => Array
                (
                )

            [discounts] => Array
                (
                )

            [descriptor] => Array
                (
                    [name] => 
                    [phone] => 
                    [url] => 
                )

            [recurring] => 
            [channel] => 
            [serviceFeeAmount] => 
            [escrowStatus] => 
            [disbursementDetails] => Array
                (
                    [disbursementDate] => 
                    [settlementAmount] => 
                    [settlementCurrencyIsoCode] => 
                    [settlementCurrencyExchangeRate] => 
                    [fundsHeld] => 
                    [success] => 
                )

            [disputes] => Array
                (
                )

            [authorizationAdjustments] => Array
                (
                )

            [paymentInstrumentType] => credit_card
            [processorSettlementResponseCode] => 
            [processorSettlementResponseText] => 
            [threeDSecureInfo] => 
        )

)

No comments:

Post a Comment