ZarinPal / Android-SDK

ZarinPal Android Client in-App Billing
13 stars 7 forks source link

بازگشت اطلاعات #18

Closed merfi1 closed 1 year ago

merfi1 commented 1 year ago

سلام من همه این کارا رو انجام دادم خرید هم انجام میشه ولی اطلاعات خرید به داخل اپ برگشت داده نمیشه باید چیکار کنم لطفا راهنمایی کنید ممنون

ImanX commented 1 year ago

سلام میشه بگید از چه نسخه‌ای استفاده میکنید؟

merfi1 commented 1 year ago

سلام بله نسخه zarinpalSdkVersion = "0.5.3"

merfi1 commented 1 year ago

اینا رو اضافه کردم implementation 'com.zarinpal:payment-provider:'+ project.ext.zarinpalSdkVersion implementation 'com.zarinpal:mpg:' +project.ext.zarinpalSdkVersion

توی منیفست از این کد برای برگشت اطلاعات

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="retuern" android:host="zarinpalpayment"/>

اینم کل متد payment

private void payment(long price){

BillingClientStateListener listener = new BillingClientStateListener() {
  @Override
  public void onClientSetupFinished(@NotNull ClientState state) {
    //Observing client states

  }

  @Override
  public void onClientServiceDisconnected() {
    Log.v("TAG_INAPP","Billing client Disconnected");
    //When Service disconnect
  }
};

ZarinPalBillingClient client = ZarinPalBillingClient.newBuilder(this)
  .enableShowInvoice()
  .setListener(listener)
  .setNightMode(AppCompatDelegate.MODE_NIGHT_NO)
  .build();

String merchantId = "------------------------------------";
long amount = price;
String description = "حمایت و خرید نرم افزار حسابداری آلفا";
String callback = "retuern://zarinpalpayment";

Purchase purchase = Purchase.newBuilder().asPaymentRequest(merchantId, amount, callback, description).build();

client.launchBillingFlow(purchase, task -> {
  if (task.isSuccess()) {
    Receipt receipt = task.getSuccess();
    Log.v("ZP_RECEIPT", receipt.getTransactionID());
    Toast.makeText(this, ""+receipt.getTransactionID(), Toast.LENGTH_SHORT).show();
    txtRes.setText(receipt.getTransactionID());

    //here you can send receipt data to your server
    //sentToServer(receipt)

  } else {
    task.getFailure().printStackTrace();
    Toast.makeText(this, "kkkkkkkkk", Toast.LENGTH_SHORT).show();
  }
});

}

merfi1 commented 1 year ago

چی شد؟؟

ImanX commented 1 year ago

https://github.com/ZarinPal/Android-SDK/releases/tag/0.6.1