Notes
Notes - notes.io |
/**
* Created by PhpStorm.
* User: abdullah
* Date: 11/9/17
* Time: 18:58
*/
namespace AppComponents;
use AppModelsCustomerSession;
use CardinityClient;
use CardinityMethodPayment;
use CardinityException;
class CardinityPayment
{
private $AUTH_TEST = [
'key' => "",
'secret' => ""
];
private $AUTH_PROD = [
'key' => "",
'secret' => ""
];
public $is_live = true;
public $currency = "USD";
private $client = null;
public static $PAYMENT_STATUS_PENDING = "pending";
public static $PAYMENT_STATUS_COMPLETED = "approved";
public function __construct()
{
if ($this->is_live)
$this->client = Client::create([
'consumerKey' => $this->AUTH_PROD['key'],
'consumerSecret' => $this->AUTH_PROD['secret'],
]);
else
$this->client = Client::create([
'consumerKey' => $this->AUTH_TEST['key'],
'consumerSecret' => $this->AUTH_TEST['secret'],
]);
}
public function create_payment($order_id, $amount, $country, $card_number, $card_exp_year, $card_exp_month, $card_cvv, $card_holder)
{
$method = new PaymentCreate([
'amount' => $amount,
'currency' => $this->currency,
'settle' => false,
'description' => 'InstaShop Payment',
'order_id' => $order_id . "",
'country' => $country,
'payment_method' => PaymentCreate::CARD,
'payment_instrument' => [
'pan' => $card_number,
'exp_year' => $card_exp_year,
'exp_month' => $card_exp_month,
'cvc' => $card_cvv,
'holder' => $card_holder
],
]);
$payment = null;
try {
/** @type CardinityMethodPaymentPayment */
$payment = $this->client->call($method);
$status = $payment->getStatus();
return $payment;
} catch (ExceptionDeclined $exception) {
$payment = $exception->getResult();
$status = $payment->getStatus(); // value will be 'declined'
$errors = $exception->getErrors(); // list of errors occured
$error = array();
foreach ($errors as $each) {
array_push($error, $each['message']);
}
return implode(", ", $error);
} catch (ExceptionInvalidAttributeValue $exception) {
return $exception->getMessage();
} catch (ExceptionUnexpectedError $exception) {
return FALSE;
} catch (Exception $exception) {
return FALSE;
}
}
public function finalized_payment($payment_id, $payRes)
{
$method = new PaymentFinalize($payment_id, $payRes);
/** @type CardinityMethodPaymentPayment */
$payment = $this->client->call($method);
return $payment;
}
}
//So we are having difficulty with pending payment, I will focus on this specific case after we are getting a pending status in the //payment
/*
$result['data'] = [
'url' => $respnse->getAuthorizationInformation()->getUrl(),
'data' => $respnse->getAuthorizationInformation()->getData(),
'payment_id' => $respnse->getId()
];
i am using passing these parameter to the view and rendering them into the form.
url => goes to form url
data => goes to PaReq parameter
TermUrl => customized return url
MD => we are sending our unique order_id
*/
/*
So as soon as the request return to TermUrl on our server our code contienu like this
*/
$cardinity = new CardinityPayment();
$response = $cardinity->finalized_payment($payment_id, $paRes);
/*
Also, the problem is that when we submit the form for 3d-auth it doesn't take us to the mobile verification page, it goes to your server and directly comes back to our server, so technically the error of decline is correct because it didn't verify anything.
Similar, through the test credentials, when I make 3d-payment test, it takes the request to your server and brings back to ours, but i assumed it just in the test case, please share me what would be going wrong?
I have followed the guide from your documentation page as well as from the
*/
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team