Skip to content

Commit

Permalink
Fix - Parameterize post_xml variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceandy committed Jun 18, 2020
1 parent d323fbf commit 36dc20c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Change Log

## [v2.0.3](https://github.com/bryceandy/laravel_pesapal/compare/v2.0.2...v2.0.3) - June 18, 2020
* Parameterize post_xml variable

## [v2.0.2](https://github.com/bryceandy/laravel_pesapal/compare/v2.0.1...v2.0.2) - June 18, 2020
* Create middleware to validate configurations
* Use request array to create post_xml
* Use request array to create post_xml

## [v2.0.1](https://github.com/bryceandy/laravel_pesapal/compare/v2.0.0...v2.0.1) - June 18, 2020
* Add a route name for the route that posts payments
Expand Down
8 changes: 7 additions & 1 deletion src/Pesapal.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ public function __construct(OAuthSignatureMethod_HMAC_SHA1 $signature)
*/
public function getIframeSource($request)
{
$parameterizedValue = "";
// Pesapal params
$postXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PesapalDirectOrderInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Currency=\"".$request['currency']."\" Amount=\"".number_format($request['amount'], 2)."\" Description=\"".$request['description']."\" Type=\"".$request['type']."\" Reference=\"".$request['reference']."\" FirstName=\"".$request['first_name']?:''."\" LastName=\"".$request['last_name']?:''."\" Email=\"".$request['email']?:''."\" PhoneNumber=\"".$request['phone_number']?:''."\" xmlns=\"http://www.pesapal.com\" />";
$request['first_name'] ? $parameterizedValue .= "\" FirstName=\"".$request['first_name'] : null;
$request['last_name'] ? $parameterizedValue .= "\" LastName=\"".$request['last_name'] : null;
$request['email'] ? $parameterizedValue .= "\" Email=\"".$request['email'] : null;
$request['phone_number'] ? $parameterizedValue .= "\" PhoneNumber=\"".$request['phone_number'] : null;

$postXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PesapalDirectOrderInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchemainstance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Currency=\"".$request['currency']."\" Amount=\"".number_format($request['amount'], 2)."\" Description=\"".$request['description']."\" Type=\"".$request['type']."\" Reference=\"".$request['reference'].$parameterizedValue."\" xmlns=\"http://www.pesapal.com\" />";
$postXml = htmlentities($postXml);

// Post transaction to PesaPal
Expand Down

0 comments on commit 36dc20c

Please sign in to comment.