- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发一个应用程序,应用程序的需求是需要在线支付。
我想以印度货币(卢比)向店主支付我申请中的账单金额。我尝试了一个使用 MPL 的演示示例。
我创建了一个类:
public class MainActivity extends Activity implements OnClickListener {
private boolean _paypalLibraryInit = false;
final static public int PAYPAL_BUTTON_ID = 10001;
CheckoutButton launchPayPalButton;
public static String resultTitle;
public static String resultInfo;
public static String resultExtra;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initLibrary();
if (_paypalLibraryInit) {
showPayPalButton();
} else {
finish();
}
}
/** init method **/
public void initLibrary() {
PayPal pp = PayPal.getInstance();
if (pp == null) {
// This is the main initialization call that takes in your Context,
// the Application ID, and the server you would like to connect to.
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T",PayPal.ENV_SANDBOX);
// -- These are required settings.
pp.setLanguage("en_US"); // Sets the language for the library.
// --
// -- These are a few of the optional settings.
// Sets the fees payer. If there are fees for the transaction, this
// person will pay for them. Possible values are FEEPAYER_SENDER,
// FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and
// FEEPAYER_SECONDARYONLY.
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
// Set to true if the transaction will require shipping.
pp.setShippingEnabled(true);
// Dynamic Amount Calculation allows you to set tax and shipping
// amounts based on the user's shipping address. Shipping must be
// enabled for Dynamic Amount Calculation. This also requires you to
// create a class that implements PaymentAdjuster and Serializable.
pp.setDynamicAmountCalculationEnabled(false);
// --
_paypalLibraryInit = true;
}
}
private void showPayPalButton() {
// Generate the PayPal checkout button and save it for later use
PayPal pp = PayPal.getInstance();
launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_278x43,CheckoutButton.TEXT_PAY);
// Add the listener to the layout
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.bottomMargin = 10;
params.leftMargin= 50;
launchPayPalButton.setLayoutParams(params);
launchPayPalButton.setId(PAYPAL_BUTTON_ID);
// The OnClick listener for the checkout button
launchPayPalButton.setOnClickListener(this);
//((RelativeLayout) findViewById(R.id.RelativeLayout01)).addView(launchPayPalButton);
((RelativeLayout) findViewById(R.id.rl)).addView(launchPayPalButton);
}
@Override
public void onClick(View v) {
// Use our helper function to create the simple payment.
PayPalButtonClick(v);
// Use checkout to create our Intent.
// Intent checkoutIntent = PayPal.getInstance().checkout(payment, this,
// new ResultDelegate());
// Use the android's startActivityForResult() and pass in our Intent.
// This will start the library.
// startActivityForResult(checkoutIntent, request);
}
public void PayPalButtonClick(View arg0) {
// Create a basic PayPal payment
PayPalPayment payment = new PayPalPayment();
// Set the currency type
payment.setCurrencyType("USD");
// Set the recipient for the payment (can be a phone number)
payment.setRecipient("abc@gmail.com");
// Set the payment amount, excluding tax and shipping costs
payment.setSubtotal(new BigDecimal("1.0"));
// Set the payment type--his can be PAYMENT_TYPE_GOODS,
// PAYMENT_TYPE_SERVICE, PAYMENT_TYPE_PERSONAL, or PAYMENT_TYPE_NONE
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
// PayPalInvoiceData can contain tax and shipping amounts, and an
// ArrayList of PayPalInvoiceItem that you can fill out.
// These are not required for any transaction.
PayPalInvoiceData invoice = new PayPalInvoiceData();
// Set the tax amount
invoice.setTax(new BigDecimal("0"));
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this /*, new ResultDelegate()*/);
this.startActivityForResult(checkoutIntent, 1);
}
public void PayPalActivityResult(int requestCode, int resultCode, Intent intent) {
if(requestCode != 1)
return;
Toast.makeText(getApplicationContext(),resultTitle , Toast.LENGTH_SHORT).show();
}
}
结果委托(delegate)类为:
public class ResultDelegate implements PayPalResultDelegate, Serializable {
private static final long serialVersionUID = 10001L;
/**
* Notification that the payment has been completed successfully.
*
* @param payKey the pay key for the payment
* @param paymentStatus the status of the transaction
*/
public void onPaymentSucceeded(String payKey, String paymentStatus) {
MainActivity.resultTitle = "SUCCESS";
MainActivity.resultInfo = "You have successfully completed your transaction.";
MainActivity.resultExtra = "Key: " + payKey;
}
/**
* Notification that the payment has failed.
*
* @param paymentStatus the status of the transaction
* @param correlationID the correlationID for the transaction failure
* @param payKey the pay key for the payment
* @param errorID the ID of the error that occurred
* @param errorMessage the error message for the error that occurred
*/
public void onPaymentFailed(String paymentStatus, String correlationID,
String payKey, String errorID, String errorMessage) {
MainActivity.resultTitle = "FAILURE";
MainActivity.resultInfo = errorMessage;
MainActivity.resultExtra = "Error ID: " + errorID + "\nCorrelation ID: "
+ correlationID + "\nPay Key: " + payKey;
}
/**
* Notification that the payment was canceled.
*
* @param paymentStatus the status of the transaction
*/
public void onPaymentCanceled(String paymentStatus) {
MainActivity.resultTitle = "CANCELED";
MainActivity.resultInfo = "The transaction has been cancelled.";
MainActivity.resultExtra = "";
}
}
同时下载了 Paypal_MPL.jar 文件并导入到应用程序中并创建了一个 paypal 个人帐户。
<强>1。现在的问题是如何测试应用程序?
<强>2。我在正确的轨道上吗?
<强>3。我还需要做什么?
我不清楚实现 MPL 的步骤以及如何在 Paypal 上创建帐户、测试帐户、将帐户链接到应用程序等。
请建议我并指导我。
最佳答案
http://www.androiddevelopersolution.com/2012/09/paypal-integration-in-android.html我希望这能帮到您 。要测试应用程序,您可以检查结果 Activity
关于安卓 : Paypal implementation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18098634/
我经常在 C 标准文档中看到“实现定义”的说法,并且非常将其作为答案。 然后我在 C99 标准中搜索它,并且: ISO/IEC 9899/1999 (C99) 中第 §3.12 条规定: 3.12 I
“依赖于实现”中的“实现”是什么意思? “依赖于实现”和“依赖于机器”之间有什么区别? 我使用C,所以你可以用C解释它。 最佳答案 当 C 标准讨论实现时,它指的是 C 语言的实现。因此,C 的实现就
我刚刚在 Android-studio 中导入了我的项目,并试图在其中创建一个新的 Activity。但我无法在 android-studio 中创建 Activity 。我指的是here我看不到将目
我想知道您对为什么会发生此错误的意见。在陆上生产环境中,我们使用 CDH4。在我们的本地测试环境中,我们只使用 Apache Hadoop v2.2.0。当我运行在 CDH4 上编译的同一个 jar
我正在尝试集成第三方 SDK (DeepAR)。但是当我构建它时,它会显示一个错误。我试图修复它。如果我创建一个简单的新项目,它就可以正常工作。但是我现有的应用程序我使用相机和 ndk。请帮我找出错误
我很好奇为什么我们有 @Overrides 注释,但接口(interface)没有类似的习惯用法(例如 @Implements 或 @Implementation)。这似乎是一个有用的功能,因为您可能
我对 DAODatabase(适用于 Oracle 11 xe)的 CRUD 方法的实现感到困惑。问题是,在通常存储到 Map 集合的情况下,“U”方法(更新)会插入新元素或更新它(像 ID:Abst
Java-API 告诉我特定类实现了哪些接口(interface)。但有两种不同类型的信息,我不太确定这意味着什么。例如,对于“TreeSet”类:https://docs.oracle.com/en
我有一个接口(interface) MLService,它具有与机器学习算法的训练和交叉验证相关的基本方法,我必须添加两个接口(interface)分类和预测,它们将实现 MLService 并包含根
我一直想知道如何最好地为所有实现相同接口(interface)的类系列实现 equals()(并且客户端应该只使用所述接口(interface)并且永远不知道实现类)。 我还没有编写自己的具体示例,但
我有一个接口(interface)及其 2 个或更多实现, public interface IProcessor { default void method1() { //logic
我有同一个应用程序的免费版和高级版(几乎相同的代码,相同的类,到处都是“if”, list 中的不同包, list 中的进程名称相同)。主要 Activity 使用 IMPLICIT Intent 调
这是我为我的应用程序中的错误部分编写的代码 - (id)initWithData:(NSData *)data <-------- options:(NSUInteger)opti
请查找随附的代码片段。我正在使用此代码将文件从 hdfs 下载到我的本地文件系统 - Configuration conf = new Configuration(); FileSys
我想在 MongoDB 中使用 Grails2.5 中的“ElasticSearch”插件。我的“BuildConfig.groovy”文件是: grails.servlet.version = "3
我收到一条错误消息: fatal error: init(coder:) has not been implemented 对于我的自定义 UITableViewCell。该单元格未注册,在 Stor
得到这个错误 kotlin.NotImplementedError: An operation is not implemented: not implemented 我正在实现一个 ImageBut
typedef int Element; typedef struct { Element *stack; int max_size; int top; } Stack; //
Playground 代码 here 例子: interface IFoo { bar: number; foo?: () => void; } abstract class Abst
我想知道如何抑制警告: Category is implementing a method which will also be implemented by its primary class. 我
我是一名优秀的程序员,十分优秀!