Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit 64c41f5

Browse files
committed
Add sender phone to payment request
1 parent 81bb6c4 commit 64c41f5

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

UOL_PagSeguro-2.7.0.tgz

124 Bytes
Binary file not shown.

app/code/community/UOL/PagSeguro/Helper/Data.php

+22
Original file line numberDiff line numberDiff line change
@@ -629,4 +629,26 @@ public function getPaymentStatusToString(Integer $key)
629629
}
630630
return false;
631631
}
632+
633+
/**
634+
* Format string phone number
635+
* @param string $phone
636+
* @return array of area code and number
637+
*/
638+
public function formatPhone($phone)
639+
{
640+
$phone = preg_replace('/[^0-9]/', '', $phone);
641+
$ddd = '';
642+
643+
if (strlen($phone) > 9) {
644+
if (substr($phone, 0, 1) == 0) {
645+
$phone = substr($phone, 1);
646+
}
647+
648+
$ddd = substr($phone, 0, 2);
649+
$phone = substr($phone, 2);
650+
}
651+
652+
return ['areaCode' => $ddd, 'number' => $phone];
653+
}
632654
}

app/code/community/UOL/PagSeguro/Model/PaymentMethod.php

+2
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,11 @@ public function getCredentialsInformation()
312312
*/
313313
private function getSenderInformation()
314314
{
315+
$phone = Mage::helper('pagseguro')->formatPhone($this->order->getBillingAddress()->getTelephone());
315316
$PagSeguroSender = new PagSeguroSender();
316317
$PagSeguroSender->setEmail($this->order['customer_email']);
317318
$PagSeguroSender->setName($this->order['customer_firstname'] . ' ' . $this->order['customer_lastname']);
319+
$PagSeguroSender->setPhone($phone['areaCode'], $phone['number']);
318320

319321
return $PagSeguroSender;
320322
}

0 commit comments

Comments
 (0)