Trouble implementing omnipay - codeigniter

I am using codeigniter and would like to implement omnipay. My development environment is windows and i use wamp server. After much struggle i installed it downloading composer and then curl and then changing the access controls in httpd.conf.
Now i am having trouble using the functions of omnipay. I have created a gateway with this code
echo 'testing the omnipay';
require 'Vendor/autoload.php';
use Omnipay\Common\GatewayFactory;
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername('some_username');
$gateway->setPassword('some_password');
$gateway->setSignature('some_signature');
$gateway->setTestMode(true);
I am not sure how to proceed furthur
I would like to know if there are any tutorials or online documentation for proper use of omnipay
regards,
Nandakumar

Once you have set created the gateway, you can make a purchase with it. The documentation is in the README which comes with Omnipay.
There is an example here: https://github.com/omnipay/omnipay#tldr
and here: https://github.com/omnipay/omnipay#gateway-methods
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}

Related

How to access Redirect Url of Paypal through

Using Paypal for payment it is working fine when I hit html form from a browser then It redirect's me to Paypal page for payment but on other side when I try to hit it from postman api then it gives error on postman as it is redirecting so my question is that how I would access that redirect or url of that redirect in Postman API?
I used this code
try {
$response = $this->gateway->purchase(array(
'amount' => $order_amount->total_price,
'currency' => env('PAYPAL_CURRENCY'),
'returnUrl' => url('success'),
'cancelUrl' => url('error'),
))->send();
if ($response->isRedirect()) {
$response->redirect(); // this will automatically forward the customer
} else {
// not successful
return $response->getMessage();
}
} catch (Exception $e) {
return $e->getMessage();
}
You cannot "access" redirect URLs from Postman, nor from any other automated system. The redirect URL mus be opened in a browser, and a payer account must sign in to give approval. On return from PayPal to the provided return_url, the ID of the order or payment will be in the URL. This should then be used to capture/execute it.
For best results, do not use any redirects. At all. Redirects returned by the API are for old websites, and should not be used by new integrations.
Instead, use the following approval flow from the payment page, which keeps your site loaded in the background (no redirect away): https://developer.paypal.com/demo/checkout/#/pattern/server
A full stack example in node can be found at: https://developer.paypal.com/docs/checkout/standard/integrate/ ; its backend can of course be implemented in PHP/laravel or any other web environment capable of returning the JSON from the API.

Laravel + Twilio SDK: Class 'Services_Twilio_Twiml' not found

I new to Laravel and newer to Twilio.
I have a working laravel 5.4 server installed w/ Composer. I installed the Twilio SDK in the root directory of my Twilio project w/ Composer.
I receive the following error when loading some basic code from the "Getting Started with Twilio and the Laravel framework for PHP" tutorial.
Class 'Services_Twilio_Twiml' not found
I really don't know what to do now.
Does anyone have any suggestions?
Route::match(array('GET', 'POST'), '/incoming', function()
{
$twiml = new Services_Twilio_Twiml();
$twiml->say('Hello - your app just answered the phone.
Neat, eh?', array('voice' => 'alice'));
$response = Response::make($twiml, 200);
$response->header('Content-Type', 'text/xml');
return $response;
});
Twilio developer evangelist here.
I think you're trying to call the old version of the Twilio PHP library there.
To use TwiML with version 5 of the PHP library you would use the Twilio\Twiml object, like this:
Route::match(array('GET', 'POST'), '/incoming', function()
{
$twiml = new Twilio\Twiml;
$twiml->say('Hello - your app just answered the phone.
Neat, eh?', array('voice' => 'alice'));
$response = Response::make($twiml, 200);
$response->header('Content-Type', 'text/xml');
return $response;
});
There are a bunch of Twilio and Laravel tutorials available here that might help you too.
Let me know if that helps at all.

Inventory stock is not updating for a particular product using Soap Api

I am using Magento version 1.12.0.2.
I am not able to update stock quantity using soap API. It is working fine for other products except one. I tried to update manually from admin and it worked fine but when trying to update from soap API, its not updating.
Please find the script below:
$proxy = new SoapClient('https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl');
$sessionId = $proxy->login('demo', 'demotest');
$result = $proxy->catalogInventoryStockItemUpdate($sessionId, 3711, array(
'qty' => '31',
'is_in_stock' => 1
));
var_dump($result);
Use soap client- https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl=1 insteed of https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl.

Http request and response in codeigniter

I am currently working in codeigniter and I am new to this.
I was wondering how to retrieve the JSON values using API call .
Can anyone suggest me where should I start.
Many Thanks in advance
Pass your array of row to json_encode();example for method of controller is below
public function getUserList() {
header('Content-Type: application/json');
$query = $this->db->get('mytable');
if(count($query) > 0) {
$message = array('status' => 'true' , 'message' => 'Record get successfully' , 'data' => $return );
}else{
$message = array('status' => 'false' , 'message' => 'Record not found.' );
}
echo json_encode($message);
}
Codeigniter does not have an inbuilt HTTP method so you need to use other things in php to achieve this.
There are 2 ways, you can use cURL, but honestly... it's convoluted... but read this: http://php.net/manual/en/book.curl.php
Another method is using stream_context_create() http://php.net/manual/en/function.stream-context-create.php
I strongly suggest using this 2nd one as its much easier to work with (in context with curl..
Much of how you setup your request depends on the API you are referencing with and the kind of requests it allows: GET, POST ... and what kind of header information it requires you to send over as well do they require oAuth header?
There is no 1 bunch of code fits all, I had to create a full custom library to integrate codeigniter into Magento, it took many hours.

Send SMS from Web (are there some providers for this)?

I'd like to have something like what the app.net site has. You click a button and get the option to send a link to your phone via SMS (or email). What are some options for implementing the sms side of things, and are there services or open source packages that provide this?
Here's a random example from app.net . Click the "Get this App" button to see what I mean.
Something like this would even work for me Send link to Phone Where "saasSMS.com" is some service that handles the whole sms side of things. Ideally could either handle that via a link or via a form post (and it would redirect back to your site on success or something).
What I don't want: A drop down that makes you pick your carrier and some php page that tries to email you #vtext.com or similar. That is just not slick enough.
You can use the ViaNett HTTP API to send SMS messages worldwide without specifying the operator.
As long as your backend supports invoking HTTP requests it will work.
Here is an example written in PHP:
<?php
// Register here to get a username and password:
// http://www.vianett.com/en/free-demonstration-account
if (vianett_sendsms('username', 'password', 'example', '+4412345678', 'Hello world', $error)) {
echo 'Success!';
} else {
echo $error;
}
function vianett_sendsms($username, $password, $from, $to, $msg, &$response=null) {
$url = 'https://smsc.vianett.no/v3/send.ashx';
$data = array(
'user' => $username,
'pass' => $password,
'src' => $from,
'dst' => $to,
'msg' => $msg
);
$qs = http_build_query($data);
$response = file_get_contents($url.'?'.$qs);
return $response == '200|OK';
}
We're getting good results from http://www.twilio.com
For direct SMS, you can try contacting a service provider and make a contract with it. If its for small projects and the server is accessible, you could put a GPRS mobile phone or modem and send with it.

Resources