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

Improve: Add PSP Compatibilization with Google Pay #491

Merged
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
1 change: 1 addition & 0 deletions src/Concrete/WoocommercePlatformOrderDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ private function extractPaymentDataFromGooglepay(
}
$newPaymentData->amount = $moneyService->floatToCents($this->getGrandTotal());
$newPaymentData->googlepayData = $cleanJson;
$newPaymentData->billing_address = $this->getCustomer()->getAddress()->convertToSDKRequest();
$newPaymentData->additionalInformation = ["googlepayData" => $cleanJson];
$googlepayIndex = 'googlepay';
if (!isset($paymentData[$googlepayIndex])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ final class GooglePayPayment extends AbstractPayment
*/
public $additionalInformation;

/**
* @var array $billingAddress
*/
public $billingAddress;

/**
* @return array
Expand All @@ -27,6 +31,14 @@ public function getAdditionalInformation()
return $this->additionalInformation;
}

/**
* @param array $billingAddress
*/
public function setBillingAddress($billingAddress)
{
$this->billingAddress = $billingAddress;
}

/**
* @param array $additionalInformation
*/
Expand Down Expand Up @@ -85,6 +97,11 @@ private function getStatementDescriptor()
return $this->moduleConfig->getCardStatementDescriptor();
}

private function getBillingAddress()
{
return $this->billingAddress;
}

/**
* @return CreateGooglePayPaymentRequest
*/
Expand All @@ -93,6 +110,8 @@ protected function convertToPrimitivePaymentRequest()
$payload = new \stdClass();
$payload->type = "google_pay";
$payload->google_pay = $this->getGooglePayload();
return new CreateGooglePayPaymentRequest($this->getStatementDescriptor(), $payload);
$card = new \stdClass();
$card->billing_address = $this->getBillingAddress();
return new CreateGooglePayPaymentRequest($this->getStatementDescriptor(), $payload, $card);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private function createGooglePayPayments($data)
if (!empty($value->additionalInformation)) {
$payment->setAdditionalInformation($value->additionalInformation);
}

$payment->setBillingAddress($value->billing_address);
$payment->setAmount($value->amount);

$payments[] = $payment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ class CreateGooglePayPaymentRequest implements JsonSerializable
*/
public $payload;

/**
* @required
* @var object $card public property
*/
public $card;

/**
* Constructor to set initial or default values of member properties
* @param string $statementDescriptor Initialization value for $this->statementDescriptor
* @param Object $payload Initialization value for $this->payload
* @param Object $card Initialization value for $this->card
*/
public function __construct()
{
if (2 == func_num_args()) {
if (3 == func_num_args()) {
$this->statementDescriptor = func_get_arg(0);
$this->payload = func_get_arg(1);
$this->card = func_get_arg(2);
}
}

Expand All @@ -45,6 +53,7 @@ public function jsonSerialize()
$json = array();
$json['statement_descriptor'] = $this->statementDescriptor;
$json['payload'] = $this->payload;
$json['card'] = $this->card;
return $json;
}
}
Loading