feat: PesaPal payment integration#1481
Conversation
beesaferoot
left a comment
There was a problem hiding this comment.
@AbogeJr, good work with the PR. I followed the steps and was able to test payment failure flow (because I don't have an active MPesa Number)
I noted some minor improvements below.
| $hash = $this->generatePermanentHash($companyId); | ||
| $token = $this->generateHashFromCompanyId($companyId); | ||
|
|
||
| return "/pesapal/public/payment/{$hash}?ct=".$token; |
There was a problem hiding this comment.
PesapalCompanyHashService has a lot in common with PaystackCompanyHashService can we extract that out into the core Services and reuse that somehow?
| public function updateCredentials(array $data): PesapalCredential { | ||
| $credential = $this->getCredentials(); | ||
| $tokenService = $this->container->make(PesapalTokenService::class); | ||
|
|
||
| $secretsRotated = array_key_exists('consumer_key', $data) | ||
| || array_key_exists('consumer_secret', $data); | ||
|
|
||
| if (array_key_exists('consumer_key', $data)) { | ||
| $data['consumer_key'] = Crypt::encrypt($data['consumer_key']); | ||
| } | ||
| if (array_key_exists('consumer_secret', $data)) { | ||
| $data['consumer_secret'] = Crypt::encrypt($data['consumer_secret']); | ||
| } | ||
|
|
||
| $environmentChanged = array_key_exists('environment', $data) | ||
| && $data['environment'] !== $credential->getEnvironment(); | ||
|
|
||
| $credential->update($data); | ||
| $credential->refresh(); | ||
|
|
||
| if (empty($credential->getAttribute('consumer_key')) || empty($credential->getAttribute('consumer_secret'))) { | ||
| throw new \RuntimeException('Consumer key and consumer secret are required.'); | ||
| } | ||
|
|
||
| if ($secretsRotated || $environmentChanged) { | ||
| $tokenService->forget($credential); | ||
| } | ||
|
|
||
| $this->ensureIpnRegistered($credential); | ||
|
|
||
| return $credential; | ||
| } |
There was a problem hiding this comment.
I know it's not currently used on the Paystack plugin (which needs to be refactored) but can we use the EncryptsCredentials trait for encryting model fields. It's used everywhere else.
|
@beesaferoot |
|
@beesaferoot Tested on Live as well.
|








Brief summary of the change made
Adds a PesaPal payment provider plugin so mini-grid operators in East Africa (Kenya, Uganda, Tanzania) can accept hosted-checkout payments via PesaPal v3
docs/integrations-guide/pesapal-integration.md.
closes: #1044
Are there any other side effects of this change that we should be aware of?
Describe how you tested your changes?
MPM_BACKEND_URL pointed at the backend tunnel
Pull Request checklist
Please confirm you have completed any of the necessary steps below.