Get Card Information from Charge object in Stripe - php

I have integrated stripe payment method in website . I want to get Card Information. Everything is work fine .After successful payment i successfully retrived payment id from $charge->id variable .So my question is that when i print_r($charge) it also show Card Object Something like That
Stripe_Card Object ( [_apiKey:protected] => sk_test_...
[_values:protected] => Array ( [id] => card_1BLSPnJ6IzxnlSnmegEq6dbH
[object] => card [address_city] => Lahire [address_country] => Pakistan
my stripe process
$customer =Stripe_Customer::create(array(
'email' => $_GET['email'],));
$charge = Stripe_Charge::create(array(
"amount" => $amount_cents,"currency" => "usd","source" =>
$_POST['stripeToken'],"description" => $description,
)
);
I try many times to get card information from $charge variable using $charge->card->address_country But not work any solution .Your help would be greatly appreciated

The payment source of a charge is returned in the source attribute of the charge object, so you should be able to do something like this:
$card = $charge->source;
// Do something with $card, e.g. access the billing address' country
// with $card->address_country

Related

how to get refunded transactions details using payflow pro api php

I have integrated Payflow pro payment gateway into my php application and processing payment requests using Payflow as payment gateway.
I need to retrieve transaction history which includes refunds too for specific profile ID.
Below is the code that I am using: ref - (https://github.com/rcastera/Paypal-PayFlow-API-Wrapper-Class).
require_once(__DIR__.'/Class.PayFlow.php');
$PayFlowAuth = new PayFlow($Vendor, $Partner, $User, $Password, 'single');
$PayFlowAuth->setTransactionType('R');
$PayFlowAuth->setProfileAction('I');
$PayFlowAuth->setCustomField('ORIGPROFILEID', 'RP0000000XYZ' );
$PayFlowAuth->setCustomField('PAYMENTHISTORY', 'Y' );
$PayFlowAuth->setEnvironment('live');
$PayFlowAuth->processTransaction();
$response = $PayFlowAuth->getResponse();
echo '<pre>';
print_r($response);
I get below response:
Array
(
[RESULT] => 0
[RPREF] => RHX51F5D3XYZ
[PROFILEID] => RP0000000XYZ
[P_PNREF1] => BK0P6E1C2XYZ
[P_TRANSTIME1] => 19-Jun-19 04:42 AM
[P_RESULT1] => 0
[P_TENDER1] => C
[P_AMT1] => 30.00
[P_TRANSTATE1] => 8
[P_PNREF2] => BK0P6EB8DXYZ
[P_TRANSTIME2] => 21-Jul-19 04:44 AM
[P_RESULT2] => 12
[P_TENDER2] => C
[P_AMT2] => 30.00
[P_TRANSTATE2] => 1
[P_PNREF3] => BR0P6482FXYZ
[P_TRANSTIME3] => 19-Aug-19 04:52 AM
[P_RESULT3] => 0
[P_TENDER3] => C
[P_AMT3] => 30.00
[P_TRANSTATE3] => 8
)
However it does not include refunded transaction. When I search in paypal manager, I can see these 3 transactions along with 1 refund transaction too. I tried changing TRXTYPE to C (credit) but it gives the error: Invalid tender
So I am looking for any such parameter change where I can retrieve refunded transaction history or may be any method in payflow pro api.
At the end asked paypal support and they replied.
unfortunately, there is no API to get refunded transactions. I'll
contact our engineers for possible feature request. I apologize for
the inconvenience.
That is correct. Credits are issued outside of the profile so they are not tied to it and as a result do not show up when doing a PAYMENTHISTORY call.

How to get the charge ID from Stripe using PHP?

First of all, I am aware that this question has been asked but they didn't explain how to get the information using
charge.succeeded
I am creating an auth and capture charge using Stripe. I need the charge ID to confirm/capture the charge.
The following code creates the charge but doesn't charge until it's been approved.
\Stripe\Charge::create(array(
"amount" => $price,
"currency" => "usd",
"customer" => $custID, // obtained with Stripe.js
"description" => "Charge for test#example.com",
"capture" => false
));
I assumed that I could get the charge ID by doing:
$chargeID = $charge->id;
because that's how I get the customer ID when I create a customer. But I get nothing when I echo out the variable, which doesn't help since I want to save it in a database. I've looked everywhere but can't find anything concrete or recent.
Then to complete the charge. I have to capture it this way:
$ch = \Stripe\Charge::retrieve("$chargeID");
$ch->capture();
This is all from the Stripe API Reference but it doesn't explain how to get the charge ID. It doesn't even tell you how to get the customer ID, luckily Stack Overflow came through with that one.
This is all done using PHP.
According to Stripe's Documentation, when creating a new charge you get Stripe\Charge JSON object in return (or an exception if something went wrong).
You can var_dump the object you just created to see what your object looks like, but according the the API you can use the id of the returned object:
$charge = \Stripe\Charge::create(array(
"amount" => $price,
"currency" => "usd",
"customer" => $custID, // obtained with Stripe.js
"description" => "Charge for test#example.com",
"capture" => false
));
// you can use the var_dump function to see what's inside the $charge object
// var_dump($charge);
$chargeID = $charge->id;
(And you don't need to call the Charge::retrieve again, you can use the current $charge object).

Paypal Payflow refund issue

Hi am trying to create a refunding function for the paypal payflow.
This is code what exactly am created.
public function refund()
{
$this->load->helper('paypal_helper');
$request = array(
"PARTNER" => PARTNER,
"VENDOR" => VENDOR,
"USER" => USER,
"PWD" => PWD,
"TRXTYPE" => 'C',
"AMT" => '11',
"CURRENCY" => CURRENCY,
"CREATESECURETOKEN" => "N",
"SECURETOKENID" => uniqid('213'.time()),
"RETURNURL" => site_url().'test/refund',
"CANCELURL" => site_url().'test/refund',
"ERRORURL" => site_url().'test/refund',
"ORIGID" => 'A70A6DBF0A8C'
);
$response = run_payflow_call($request);
printr($response);
return $response;
}
Here ORGID is set as the PNREF what i got after the success payment.
$response = run_payflow_call($request); is defined in the helper and it just post the details in to the https://pilot-payflowpro.paypal.com/ (sandbox). But after the action i got the result like this
[RESULT] => 23
[PNREF] => A1X06F928D52
[RESPMSG] => Invalid account number
Any one can tell me why this happen ??
am using the same "PARTNER" "VENDOR" "USER" for the purchase section also. But in the purchase everything going fine. I get the success report and the amount properly credited.
To refund a transaction using the Payflow you just need to pass the below parameters :
TRXTYPE =C (value is "C" for credit )
TENDER =C ( Value can be "C" if the payment was done using the credit card or "P" if its a PayPal payment)
ORIGID = A70A6DBF0A8C( Id to refund)
AMT = Optional parameter ( If not provided whole amount will be refunded)
Secure token is not required while doing the refund .

Mercado Pago only CreditCard

I'm learning Mercado-Pago SDK...
I'd like to only be able to use credit card's, and for that I'm trying to use, "excluded_payment_types", so my array looks like this:
$preference_data = array(
"items" => array(
array(
"title" => "Puppy Dalmata",
"description" => "Nice description of the item",
"quantity" => 1,
"currency_id" => "MXN",
"picture_url" => "http://domain.com/dal2.jpg",
"unit_price" => 1500,
"payment_methods" => array (
"excluded_payment_types" => array (
"id" => "ticket",
"id" => "bank_transfer",
"id" => "atm",
"id" => "debit_card",
"id" => "account_money"
),
"installments" => 12
),
)
)
);
$preference = $mp->create_preference($preference_data);
With that I'm able to get the URL so that I can process the payment for that item, so, this is working "fine" the client is able to see how much is going to pay and a lot of option to make a payment:
Bank Deposit, Account Money, Debit card, Payment via "7Eleven, OXXO, STRIPES" and Credit card... the idea is to only show Credit Card and nothing else, the user can only select the type of card, Visa Credit or Master Credit ... and nothing else...
but as in the this url shows :https://api.mercadolibre.com/payment_types it doesn't work base on my ARRAY... so I wonder what am I doing wrong? ...
I thank you for any help you can provided
Thank you for taking the time to read my question.
toke me some time to get back to this... anyway, the problem with that array is that I have the key "payment_methods" inside key "items" which is wrong... it should be outside key items ... and that solved to problem of getting "payment_methods" to only accept credit card... btw, after I solved this issue I went back to read and learn more about "mercadopago" API for processing online payments and is quite easy to use I'm not saying is better than... PayPal, but, yes more easy to use...

Authorize.net AIM refund transaction error 3.2.33

According to authorize.net pdf instructions I use the AIM parameters:
"x_login" => $AimLoginID,
"x_tran_key" => $AimTransKey,
"x_version" => "3.1",
"x_delim_data" => "TRUE",
"x_delim_char" => "|",
"x_relay_response" => "FALSE",
"x_type" => $Type,
"x_trans_id" => $TransID,
"x_amount" => $Amount,
"x_card_num" => $CCLast4,
"x_invoice_num" => $invoicenumber
where
x_tran_key is the original transaction ID as given to my from authorize.net
type = CREDIT as I want to refund
x_amount equals the exact amount I previously charged on the credit card
x_card_num is filled with the last 4 digits from the credit card.
x_invoice_num has my invoice number
the message I get back gives me an error.
Array
(
[0] => 3
[1] => 2
[2] => 33
[3] => Recurring Billing is required.
this does not make any sense as it is not a recurring billing?
at the beginning I tried it without the invoice number, but the retunred errorcode informed me that I need to give them also that. I also tried to give the parameter x_exp_date as '' (i saw a suggestion for this online) but it didn't work, had the same message.
Any idea or suggestion will be highly appreciated.
Please, check x_recurring_billing - perhaps it is enabled as "required".
You need to access your Merchant Interface. Check if this field is set as Required.
Just change the FIELD value to NOT REQUIRED.
See more detailed problem explaination here http://community.developer.authorize.net/t5/Integration-and-Testing/Receiving-Response-3-2-33-Recurring-Billing-is-required/td-p/718

Categories