Working on Alipay

This commit is contained in:
Hillel Coren 2017-09-05 13:51:08 +03:00
parent f654259ae8
commit d251df7531
3 changed files with 17 additions and 8 deletions

View File

@ -331,10 +331,14 @@ class StripePaymentDriver extends BasePaymentDriver
$data = "type=alipay&amount={$amount}&currency={$currency}&redirect[return_url]={$redirect}";
$response = $this->makeStripeCall('POST', 'sources', $data);
$this->invitation->transaction_reference = $response['id'];
$this->invitation->save();
if (is_array($response) && isset($response['id'])) {
$this->invitation->transaction_reference = $response['id'];
$this->invitation->save();
return redirect($response['redirect']['url']);
return redirect($response['redirect']['url']);
} else {
throw new Exception($response);
}
}
public function makeStripeCall($method, $url, $body = null)
@ -459,8 +463,10 @@ class StripePaymentDriver extends BasePaymentDriver
return false;
}
$data = sprintf('amount=%d&currency=%s&source=%s', $source['amount'], $source['currency'], $source['id']);
$this->purchaseResponse = $this->makeStripeCall('POST', 'charges', $data);
$this->createPayment($this->purchaseResponse['id']);
$this->purchaseResponse = $response = $this->makeStripeCall('POST', 'charges', $data);
if (is_array($response) && isset($response['id'])) {
$this->createPayment($response['id']);
}
}
return 'Processed successfully';

View File

@ -37,6 +37,7 @@ class PaymentTypesSeeder extends Seeder
['name' => 'Venmo'],
['name' => 'Money Order'],
['name' => 'Alipay', 'gateway_type_id' => GATEWAY_TYPE_ALIPAY],
['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_BANK_TRANSFER],
];
foreach ($paymentTypes as $paymentType) {

View File

@ -66,6 +66,10 @@
@foreach ($gateways as $gateway)
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@if ($gateway->id == GATEWAY_STRIPE)
{!! Former::text('publishable_key') !!}
@endif
@foreach ($gateway->fields as $field => $details)
@if ($details && !$accountGateway && !is_array($details) && !is_bool($details))
@ -89,9 +93,7 @@
@endforeach
@if ($gateway->id == GATEWAY_STRIPE)
{!! Former::text('publishable_key') !!}
@elseif ($gateway->id == GATEWAY_BRAINTREE)
@if ($gateway->id == GATEWAY_BRAINTREE)
@if ($account->hasGatewayId(GATEWAY_PAYPAL_EXPRESS))
{!! Former::checkbox('enable_paypal')
->label(trans('texts.paypal'))