Skip to content

Instantly share code, notes, and snippets.

@brexis
Last active February 8, 2022 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brexis/d46c76f106f67a9e5bfae4d3874c8369 to your computer and use it in GitHub Desktop.
Save brexis/d46c76f106f67a9e5bfae4d3874c8369 to your computer and use it in GitHub Desktop.
FedaPay php integration
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 john.doe@example.com",
"amount" => 2000,
"currency" => ["iso" => "XOF"],
"callback_url" => "https://cooke.bj/callback",
"customer" => [
"firstname" => "John",
"lastname" => "Doe",
"email" => "seb@accessia.fr",
"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