Last active
February 8, 2022 10:28
-
-
Save brexis/d46c76f106f67a9e5bfae4d3874c8369 to your computer and use it in GitHub Desktop.
FedaPay php integration
This file contains hidden or 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
require_once('vendor/autoload.php'); | |
$token = "sk_sandbox_WNxERQEilcpD-fYboNG2-Twy"; | |
\FedaPay\FedaPay::setApiKey($token); | |
\FedaPay\FedaPay::setEnvironment('sandbox'); //ou setEnvironment('live'); | |
// Créer une transaction | |
try { | |
$transaction = \FedaPay\Transaction::create(array( | |
"description" => "Transaction for [email protected]", | |
"amount" => 2000, | |
"currency" => ["iso" => "XOF"], | |
"callback_url" => "https://cooke.bj/callback", | |
"customer" => [ | |
"firstname" => "John", | |
"lastname" => "Doe", | |
"email" => "[email protected]", | |
"phone_number" => [ | |
"number" => "+22997808080", | |
"country" => "bj" | |
] | |
] | |
)); | |
// Generer le lien de paiement | |
$token = $transaction->generateToken(); | |
return header('Location: ' . $token->url); | |
} catch (\FedaPay\Error\ApiConnection $e) { | |
print_r($e->getMessage()); | |
if ($e->hasErrors()) { | |
print_r($e->getErrorMessage()); | |
print_r($e->getErrors()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment