flutter_ravepay
flutter_ravepay copied to clipboard
Switching from stripe payment gateway to flutter_ravepay on Android
I want to change from stripe payment gateway to flutter_ravepay, though I have try a lot of way but all to no vail.
Thanks.
public class PaymentActivity extends AppCompatActivity {
private String restaurantId, address, orderDetails;
private Button buttonPlaceOrder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment);
getSupportActionBar().setTitle("");
// Get Order Data
Intent intent = getIntent();
restaurantId = intent.getStringExtra("restaurantId");
address = intent.getStringExtra("address");
orderDetails = intent.getStringExtra("orderDetails");
final CardInputWidget mCardInputWidget = (CardInputWidget) findViewById(R.id.card_input_widget);
buttonPlaceOrder = (Button) findViewById(R.id.button_place_order);
buttonPlaceOrder.setOnClickListener(new View.OnClickListener() {
@SuppressLint("StaticFieldLeak")
@Override
public void onClick(View view) {
final Card card = mCardInputWidget.getCard();
if (card == null) {
// Do not continue token creation.
Toast.makeText(getApplicationContext(), "Card cannot be blank", Toast.LENGTH_LONG).show();
} else {
// Disable the Place Order Button
setButtonPlaceOrder("LOADING...", false);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
Stripe stripe = new Stripe(getApplicationContext(), "STRIPE API KEY HERE");
stripe.createToken(
card,
new TokenCallback() {
public void onSuccess(Token token) {
// Make an order
//Toast.makeText(getApplicationContext(), token.getId(), Toast.LENGTH_LONG).show();
addOrder(token.getId());
}
public void onError(Exception error) {
// Show localized error message
Toast.makeText(getApplicationContext(),
error.getLocalizedMessage(),
Toast.LENGTH_LONG
).show();
// Enable the Place Order Button
setButtonPlaceOrder("PLACE ORDER", true);
}
}
);
return null;
}
}.execute();
}
}
});
}