🍲dfcv🏰dd⋉(● ∸ ●)⋊@% PNG %k25u25%fgd5n! PNG %k25u25%fgd5n!laravelrave/tests/Feature/FeatureTests.php 0000644 00000014673 15242762156 0014761 0 ustar 00 subaccounts = [];
$request->meta = [];
$request->ref = false;
$request->logo = false;
$request->title = false;
$request->paymentplan = false;
$request->phonenumber = '080232382382';
$request->payment_method = 'online';
$request->pay_button_text = 'Pay Now';
$rave = new Rave();
$rave->initialize("http://localhost");
$this->assertTrue($rave instanceof Rave);
return $rave;
}
/**
* Test if hash is created.
*
* @test
* @depends getParams
* @param Rave $rave
* @return void
* @throws \ReflectionException
*/
function creatingCheckSum(Rave $rave) {
#$rave = $rave->createReferenceNumber();
$publicKey = "FLWPUBK-MOCK-1cf610974690c2560cb4c36f4921244a-X";
$rave->initialize("http://localhost");
$rave = $rave->createCheckSum('http://localhost');
$hash = $this->extractProperty($rave, "integrityHash");
$this->assertEquals(64, strlen($hash["value"]));
return $rave;
}
/**
* Testing payment.
*
* @test
* @depends creatingCheckSum
* @param Rave $rave
* @return void
*/
function paymentInitialize(Rave $rave) {
$response = $rave->eventHandler(new PaymentEventHandler)->initialize("http://localhost");
$values = json_decode($response, true);
$class = $this->data["class"];
$this->assertArrayHasKey("meta", $values);
$this->assertArrayHasKey("txref", $values);
$this->assertArrayHasKey("amount", $values);
$this->assertArrayHasKey("country", $values);
$this->assertArrayHasKey("currency", $values);
$this->assertArrayHasKey("PBFPubKey", $values);
$this->assertArrayHasKey("custom_logo", $values);
$this->assertArrayHasKey("redirect_url", $values);
$this->assertArrayHasKey("data-integrity_hash", $values);
$this->assertArrayHasKey("payment_method", $values);
$this->assertArrayHasKey("customer_phone", $values);
$this->assertArrayHasKey("customer_email", $values);
$this->assertArrayHasKey("pay_button_text", $values);
$this->assertArrayHasKey("customer_lastname", $values);
$this->assertArrayHasKey("custom_description", $values);
$this->assertArrayHasKey("customer_firstname", $values);
}
/**
* Test if proper actions are taken when payment is cancelled.
*
* @test
* @return void
*/
function paymentCancelledTest() {
$request = new Request();
$request->cancelled = true;
$rave = new Rave();
$rave = $rave->createReferenceNumber();
$ref = $rave->getReferenceNumber();
// This section tests if json is returned when no handler is set.
$returned = $rave->paymentCanceled($ref);
$this->assertTrue( is_object($returned));
// Tests if json has certain keys when payment is cancelled.
$returned = json_decode(json_encode($returned), true);
$this->assertArrayHasKey("data", $returned);
$this->assertArrayHasKey("txRef", $returned['data']);
$this->assertArrayHasKey("status", $returned['data']);
// This section tests if instance of rave is returned when a handler is set.
$rave->eventHandler(new PaymentEventHandler)->paymentCanceled($ref);
$this->assertEquals(Rave::class, get_class($rave));
return $ref;
}
/**
* Testing requery transactions.
*
* @test
* @depends paymentCancelledTest
* @dataProvider providesResponse
* @runInSeparateProcess
* @preserveGlobalState disabled
* @param string $ref txref
*/
// function requeryTransactionTransactionTest($mResponse, $ref) {
//
// $data = [
// 'txref' => $ref,
// 'SECKEY' => $this->app->config->get("secretKey"),
// 'last_attempt' => '1'
// // 'only_successful' => '1'
// ];
//
// $url = "https://rave-api-v2.herokuapp.com";
// $headers = ['Content-Type' => 'application/json'];
//
// $data = Body::json($data);
// $response = json_encode($mResponse);
//
// $decodedResponse = json_decode($response);
//
// $mRequest = $this->m->mock("alias:Unirest\Request");
// $mRequest->shouldReceive("post")
// ->andReturn($decodedResponse);
//
// $rave = new Rave(new Request(['cancelled' => true]), $mRequest, new Body);
//
// $raveResponse = $rave->verifyTransaction($ref);
//
// // Test if data is returned when no handler.
// // $this->assertEquals($decodedResponse->body->status, $raveResponse->status);
//
// $this->setProperty($rave, "handler", new PaymentEventHandler);
//
// $raveResponse = $rave->verifyTransaction($ref);
//
// // Tests that an instance of rave is returned when a handler is set
// $this->assertTrue(Rave::class, get_class($raveResponse));
// }
/**
* Provides data for all events of requery transaction.
*
* @return array
*/
function providesResponse () {
return [
[
[
"body" => [
"status" => "unknown",
"data" => ["status", "unknown"]
],
],
],
[
[
"body" => [
"status" => "success",
],
]
],
[
[
"body" => [
"status" => "success",
"data" => [
"status" => "failed"
]
],
]
],
[
[
"body" => [
"status" => "success",
"data" => [
"status" => "successful"
]
],
]
]
];
}
}
laravelrave/tests/Unit/UnitTests.php 0000644 00000005714 15242762156 0013625 0 ustar 00 app->make("laravelrave");
$this->assertTrue($rave instanceof Rave);
return $rave;
}
/**
* Test Rave initiallizes with default values;.
*
* @test
*
* @depends initiateRaveFromApp
* @param \KingFlamez\Rave\Rave $rave
* @return void
* @throws \ReflectionException
*/
function initializeWithDefaultValues(Rave $rave)
{
$reflector = new ReflectionClass($rave);
$methods = $reflector->getProperties(ReflectionProperty::IS_PROTECTED);
foreach ($methods as $method) {
if ($method->getName() == 'baseUrl') $baseUrl = $method;
if ($method->getName() == 'secretKey') $secretKey = $method;
if ($method->getName() == 'publicKey') $publicKey = $method;
};
$baseUrl->setAccessible(true);
$publicKey->setAccessible(true);
$secretKey->setAccessible(true);
$this->assertEquals($this->app->config->get("flutterwave.secretKey"), $secretKey->getValue($rave));
$this->assertEquals($this->app->config->get("flutterwave.publicKey"), $publicKey->getValue($rave));
$this->assertEquals(
"https://api.flutterwave.com/v3",
$baseUrl->getValue($rave)
);
}
/**
* Tests if transaction reference is generated.
*
* @test
* @depends initiateRaveFromApp
* @param Rave $rave
* @return void
*/
function generateReference(Rave $rave)
{
$ref = $rave->generateReference();
$prefix = 'flw';
$this->assertRegExp("/^{$prefix}_\w{13}$/", $ref);
}
/**
* Testing if keys are modified using setkeys.
*
* @test
* @depends initiateRaveFromApp
* @param Rave $rave
* @return void
* @throws \ReflectionException
*/
function settingKeys(Rave $rave)
{
$newPublicKey = "public_key";
$newSecretKey = "secret_key";
$rave->setKeys($newPublicKey, $newSecretKey);
$reflector = new ReflectionClass($rave);
$reflector = $reflector->getProperties(ReflectionProperty::IS_PROTECTED);
$keys = array_map(function ($value) use ($rave, $newPublicKey, $newSecretKey) {
$name = $value->getName();
if ($name === "publicKey" || $name === "secretKey") {
$value->setAccessible(true);
$key = $value->getValue($rave);
$this->assertEquals(${"new" . ucfirst($name)}, $key);
}
}, $reflector);
}
}
laravelrave/tests/Unit/RaveServiceProviderTests.php 0000644 00000001244 15242762156 0016631 0 ustar 00 assertTrue($this->app->bound('laravelrave'));
}
/**
* Test if service provider returns \Rave as alias for \KingFlamez\Rave\Rave
*
* @test
*/
public function hasAliased()
{
$this->assertTrue($this->app->isAlias("KingFlamez\Rave\Rave"));
$this->assertEquals('laravelrave', $this->app->getAlias("KingFlamez\Rave\Rave"));
}
}
laravelrave/tests/Stubs/Request.php 0000644 00000001057 15242762156 0013470 0 ustar 00 {$key} = $value;
});
}
}
laravelrave/tests/Stubs/PaymentEventHandler.php 0000644 00000007365 15242762156 0015765 0 ustar 00 '; //Remember to delete this line
}
/**
* This is called only when a transaction is successful
* */
function onSuccessful($transactionData){
// Get the transaction from your DB using the transaction reference (txref)
// Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue
// Comfirm that the transaction is successful
// Confirm that the chargecode is 00 or 0
// Confirm that the currency on your db transaction is equal to the returned currency
// Confirm that the db transaction amount is equal to the returned amount
// Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose)
// Give value for the transaction
// Update the transaction to note that you have given value for the transaction
// You can also redirect to your success page from here
return 'Payment Successful!'.json_encode($transactionData).'
'; //Remember to delete this line
}
/**
* This is called only when a transaction failed
* */
function onFailure($transactionData){
// Get the transaction from your DB using the transaction reference (txref)
// Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose)
// You can also redirect to your failure page from here
return 'Payment Failed!'.json_encode($transactionData).'
'; //Remember to delete this line
}
/**
* This is called when a transaction is requeryed from the payment gateway
* */
function onRequery($transactionReference){
// Do something, anything!
return 'Payment requeried......'.$transactionReference.'
'; //Remember to delete this line
}
/**
* This is called a transaction requery returns with an error
* */
function onRequeryError($requeryResponse){
// Do something, anything!
return 'An error occured while requeying the transaction...'.json_encode($requeryResponse).'
'; //Remember to delete this line
}
/**
* This is called when a transaction is canceled by the user
* */
function onCancel($transactionReference){
// Do something, anything!
// Note: Somethings a payment can be successful, before a user clicks the cancel button so proceed with caution
return 'Payment canceled by user......'.$transactionReference.'
'; //Remember to delete this line
}
/**
* This is called when a transaction doesn't return with a success or a failure response. This can be a timedout transaction on the Rave server or an abandoned transaction by the customer.
* */
function onTimeout($transactionReference, $data){
// Get the transaction from your DB using the transaction reference (txref)
// Queue it for requery. Preferably using a queue system. The requery should be about 15 minutes after.
// Ask the customer to contact your support and you should escalate this issue to the flutterwave support team. Send this as an email and as a notification on the page. just incase the page timesout or disconnects
return 'Payment timeout......'.$transactionReference.' - '.json_encode($data).'
'; //Remember to delete this line
}
}
laravelrave/tests/Stubs/env.php 0000644 00000000576 15242762156 0012635 0 ustar 00 "rave",
"secretKey" => "FLWSECK-4127f15e63c9098402dcc7891798fb0f-X",
"publicKey" => "FLWPUBK-1cf610974690c2560cb4c36f4921244a-X",
"title" => "Rave Payment Gateway",
"env" => "testing",
"logo" => "https://files.readme.io/ee907a0-small-rave_by_flutterwave.png"
];
laravelrave/tests/Stubs/request_data.php 0000644 00000002106 15242762156 0014515 0 ustar 00 [
"amount" => 30000,
"title" => "A Title",
"lastname" => "Last",
"currency" => "naira",
"country" => "Nigeria",
"firstname" => "First",
"payment_method" => "card",
"phonenumber" => "08012345678",
"email" => "email@example.org",
"pay_button_text" => "Pay Now",
"metadata" => "[{ flightid:3849 }]",
"description" => "Some random description.",
"logo" => "https://files.readme.io/ee907a0-small-rave_by_flutterwave.png",
],
/**
* Rave original properties representation.
*/
"class" => [
"amount",
"country",
"currency",
"lastname",
"firstname",
["logo" => "customLogo"],
"phonenumber",
["title" => "customTitle"],
"payButtonText",
["email" => "customerEmail"],
"payment_method",
["description" => "customeDescription"],
"metadata",
]
];
laravelrave/tests/Concerns/ExtractProperties.php 0000644 00000002126 15242762156 0016177 0 ustar 00 getProperty($name);
$property->setAccessible(true);
return [
"name" => $property->getName(),
"value" => $property->getValue($class),
];
}
/**
* Set property of class.
*
* @param \stdClass $class
* @param string $name Property name
* @param mixed $value
* @throws \ReflectionException
*/
function setProperty($class, $name, $value = null) {
$reflector = new ReflectionClass($class);
$property = $reflector->getProperty($name);
$property->setAccessible(true);
$property->setValue($class, $value);
}
}
laravelrave/tests/TestCase.php 0000644 00000003210 15242762156 0012444 0 ustar 00 m = new Mockery;
$this->envVars = (array) include __DIR__ . "/Stubs/env.php";
$this->data = (array) include __DIR__ . "/Stubs/request_data.php";
$this->formData = $this->data["form"];
parent::setUp();
}
/**
* Clear mockery after every test in preparation for a new mock.
*
* @return void
*/
function tearDown() : void {
$this->m->close();
parent::tearDown();
}
/**
* Register package.
*
* @param \Illuminate\Foundation\Application $app
* @return array Packages to register
*/
protected function getPackageProviders($app)
{
return [ "\KingFlamez\Rave\RaveServiceProvider" ];
}
/**
* Get alias packages from app.
*
* @param \illuminate\Foundation\Application $app
* @return array Aliases.
*/
protected function getPackageAliases($app)
{
return [
"Rave" => "\KingFlamez\Rave\Facades\Rave"
];
}
/**
* Configure Environment.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
array_walk($this->envVars, function ($value, $key) use (&$app) {
$app["config"]->set("flutterwave.{$key}", $value);
});
}
}
laravelrave/resources/img/pay.jpg 0000644 00000054611 15242762156 0013152 0 ustar 00 Exif MM * b j( 1 $ r2 i ' 'Adobe Photoshop CC 2017 (Macintosh) 2017:12:29 08:37:17 j & .( 6 H H Adobe_CM Adobe d
h "
?
3 !1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw 5 !1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ? TI%)$IJI$RI$I%)$IJI$RI$I%)$IOTI%)$IJI$RI$I%)$IJI$RI$I%)$IOTI%)$IJI%[/b:8anA%6RU߅ %p'V[4zLcokAp{
mwIMFu^fư8
N}7I[j:{n
;geV;%7RTza~Cistuw~Wl;YmO5-m V sVUjJnI I}Wպ}+9
@vͻ?u%7Us38CCI-{k_rI$$I)TI%)$IJU1sC7snsD:71omWgXI%4*4.c]9,MoA3zJo7nl/K/kA$gFQ5kKZOkX15}K\A9M۞=gѳgWͣUf=>+y}WUV ^G"JnݯHqs8=e^39-5c,ְZX슽ٲI zkg\[n6~~'teoԘsA =kkHw~~RoF`>
nmK O{5y$ع_H-6561kַ դIJI$RI$ TI%)$IJI$RI$$Od$$I)I$JRI$I$$I)TI%)$IJI$RI$I%)$IJI$RI$I%)$IOTʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$ꤗʩ$Photoshop 3.0 8BIM 8BIM% \/{gdպ8BIM: printOutput PstSbool Inteenum Inte Clrm printSixteenBitbool printerNameTEXT printProofSetupObjc P r o o f S e t u p
proofSetup Bltnenum builtinProof proofCMYK 8BIM; - printOutputOptions Cptnbool Clbrbool RgsMbool CrnCbool CntCbool Lblsbool Ngtvbool EmlDbool Intrbool BckgObjc RGBC Rd doub@o Grn doub@o Bl doub@o BrdTUntF#Rlt Bld UntF#Rlt RsltUntF#Pxl@b
vectorDatabool PgPsenum PgPs PgPC LeftUntF#Rlt Top UntF#Rlt Scl UntF#Prc@Y cropWhenPrintingbool cropRectBottomlong cropRectLeftlong
cropRectRightlong cropRectToplong 8BIM 8BIM&