Coder Social home page Coder Social logo

mastercardcoresdk-php's Introduction

Read Me

PHP Core SDK for use with Masterpass Merchant Checkout Service SDK on MasterCard Developer Zone (https://developer.mastercard.com)

Pre-Requisites for using PHP MasterCard Core SDK:

  • PHP 5.5 or higher
  • Download MasterCardCoreSDK-PHP phar file
Note: Refer to mastercard developer zone for documentation on SDKs for implementation reference and avoid potential break in your existing code if you upgrade with higher version.
Documentation for SDK Integration:

For Masterpass V6 :

For configuration and pre-requisites: https://developer.mastercard.com/documentation/masterpass-merchant-integration-v6 For standard/express checkout integration: https://developer.mastercard.com/documentation/masterpass-merchant-integration-v6#tutorials

For Masterpass V7:

For configuration and pre-requisites https://developer.mastercard.com/documentation/masterpass-merchant-integration-v7 For standard checkout integration: https://developer.mastercard.com/documentation/masterpass-merchant-integration-v7#standard-checkout For express checkout integration: https://developer.mastercard.com/documentation/masterpass-merchant-integration-v7#express-checkout

This phar can be downloaded from github directly or by using composer dependency.

If you do not have composer installed you can download it from https://getcomposer.org/

To download this phar as composer dependency, put a file named composer.json at the root of your project, containing as your project dependencies:

MasterCardCoreSDK v6 :

{
   "require": {
     "masterpass/mpasscoresdk":"1.3.0"
   }
}

MasterCardCoreSDK v7 :

{
   "require": {
     "masterpass/mpasscoresdk":"2.3.0"
   }
}

In order to import this package in your application, you need to use following composer command after installing composer locally:

composer update

Usage

Set configurations for private key and consumer key to call API:


MasterCardApiConfig::$consumerKey = "YOUR_CONSUMER_KEY";
MasterCardApiConfig::$privateKey = "YOUR_PRIVATE_KEY";
MasterCardApiConfig::setSandBox(true); // For sandbox environment. By default SANDBOX environment is set as true, Set sandbox to false to use Production environment

Customize default SSL settings for the SDK through Configuration class using following code: [You may get SSL Exception if there is no already configured ssl certificate file exists locally or in php.ini] Note: SSL Verification is set to True by default. Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.


$conf = new Configuration();
$conf->setSSLVerification("C:\\Users\\Documents\\cert.pem");
Configuration::setDefaultConfiguration($conf);

Example : Api Call


$RequestTokenResponse = RequestTokenApi::create(<URL>);

You can get more information about integrating MasterCard Merchant Checkout SDK from MasterCard Developer Zone -

Merchant Integration section.

mastercardcoresdk-php's People

Contributors

masterpass avatar

Stargazers

 avatar  avatar

mastercardcoresdk-php's Issues

Guzzle version 6.0.0 forced

It seems that only v6.0.0 of Guzzle is allowed. I have other packages installed that require higher versions and this prevents me from being able to include this library via composer - is there a reason this specific version is forced?

Thanks

Dependency failures?

Hi

I'm attempting to integrate Masterpass via the documentation available here:
https://developer.mastercard.com/documentation/masterpass-merchant-integration#php

Per the documentation, I need to use both of the following SDKs:

I am attempting to include the phar files into our application per the following example from the documentation:

include_once 'MasterCardCoreSDK.phar';
include_once 'MasterCardMasterPassMerchant.phar';

Unfortunately, both of the SDKs appear - as best as I can tell - to contain references to missing dependencies that seem not to have been compiled into the phar.

I created two test-cases to demonstrate the problems:
https://github.com/RevoPay/masterpass-debug

The problems occur regardless of whether additional composer dependencies are made available via the composer autoloader.

To see the errors that occur without using composer, run:

php -f src/without-composer.php

To see the errors that occur with composer, run:

php -f src/with-composer.php

You'll see that the errors change, but there are errors in both cases. Also, please note that both SDKs throw errors.

PEAR

It's worth noting that the documentation contains what I believe to be an error that may have something to do with this problem.

The documentation advises to add the following snippet to composer.json:

"repositories": [
        {
            "type": "pear",
            "url": "https://pear.php.net"
        }
    ]

It's worth noting that:

  1. This causes composer to throw errors on composer install
  2. This isn't necessary, because the dependent package is available in Packagist.

System Information

chris@fourside:~/src/revo/organization/masterpass-debug$ uname -a
Linux fourside 4.8.0-22-generic #24-Ubuntu SMP Sat Oct 8 09:15:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
chris@fourside:~/src/revo/organization/masterpass-debug$ php --version
PHP 5.6.30-12~ubuntu16.10.1+deb.sury.org+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Please let me know if you have any questions. Thanks.

Oauth timestamp is not valid

Hello!

I'm having a hard time implementing the masterpass wallet service.

I am using the SDK for PHP, and when requesting the creation of the token is returning the following message:

Description: Oauth timestamp is not valid
ReasonCode: INVALID_TIMESTAMP
Source: OAuth.Timestamp
Response Code 403

Here's also the log:

2017-05-31T14:52:58+00:00 ApiClient.php INFO POST https://sandbox.api.mastercard.com/oauth/consumer/v1/request_token
2017-05-31T14:52:58+00:00 ApiClient.php INFO Authorization header added in the request.
2017-05-31T14:52:58+00:00 ApiClient.php DEBUG Request Information
POST https://sandbox.api.mastercard.com/oauth/consumer/v1/request_token
Content-Type: application/xml;
Authorization: OAuth oauth_consumer_key="xxxxxxxxxxxxxx0000000000000000",oauth_signature_method="RSA-SHA1",oauth_nonce="2b769069ccdc3a1f",oauth_timestamp="1496242378",oauth_version="1.0",oauth_callback="mgmtdev.level4pay.com%3A7779%2Fmasterpass",oauth_signature="lnXEwQ1mALcdyuegpaOQCJTJeeAfGqxBOlCrY7XZtUtSoUTh%2BljKQnAx%2BU%2FDOtD%2BZlWzDLQHl4KkN7%2FDY4e6%2F2IIlkoYZIs2%2FLCJcK0qTMOCK26Tl4FHzNbNKayguIgKJ2xhhGJ%2B7yuIX3Q2DxXkaetDTL23zjI0YbJqR60PgTlrOw8RrwaafGDBJ9jFF%2FB%2BhRkALkI6fEvenX3n9ArjAtte5967EDW7MbkpuCQRVDR%2Ft9LcJiaaijaU3istSO2W%2B2uziRAaj2UM5MrpA5kOwQ04u%2BbzXr2E88jUsN4bbJfzqMo4H7mvazJZUlS6BVHgWHa7t1Z8hHlAf%2BMCMb76wA%3D%3D",realm="eWallet";
User-Agent: base_sdk_version=1.2.0,lang_name=PHP,lang_version=5.6.30;
oauth_callback: mgmtdev.level4pay.com:7779/masterpass;

2017-05-31T14:52:58+00:00 ApiClient.php INFO Error Response Code : 403
2017-05-31T14:52:58+00:00 ApiClient.php DEBUG Response Information
https://sandbox.api.mastercard.com/oauth/consumer/v1/request_token
Response : Forbidden
Response Body : OAuth.TimestampINVALID_TIMESTAMPOauth timestamp is not validfalse
2017-05-31T14:52:58+00:00 ApiClient.php INFO Response Status : 403 ;Response : Forbidden

The code implemented so far follows:

`<?php
ini_set( 'display_errors','1');

include_once "logger/Logger.php";
Logger::configure("logger/config.xml");

include_once "vendor/autoload.php";
include_once 'phar://MasterCardCoreSDK.phar/index.php';
include_once 'phar://MasterCardMasterPassMerchant.phar/index.php';

$privateKey = "";
$keystore = array();
trim(openssl_pkcs12_read(file_get_contents('xxxxxxx.p12'), $keystore, 'xxxxxxx'));
$privateKey = $keystore['pkey'];

try
{
MasterCardApiConfig::$consumerKey = "xxxxxxxxxxxxxxxxx0000000000000000";
MasterCardApiConfig::$privateKey = $privateKey;
MasterCardApiConfig::setSandBox(true); // For sandbox environment else

$RequestTokenResponse = RequestTokenApi::create("http://mgmtdev.level4pay.com:7779/masterpass/");

//TODO: Merchant checkout SDK call.
}
catch(SDKErrorResponseException $e)
{
$errors = $e->errors;

foreach($errors as $error)
{
    echo "<br/>Description: " . $error->Description;
    echo "<br/>ReasonCode: " . $error->ReasonCode;
    echo "<br/>Source: " . $error->Source;
    echo "<br/>Response Code ". $e->code;
    echo "<br/>";
}

}
catch(SDKValidationException $e)
{
echo .$e->getMessage();
}
?>`

The $privateKey parameter is being successfully generated.

Sorry for translator's english.

Can you please help me?

Thank you.

Extra line ending character is returned when we include the core SDK phar file

Hi,

We are using the PHP SDK according to the documentation, but we see an extra character every time when we include the MasterCardCoreSDK.phar file. We are using the "2.1.0" version of the "masterpass/merchantcheckoutsdk" composer package (according to packagist and github this is the most recent published version). The extra character is a \r\n line ending character and it is coming from the index.php in the phar file.
You really shouldn't put the PHP closing tags in your PHP files otherwise you can easily face this issue.

The solution is very easy, just please remove the closing PHP tag from the index.php file. (the extra character is added after the closing tag at the moment)

Could you please fix ASAP? This is a very serious issue, because it starts to display the homepage body and it doesn't allow us to set any headers unless we are using output buffering. Also in an API environment displaying an extra character is not really allowed because of the API interfaces are strict.

Many thanks,
Norbert

Composer package not found

I tried to install with composer require, but without success.
The verbose message me with:

[InvalidArgumentException] Could not find package masterpass/mastercardcoresdk at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

Image of InvalidArgumentException

Multiple issues

Hi,
We try to use the code and was imposible since:

  • The code do not use of namespaces create a serious issue in the code compatibility with another code.
  • The code have explicit require/include like in XMLSerializer to user PEAR.php so using like a dependency do not work.
  • The model/Error cause a serious issue since the class Error is defined in PHP 7.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.