【问题标题】:How can I report the descripction in paypal from aplication android?如何从应用程序 android 报告贝宝中的描述?
【发布时间】:2014-09-30 12:10:51
【问题描述】:

我正在做一个安卓应用程序。我使用 PayPalPayment.class 与贝宝连接,我想报告她出售的描述,因为它出现在更多详细信息中。

我的部分代码:

PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("4.99"), "EUR", "Datos de contacto - "+pro.getTitulo());

Intent intent = new Intent(InfoProyecto.this, PaymentActivity.class);

intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
// It's important to repeat the clientId here so that the SDK has it if Android restarts your 
// app midway through the payment UI flow.
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "APP-80W284485P519543T");
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "your-customer-id-in-your-system");
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

startActivityForResult(intent, 0);

【问题讨论】:

    标签: android paypal


    【解决方案1】:

    试试这个方法

    Intent intent = new Intent(this, PayPalService.class);        
    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);        
    startService(intent);
    

    外面onCreate()

    public void onBuyPressed(View pressed) {
        Double amount=Double.parseDouble(Amount.toString());
    
        PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(String.valueOf(amount)), "NOK","ITEM_S");        
        Intent intent = new Intent(this, PaymentActivity.class);        
        intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
        intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
        intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
        intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
    
        startActivityForResult(intent, 0);
    }
    
    
    
    public void onBuyPressed(View pressed) {
        Double amount=Double.parseDouble(Amount.toString());
    
        PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(String.valueOf(amount)), "NOK","ITEM_S");        
        Intent intent = new Intent(this, PaymentActivity.class);        
        intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
        intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
        intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
        intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
    
        startActivityForResult(intent, 0);
    }
    
    @Override
    protected void onActivityResult (int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i("paymentExample", confirm.toJSONObject().toString(4));
    
    
                    JSONObject json=confirm.toJSONObject();
                    JSONObject payment=json.getJSONObject("payment");
                    String product=payment.getString("short_description");
                    String amount=payment.getString("amount").substring(0, 5);
                    String currency_code=payment.getString("currency_code");
                    //Toast.makeText(getBaseContext(), "Payment for "+product+" is done sucessfully. Amount of "+amount+" "+currency_code+" has been charged ..!!" , Toast.LENGTH_LONG).show();
                    tv.setText( getResources().getString(R.string.Payment_for)+product+""+getResources().getString(R.string.has_been_charge)+""+getResources().getString(R.string.Amount)+amount+
                            " "+currency_code+getResources().getString(R.string.has_been_charge));
                    new ACtivate_POST().execute();
                } catch (JSONException e) {
                    Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        }
        else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("paymentExample", "The user canceled.");
            Toast.makeText(this,"transaksjonen avbrutt.",Toast.LENGTH_LONG).show();
        }
        else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
            Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
            Toast.makeText(this,"En ugyldig betalingen ble sendt. Vennligst se docs.",Toast.LENGTH_LONG).show();
        }
    }
    

    【讨论】:

    • 感谢您的回答。现在,我怎样才能拿到“支付密钥”
    • @CarlosSierraGarcia 付款成功后您将获得Transaction ID(付款ID)
    猜你喜欢
    • 2015-05-26
    • 1970-01-01
    • 2013-10-15
    • 2014-06-25
    • 2014-11-29
    • 2011-06-14
    • 2011-01-04
    • 2021-10-10
    • 2013-03-16
    相关资源
    最近更新 更多