开发索引
安卓篇

MGM Money 安卓端 集成流程

第一步:搭建开发环境
1. 在Android Studio创建您的Android应用工程
2. 在工程中添加Java资源文件夹resources\libs,将mgmpaylibrary.aar复制到该文件夹中。
3. 在build.gradle中添加以下代码:

		repositories {
		    flatDir {
		        dirs 'libs'
		    }
		}
		implementation(name:'mgmpaylibrary', ext:'aar')
				        
第二步:使用MGMPay支付
1. 在您想调起支付页面的代码中加入如下代码

		//创建MGMPay对象
		MGMPay mgmPay = new MGMPay(MainActivity.this);
		//调起支付页面
		mgmPay.pay(price, orderString, new MGMPayResultCallback() {
		    @Override
		    public void paySuccess() {
		        Log.d(Constant.TAG, "suc");
		      }

		    @Override
		    public void payFailed(String code, String errorMsg) {
		        Log.d(Constant.TAG, "code:".concat(code).concat("   msg:").concat(errorMsg));

		    }
		});

				        
2.api介绍

		/**
		 *@Param price 商品价格
		 *@param orderString 后台返还的拼接字符串 里面包含appid、appkey、订单号等信息
		 *@callback 返回支付的成功/失败的回调
		 *
		 **/
		public synchronized void pay(float price ,String orderString, MGMPayResultCallback callback);

		public interface MGMPayResultCallback {
		    void paySuccess();//成功

		    void payFailed(String code/*错误码*/, String errorMsg/*错误信息*/);//失败
		}


				        

Processus d'intégration Android MGM Money

Première étape:Créer un environnement de dévéloppement.
1. Créez votre projet d'application Android dans Android Studio.
2. Ajoutez un dossier de ressource resources\libs Java dans votre projet,copiez mgmpaylibrary.aar dans le dossier.
3.Dans build.gradle ajoutez le code source suivant:

		repositories {
		    flatDir {
		        dirs 'libs'
		    }
		}
		implementation(name:'mgmpaylibrary', ext:'aar')
				        
Deuxième étape:Utiliser le paiement MGMPay
1.Ajoutez le code source suivant dans la page de paiement que vous souhaiteriez adapter

		//Créer un objet MGMPay
		MGMPay mgmPay = new MGMPay(MainActivity.this);
		//Adapter la page de paiement
		mgmPay.pay(price, orderString, new MGMPayResultCallback() {
		    @Override
		    public void paySuccess() {
		        Log.d(Constant.TAG, "suc");
		      }

		    @Override
		    public void payFailed(String code, String errorMsg) {
		        Log.d(Constant.TAG, "code:".concat(code).concat("   msg:").concat(errorMsg));

		    }
		});

				        
2.Introduction à l'API

		/**
		 *@Param price //Prix du produit
		 *@param orderString //La chaîne de caractère renvoyé par l'arrière-plan contient l'appid、appkey、Numéro de commande et autres informations
		 *@callback Retour //de paiement réussi/Retour de paiement échoué.
		 *
		 **/
		public synchronized void pay(float price ,String orderString, MGMPayResultCallback callback);

		public interface MGMPayResultCallback {
		    void paySuccess();//Réussi

		    void payFailed(String code/*Code d'erreur*/, String errorMsg/*Message d'erreur*/);//Echèc
		}


				        

MGM Money Android Integration process

First step:Create a development environment
1.Create an Android project in Android Studio
2. Add a Java resources folder resources\libs to your project,and copy mgmpaylibrary.aar to the folder
3. Add the following source code in build.gradle:

		repositories {
		    flatDir {
		        dirs 'libs'
		    }
		}
		implementation(name:'mgmpaylibrary', ext:'aar')
				        
Second step:Use MGMPay payment
1. Add the following source code in the payment page that you would like to adapt

		//Create an object MGMPay
		MGMPay mgmPay = new MGMPay(MainActivity.this);
		//Adapt payment page
		mgmPay.pay(price, orderString, new MGMPayResultCallback() {
		    @Override
		    public void paySuccess() {
		        Log.d(Constant.TAG, "suc");
		      }

		    @Override
		    public void payFailed(String code, String errorMsg) {
		        Log.d(Constant.TAG, "code:".concat(code).concat("   msg:").concat(errorMsg));

		    }
		});

				        
2.API introduction

		/**
		 *@Param price //Price
		 *@param orderString //The string returned by the background contains the appid、appkey、Order no.and other information
		 *@callback Successful //payment return/Failed payment return
		 *
		 **/
		public synchronized void pay(float price ,String orderString, MGMPayResultCallback callback);

		public interface MGMPayResultCallback {
		    void paySuccess();//Successful

		    void payFailed(String code/*Error code*/, String errorMsg/*Error message*/);//Failed
		}