但是我得到的屏幕上写着"哎呀!付款失败"点击start_transaction按钮后。有人可以帮忙吗?我没有在下面的代码中包含paytm给我的登台凭据。
package in.wishup.assistant.fragments.PaymentDialogFragments;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import android.app.Activity;
import android.app.DialogFragment;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import butterknife.Bind;
import in.wishup.assistant.R;
import com.paytm.pgsdk.PaytmClientCertificate;
import com.paytm.pgsdk.PaytmMerchant;
import com.paytm.pgsdk.PaytmOrder;
import com.paytm.pgsdk.PaytmPGService;
import com.paytm.pgsdk.PaytmPaymentTransactionCallback;
/**
* Created by DELL on 7/4/2016.
*/
public class PaytmFragment extends DialogFragment implements View.OnClickListener {
private Context mContext;
Button btn_pay;
public PaytmFragment()
{}
public PaytmFragment(Context mContext)
{
this.mContext=mContext;
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.test, container, false);
btn_pay = (Button) rootView.findViewById(R.id.start_transaction);
//setListeners();
btn_pay.setOnClickListener(this);
return rootView;
}
public void onClick(View v) {
switch (v.getId()){
case R.id.start_transaction : Log.d("paytm","button pressed");
pay();
break;
}
}
private void pay()
{
Log.d("paytm","inside pay");
//Getting the Service Instance. PaytmPGService.getStagingService() will return the Service pointing to Staging Environment and PaytmPGService.getProductionService() will return the Service pointing to Production Environment.
PaytmPGService Service = null;
Service = PaytmPGService.getStagingService();
//or
Service = PaytmPGService.getProductionService();
//Create new order Object having all order information.
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("REQUEST_TYPE", "DEFAULT");
paramMap.put("ORDER_ID", "ORDER12350");
paramMap.put("MID", "xxxxx");
paramMap.put("CUST_ID","CUST110");
paramMap.put("CHANNEL_ID", "WAP");
paramMap.put("INDUSTRY_TYPE_ID", "Retail");
paramMap.put("WEBSITE", "paytm");
paramMap.put("TXN_AMOUNT", "1.0");
paramMap.put("THEME ", "merchant");
paramMap.put("EMAIL","xxx");
paramMap.put("MOBILE_NO","7777777777");
PaytmOrder Order = new PaytmOrder(paramMap);
//Create new Merchant Object having all merchant configuration.
PaytmMerchant Merchant = new PaytmMerchant( "https://pguat.paytm.com/paytmchecksum/paytmCheckSumGenerator.jsp", "https://pguat.paytm.com/paytmchecksum/paytmCheckSumVerify.jsp");
//Set PaytmOrder and PaytmMerchant objects. Call this method and set both objects before starting transaction.
Service.initialize(Order, Merchant, null);
//Start the Payment Transaction. Before starting the transaction ensure that initialize method is called.
Service.startPaymentTransaction(mContext, true, true, new PaytmPaymentTransactionCallback()
{
@Override
public void onBackPressedCancelTransaction() {
// TODO Auto-generated method stub
}
@Override
public void someUIErrorOccurred(String inErrorMessage)
{
// Some UI Error Occurred in Payment Gateway Activity.
// This may be due to initialization of views in Payment Gateway Activity or may be due to initialization of webview.
// Error Message details the error occurred.
Toast.makeText(mContext,"Some UI error occurred",Toast.LENGTH_LONG);
}
@Override
public void onTransactionSuccess(Bundle inResponse)
{
// After successful transaction this method gets called.
// Response bundle contains the merchant response parameters.
Toast.makeText(mContext,"Transaction successful",Toast.LENGTH_LONG);
}
@Override
public void onTransactionFailure(String inErrorMessage, Bundle inResponse)
{
// This method gets called if transaction failed.
// Here in this case transaction is completed, but with a failure.
// Error Message describes the reason for failure.
// Response bundle contains the merchant response parameters.
Toast.makeText(mContext,"Transaction failure",Toast.LENGTH_LONG);
}
@Override
public void networkNotAvailable()
{
// If network is not available, then this method gets called.
Toast.makeText(mContext,"Network not available",Toast.LENGTH_LONG);
}
@Override
public void clientAuthenticationFailed(String inErrorMessage)
{
// This method gets called if client authentication failed.
// Failure may be due to following reasons
// 1. Server error or downtime.
// 2. Server unable to generate checksum or checksum response is
// not in proper format.
// 3. Server failed to authenticate that client. That is value of
// payt_STATUS is 2.
// Error Message describes the reason for failure.
Toast.makeText(mContext,"Client authentication failed",Toast.LENGTH_LONG);
}
@Override
public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingURL)
{
// This page gets called if some error occurred while loading some URL in Webview.
// Error Code and Error Message describes the error.
// Failing URL is the URL that failed to load.
Toast.makeText(mContext,"Error loading webpage",Toast.LENGTH_LONG);
}
});
}
}
这就是我创建这个类的对象的地方:
FragmentManager fm2=getFragmentManager();
Log.d("paytm","made it inside paytm!!");
PaytmFragment paytmFragment=new PaytmFragment(mContext);
paytmFragment.show(fm2,null);
答案 0 :(得分:0)
你忘记了这些值 -
paramMap.put("MID", "xxxxx");
paramMap.put("EMAIL","xxx");
paramMap.put("INDUSTRY_TYPE_ID", "xxxxx");
您的网站价值看起来是默认的,请使用您从paytm获得的值替换这些值。 并删除此行 -
Service = PaytmPGService.getProductionService();
用于制作,当您将应用发布到Play商店时。
希望它会有所帮助:)