-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from brandeddavid/card-checkout
Card checkout Functionality
- Loading branch information
Showing
15 changed files
with
770 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import axios from "axios"; | ||
import "dotenv/config"; | ||
|
||
const getAuthToken = async () => { | ||
const headersList = { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}; | ||
|
||
let reqOptions = { | ||
url: "https://sbkltest.finsprint.io/api/v1/token", | ||
method: "POST", | ||
headers: headersList, | ||
data: JSON.stringify( | ||
{ | ||
email: process.env.CLIENT_EMAIL, | ||
client_id: process.env.CLIENT_ID, | ||
client_secret: process.env.CLIENT_SECRET, | ||
} | ||
), | ||
}; | ||
try { | ||
const response = await axios.request(reqOptions); | ||
|
||
return response; | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
export default getAuthToken; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios"; | ||
|
||
const proceedCheckout = async ({ phoneNumber, email, amount , accessToken}: any) => { | ||
const headersList = { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${accessToken}`, | ||
}; | ||
|
||
let reqOptions = { | ||
url: "https://sbkltest.finsprint.io/api/v1/invoices/checkout", | ||
method: "POST", | ||
headers: headersList, | ||
data: JSON.stringify({ | ||
credit_account_number: "1115510052653", | ||
merchant_name: "Redcross", | ||
merchant_logo: | ||
"https://www.redcross.or.ke/wp-content/uploads/2023/03/logo-203x114-1.png", | ||
currency: "KES", | ||
amount: amount, | ||
result_url: "https://fulgence.free.beeceptor.com", | ||
reference_id: "60987RED", | ||
remarks: "string", | ||
email: email , | ||
phone: phoneNumber, | ||
gateways: "mpesa", | ||
notification_channels: "sms", | ||
}), | ||
}; | ||
|
||
console.log("request body", { reqOptions }); | ||
|
||
try { | ||
const response = await axios.request(reqOptions); | ||
|
||
console.log("response", { response }); | ||
|
||
return response; | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
export default proceedCheckout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from "react"; | ||
|
||
type Props ={ | ||
handleClick : ()=> void; | ||
|
||
} | ||
|
||
function CardCheckout({handleClick}: Props) { | ||
|
||
return ( | ||
<div className="flex items-center p-4 border border-gray-200 rounded" onClick={handleClick}> | ||
<input | ||
id="bordered-radio-1" | ||
type="radio" | ||
value="" | ||
name="bordered-radio" | ||
className="w-4 h-4 text-primary bg-gray-100 border-gray-300 focus:ring-red-500 focus:ring-2 " | ||
/> | ||
<label | ||
htmlFor="bordered-radio-1" | ||
className="w-full py-4 ms-2 text-sm font-medium text-gray-900" | ||
> | ||
Click to initiate card payment | ||
</label> | ||
</div> | ||
|
||
); | ||
} | ||
|
||
export default CardCheckout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.