Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the code for latest sdk change #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions SecureSubmit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
global $wpdb;
global $table_name;

use GlobalPayments\Api\Entities\EncryptionData;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
use GlobalPayments\Api\PaymentMethods\CreditTrackData;
use GlobalPayments\Api\Services\CreditService;
use GlobalPayments\Api\ServicesConfig;
use GlobalPayments\Api\ServicesContainer;
use GlobalPayments\Api\Entities\Address;
use GlobalPayments\Api\Entities\Customer;
use GlobalPayments\Api\Entities\TransactionSummary;

$table_name = $wpdb->prefix . "securesubmit";
$jal_db_version = "1.2.0";
$secureSubmit = new SecureSubmit();
Expand All @@ -29,8 +39,8 @@ class SecureSubmit {
function __construct() {
$this->dir = (string) dirname(__FILE__);

if ( ! class_exists('HpsServicesConfig' ) ) {
require_once($this->dir . '/lib/Hps.php');
if ( ! class_exists('ServicesConfig' ) ) {
require_once($this->dir . '/lib/vendor/autoload.php');
}

$this->url = plugins_url('securesubmit');
Expand Down Expand Up @@ -2013,44 +2023,26 @@ function submit_payment() {
}
}

$config = new HpsServicesConfig();

$config->secretApiKey = esc_attr($skey);
$config->versionNumber = '1648';
$config->developerId = '002914';

$chargeService = new HpsCreditService($config);

$address = new HpsAddress();
$address->address = $billing_address;
$config = $this->setConfig($skey);
$address = new Address();
$address->streetAddress1 = $billing_address;
$address->city = $billing_city;
if ($requireState)
$address->state = $billing_state;
$address->zip = $billing_zip;

$cardHolder = new HpsCardHolder();
$cardHolder->firstName = $billing_firstname;
$cardHolder->lastName = $billing_lastname;
$cardHolder->email = $billing_email;
$cardHolder->address = $address;

$cardOrToken = new HpsTokenData();
$cardOrToken->tokenValue = $secureToken;


$cardOrToken = new CreditCardData();
$cardOrToken->token = $secureToken;
$cardOrToken->cardHolderName = $billing_firstname. ' ' .$billing_lastname;

if (!empty($memo)) {
$details = new HpsTransactionDetails();
$details->memo = $memo;
$details = $memo;
}

$response = $chargeService->charge(
$amount,
'usd',
$cardOrToken,
$cardHolder,
false,
$details
);

$response = $cardOrToken->charge($amount)
->withCurrency('usd')
->withAddress($address)
->withDescription($details)
->execute();
$transaction_id = $response->transactionId;

add_filter('wp_mail_content_type', create_function('', 'return "text/html"; '));
Expand Down Expand Up @@ -2208,4 +2200,13 @@ function jal_update_db_check(){
$this->jal_install();
}
}

public function setConfig($skey)
{
$config = new ServicesConfig();
$config->secretApiKey = esc_attr($skey);
$config->serviceUrl = 'https://cert.api2.heartlandportico.com';
$service = ServicesContainer::configure($config);
return $service;
}
}
5 changes: 5 additions & 0 deletions lib/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"globalpayments/php-sdk": "^1.3"
}
}
63 changes: 63 additions & 0 deletions lib/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitf9480bef670eec5a1ff9c2cbff716477::getLoader();
Loading