Trouble Integrating to Visa Direct - php

My aim is to have an on line system where people can transfer money via visa direct and also pay for the services.
For this I needed to integrate to visa network. However, am having some challenges doing the same.
Well, this is what I have found to be the steps towards integrating with them:
Create a sandbox account where sample code is provided on how you can hit their end point.
My problem came when I found the sample code provided uses PHPUnit hence I have a problem testing on a browser.
The sample code generated for you can only be tested on a terminal via ./vendor/bin/phpunit.. My interest is to be able to test the same on a browser. Can this be done?
After you are done with the tests, you request them to be allowed to move to production.
I am yet to get to this stage since I am stuck at one.
A major concern is that the email provided for communication during the development journey takes days before it is responded. This makes the development journey a bit too long.
Has anyone done this before probably in PHP and would be willing to help me?
Kind regards.

Your work process should be like that:
1- Your code:
You have your webserver and php backend.
2- Visa API:
Download Visa api via Composer.
Test if the api works by itself (isolated from your backend) using phpunit.
After running phpunit, you know your installation of the API is successful. Now you're ready to use it.
Note that the API vendor Visa have already wrote the tests and added phpunit package along with their api, so you just run phpunit.
3- Integration
In your backend, instantiate a Visa API object (I think their API is a class).
Do the function calls as per their API docs.
To write your code, you need to look at API, and use help from their tests and sample codes.
4- Testing
Either use a test suit like phpunit or something else.
If it compiles, it is tested ;) // Don't do that.

Related

How do I onboard a submerchant in Braintree? [PHP SDK]

In PHP, I am developing an application that is going to use the Braintree Marketplace functionality - for users within my platform to be able to handle escrow transactions for projects they post. I understand the code on how to do actual transactions, but I am having issues on the sub-merchant process and where that necessary code is supposed to go.
I have looked extensively on how to onboard sub-merchants with the code from their documentation, but where am I supposed to put all this? On its own separate page? The only coding example is the very basics here on Github. I need to be able to create these sub-merchants so that I can test escrow within their Sandbox.
It turns out that what I was trying to do was a limitation of Braintree itself. At that time, you were not able to test escrow transactions within their Sandbox. Not sure if that has changed over the past year.
For those looking for a much better payments API, check out Stripe instead.

PHP: How to test my REST API

I created a API and would like to test it. My initial thoughts was to use an API client, which I did, I used guzzlehttp, but after deploying the app to heroku and using travis and coveralls to build my test, it turns out coveralls is not able to see the part of my code covered by the test.
So my question is really "How do I test my REST API without an API Client?"
below is the link to my Github showing 0% as my test coverage

Mocking Stripe and AWS APIs in CodeIgniter

I have written Integration tests for an application built in CodeIgniter 2.x. The tests are a Selenium + PhpUnit combination.
So far, I have used test accounts of Stripe and Amazon within the application and obviously the tests use the same accounts. I was wondering how would i go about creating Mock objects for these APIs so that i can avoid live data creation/deletion.
For Stripe, i could not find any mocking library for PHP. So stubbing the responses and requests does seem to be a good option. But again, even if i use stubs in my tests in place of real data, the application during that certain integration test will still be needing correct information for it to pass.How do i tell the application to use fake data?
Also, i would like to know if it is generally a good idea to mock objects in integration tests i.e. within the context of web applications?
This is a tool that Stripe themselves have developed for mocking Stripe.
https://github.com/stripe/stripe-mock
It runs a server on your local machine that responds to API calls in s Stripe-like fashion. This would be something you could try for acceptance tests
For PHP Unit tests, you'd be better using something like AspectMock - although config is a bit tricky. You can specify in advance what a call to a Stripe resource (e.g. \Stripe\Stripe::setApiKey, or \Stripe\Customer::retrieve) is supposed to return without hitting the Stripe servers - and you can also test whether or not your application code tried to make these calls. You can also simulate failures to test that your application behaves properly if, say, Stripe is down.

Is it possible to integrate with Sagepay Virtual Terminal using PHP?

I'm crating a Sagepay Direct implementation for a client, which deals with taking deposits and payments, as well as refunding deposits. This is fine for online payments, but the client also takes phone payments through Sagepay's Virtual Terminal.
I would like to handle these payments through my system, which would allow a higher percentage of the refunds to be automated but, despite searching Sagepay's resources, Google, and SO, I can't find any information at all on integrating with the terminal.
So, what I would like to know is:
Is it possible to integrate in this way, and if so are there some resources I'm missing?
If there's no official API, would Sagepay implement anything that would prevent automating the process through CURL or a similar technology.
I have worked with Sagepay (both Direct and Form) before and am quite familiar with the online payment side of things, but not familiar with the Terminal.
Okay, so I talked to Sagepay support and the answer is far simpler than I was expecting. I don't need to integrate with Terminal, I just have to use the standard integration and change the value of AccountType to 'M'.

Unit Testing Google OAuth2 with PHP

I'm wondering if there is some way to do unit testing using the Google API for authentication using the Google API PHP Client.
Here is the kind of code example that I want to use around my unit testing case.
(but i want to do more complicated things around it of course that is why i need to do unit testing)
http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/userinfo/index.php
It is messy, but possible. It is not going to be exactly unit testing, but still...
You need to
either write stubs for the parts of your code which do actual
requests to the google api, which would return predefined responses
which your code needs to be ready for.
or create a simple separate
service in your local network which would behave like google api web
service. It is easier than it sounds - a simple php script with a
switch and a readfile(responseFileNumberN)...
Either way you need to decide which of google's behaviours/errors you need to emulate. Testing on live service is a bad idea. This way you are going to test google's api which is out of your control or your network connection, not your app.

Categories