Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
@@ -505,7 +505,7 @@ class PayPal extends Gateway
|
||||
/* Send the request */
|
||||
try
|
||||
{
|
||||
$response = $this->api( 'checkout/orders', [
|
||||
$intent = [
|
||||
'intent' => 'AUTHORIZE',
|
||||
'purchase_units' => $this->_getPurchaseUnits( $transaction ),
|
||||
'payment_source' => [
|
||||
@@ -515,16 +515,23 @@ class PayPal extends Gateway
|
||||
'cancel_url' => (string)$transaction->invoice->checkoutUrl(),
|
||||
],
|
||||
'email_address' => $transaction->member->email,
|
||||
'name' => [
|
||||
'given_name' => $this->_getFirstName( $transaction ),
|
||||
'surname' => $this->_getLastName( $transaction )
|
||||
],
|
||||
'address' => ( $transaction->invoice->billaddress instanceof GeoLocation ) ? $this->_getAddress( $transaction->invoice->billaddress, $transaction->member ) : null,
|
||||
]
|
||||
]
|
||||
], 'POST', true, null, md5( $transaction->invoice->checkoutUrl() . ';' . $transaction->id ), 2 );
|
||||
];
|
||||
|
||||
try
|
||||
{
|
||||
$intent['payment_source']['paypal']['name'] = [
|
||||
'given_name' => $this->_getFirstName( $transaction ),
|
||||
'surname' => $this->_getLastName( $transaction )
|
||||
];
|
||||
}
|
||||
catch( UnexpectedValueException ){}
|
||||
|
||||
$response = $this->api( 'checkout/orders', $intent, 'POST', true, null, md5( $transaction->invoice->checkoutUrl() . ';' . $transaction->id ), 2 );
|
||||
}
|
||||
catch(PayPal\Exception $e )
|
||||
catch( PayPal\Exception $e )
|
||||
{
|
||||
$this->processException( $transaction, $e );
|
||||
throw $e;
|
||||
@@ -645,14 +652,10 @@ class PayPal extends Gateway
|
||||
$plan = $this->api( 'billing/plans', $planDetails );
|
||||
|
||||
/* Create a subscription */
|
||||
$subscription = $this->api( 'billing/subscriptions', array(
|
||||
$planData = array(
|
||||
'plan_id' => $plan['id'],
|
||||
'quantity' => '1',
|
||||
'subscriber' => array(
|
||||
'name' => array(
|
||||
'given_name' => $this->_getFirstName( $transaction ),
|
||||
'surname' => $this->_getLastName( $transaction )
|
||||
),
|
||||
'email_address' => $transaction->member->email,
|
||||
),
|
||||
'application_context' => array(
|
||||
@@ -668,7 +671,21 @@ class PayPal extends Gateway
|
||||
'cancel_url' => (string) $transaction->invoice->checkoutUrl(),
|
||||
'return_url' => Settings::i()->base_url . 'applications/nexus/interface/gateways/paypal.php?subscription=1&nexusTransactionId=' . $transaction->id,
|
||||
)
|
||||
) );
|
||||
);
|
||||
|
||||
if( $transaction->invoice->hasItemsRequiringBillingAddress() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$planData['subscriber']['name'] = array(
|
||||
'given_name' => $this->_getFirstName( $transaction ),
|
||||
'surname' => $this->_getLastName( $transaction )
|
||||
);
|
||||
}
|
||||
catch( UnexpectedValueException ){}
|
||||
}
|
||||
|
||||
$subscription = $this->api( 'billing/subscriptions', $planData );
|
||||
|
||||
/* Redirect */
|
||||
foreach ( $subscription['links'] as $link )
|
||||
@@ -1250,27 +1267,43 @@ class PayPal extends Gateway
|
||||
/* Return */
|
||||
return $address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get first name for PayPal
|
||||
*
|
||||
* @param Transaction $transaction Transaction
|
||||
* @return string
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
protected function _getFirstName( Transaction $transaction ) : string
|
||||
{
|
||||
return $transaction->invoice->member->member_id ? $transaction->invoice->member->cm_first_name : $transaction->invoice->guest_data['member']['cm_first_name'];
|
||||
$name = $transaction->invoice->member->member_id ? $transaction->invoice->member->cm_first_name : $transaction->invoice->guest_data['member']['cm_first_name'];
|
||||
|
||||
if( empty( $name ) )
|
||||
{
|
||||
throw new UnexpectedValueException;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get last name for PayPal
|
||||
*
|
||||
* @param Transaction $transaction Transaction
|
||||
* @return string
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
protected function _getLastName( Transaction $transaction ) : string
|
||||
{
|
||||
return $transaction->invoice->member->member_id ? $transaction->invoice->member->cm_last_name : $transaction->invoice->guest_data['member']['cm_last_name'];
|
||||
$name = $transaction->invoice->member->member_id ? $transaction->invoice->member->cm_last_name : $transaction->invoice->guest_data['member']['cm_last_name'];
|
||||
|
||||
if( empty( $name ) )
|
||||
{
|
||||
throw new UnexpectedValueException;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user