GoCardless Integration update #872

This commit is contained in:
Hillel Coren 2017-08-21 22:10:50 +03:00
parent 82a94c1612
commit 3052168b1d
8 changed files with 76 additions and 18 deletions

View File

@ -96,8 +96,10 @@ class AccountGatewayToken extends Eloquent
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
$merchantId = $accountGateway->getConfigField('merchantId');
$testMode = $accountGateway->getConfigField('testMode');
return $testMode ? "https://sandbox.braintreegateway.com/merchants/{$merchantId}/customers/{$this->token}" : "https://www.braintreegateway.com/merchants/{$merchantId}/customers/{$this->token}";
} elseif ($accountGateway->gateway_id == GATEWAY_GOCARDLESS) {
$testMode = $accountGateway->getConfigField('testMode');
return $testMode ? "https://manage-sandbox.gocardless.com/customers/{$this->token}" : "https://manage.gocardless.com/customers/{$this->token}";
} else {
return false;
}

View File

@ -2,16 +2,72 @@
namespace App\Ninja\PaymentDrivers;
use Session;
class GoCardlessV2RedirectPaymentDriver extends BasePaymentDriver
{
protected $transactionReferenceParam = "\x00*\x00id";
public function gatewayTypes()
{
$types = [
GATEWAY_TYPE_BANK_TRANSFER,
GATEWAY_TYPE_TOKEN,
];
return $types;
}
protected function paymentDetails($paymentMethod = false)
{
$data = parent::paymentDetails($paymentMethod);
if ($paymentMethod) {
$data['mandate_reference'] = $paymentMethod->source_reference;
}
if ($ref = request()->redirect_flow_id) {
$data['transaction_reference'] = $ref;
}
return $data;
}
protected function shouldCreateToken()
{
return false;
}
public function completeOffsitePurchase($input)
{
$details = $this->paymentDetails();
$this->purchaseResponse = $response = $this->gateway()->completePurchase($details)->send();
if (! $response->isSuccessful()) {
return false;
}
$paymentMethod = $this->createToken();
$payment = $this->completeOnsitePurchase(false, $paymentMethod);
return $payment;
}
protected function creatingCustomer($customer)
{
$customer->token = $this->purchaseResponse->getCustomerId();
return $customer;
}
protected function creatingPaymentMethod($paymentMethod)
{
$paymentMethod->source_reference = $this->purchaseResponse->getMandateId();
$paymentMethod->payment_type_id = PAYMENT_TYPE_ACH;
$paymentMethod->status = PAYMENT_METHOD_STATUS_VERIFIED;
return $paymentMethod;
}
}

View File

@ -37,7 +37,7 @@
"descubraomundo/omnipay-pagarme": "dev-master",
"digitickets/omnipay-barclays-epdq": "~3.0",
"digitickets/omnipay-datacash": "~3.0",
"digitickets/omnipay-gocardlessv2": "dev-master",
"digitickets/omnipay-gocardlessv2": "dev-payment-fix",
"digitickets/omnipay-realex": "~5.0",
"dioscouri/omnipay-cybersource": "dev-master",
"doctrine/dbal": "2.5.x",

14
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "21e71e6ce0568744f92aca427b7f103b",
"content-hash": "a052186eb2c4093936e61fe22d93255f",
"hash": "a39a505121abab0985f7c0cb1734920c",
"content-hash": "4067bb1f3c6d2b3397e3a005b642ddb6",
"packages": [
{
"name": "agmscode/omnipay-agms",
@ -1429,16 +1429,16 @@
},
{
"name": "digitickets/omnipay-gocardlessv2",
"version": "dev-master",
"version": "dev-payment-fix",
"source": {
"type": "git",
"url": "https://github.com/hillelcoren/omnipay-gocardlessv2.git",
"reference": "007c29256a4df6e2d149d8a239474f80028e8601"
"reference": "a264ac71dcdb7c03f42f17cb52c650d87e42f8e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hillelcoren/omnipay-gocardlessv2/zipball/007c29256a4df6e2d149d8a239474f80028e8601",
"reference": "007c29256a4df6e2d149d8a239474f80028e8601",
"url": "https://api.github.com/repos/hillelcoren/omnipay-gocardlessv2/zipball/a264ac71dcdb7c03f42f17cb52c650d87e42f8e0",
"reference": "a264ac71dcdb7c03f42f17cb52c650d87e42f8e0",
"shasum": ""
},
"require": {
@ -1511,7 +1511,7 @@
"support": {
"source": "https://github.com/hillelcoren/omnipay-gocardlessv2/tree/master"
},
"time": "2017-08-21 09:54:55"
"time": "2017-08-21 18:05:05"
},
{
"name": "digitickets/omnipay-realex",

View File

@ -72,7 +72,7 @@ class PaymentLibrariesSeeder extends Seeder
['name' => 'Braintree', 'provider' => 'Braintree', 'sort_order' => 2],
['name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 9],
['name' => 'FirstData Payeezy', 'provider' => 'FirstData_Payeezy'],
//['name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 8, 'is_offsite' => true],
['name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 8, 'is_offsite' => true],
];
foreach ($gateways as $gateway) {

File diff suppressed because one or more lines are too long

View File

@ -439,7 +439,7 @@ $LANG = array(
'reset_all' => 'Reset All',
'approve' => 'Approve',
'token_billing_type_id' => 'Token Billing',
'token_billing_help' => 'Store payment details with WePay, Stripe or Braintree.',
'token_billing_help' => 'Store payment details with WePay, Stripe, Braintree or GoCardless.',
'token_billing_1' => 'Disabled',
'token_billing_2' => 'Opt-in - checkbox is shown but not selected',
'token_billing_3' => 'Opt-out - checkbox is shown and selected',

View File

@ -67,7 +67,7 @@
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@foreach ($gateway->fields as $field => $details)
@if ($details && !$accountGateway && !is_array($details))
@if ($details && !$accountGateway && !is_array($details) && !is_bool($details))
{!! Former::populateField($gateway->id.'_'.$field, $details) !!}
@endif