public function testExtend()
 {
     $manager = new GatewayManager($this->config);
     $this->assertNull($manager->provider('example'));
     $manager->extend('example', function () {
         return new ExampleProvider();
     });
     $this->assertTrue($manager->provider('example') instanceof ProviderInterface);
 }
Example #2
0
    return new ExampleProvider();
});
/**
 * PaymentRequestNeeds
 * you can create new PaymentRequestNeeds
 * and customize it for your own provider
 *
 * for more information read Default payment providers
 */
$requestNeeds = new PaymentRequestNeeds();
$requestNeeds->setAmount(1000);
$requestNeeds->setReturnUrl('YOUR_CALLBACK_URL');
$requestNeeds->set('attr', 'value');
// Call with provider name
// by this, you can change provider on-the-fly
$manager->provider('example')->callPaymentRequest($requestNeeds);
// OR set provider as default provider
// this set example as default provider
// and you can call provider methods directly from manager
$manager->setDefaultProvider('example');
$response = $manager->callPaymentRequest($requestNeeds);
$verifyNeeds = new PaymentNeeds();
$verifyNeeds->set('amount', 1000);
$verifyNeeds->set('payment_id', 15415648);
$response = $manager->callPaymentVerify($verifyNeeds);
// Zarinpal example
$provider = $manager->provider('zarinpal');
// create payment request:
$requestNeeds = new PaymentRequestNeeds();
$requestNeeds->setAmount(1000)->setReturnUrl('http://some_url')->set('description', 'some description')->set('mobile', 'YOUR_PHONE_NUMBER')->set('email', 'YOUR_EMAIL_ADDRESS');
// optional