-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da2de26
commit aa3181f
Showing
3 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ti.stripe; | ||
|
||
import com.stripe.android.EphemeralKeyProvider; | ||
import com.stripe.android.EphemeralKeyUpdateListener; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class TiEphemeralKeyProvider implements EphemeralKeyProvider { | ||
|
||
@Override | ||
public void createEphemeralKey(@NotNull String apiVersion, @NotNull EphemeralKeyUpdateListener ephemeralKeyUpdateListener) { | ||
// TODO: Add a HTTP request here and use the backend API info (url) | ||
// via a module property | ||
ephemeralKeyUpdateListener.onKeyUpdate("<TEST>"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package ti.stripe; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
|
||
import com.stripe.android.PaymentSession; | ||
import com.stripe.android.PaymentSessionConfig; | ||
import com.stripe.android.PaymentSessionData; | ||
import com.stripe.android.model.PaymentMethod; | ||
import com.stripe.android.model.ShippingInformation; | ||
|
||
public class TiHostActivity extends Activity { | ||
private PaymentSession paymentSession; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// This currently does not work?! | ||
/*paymentSession = new PaymentSession( | ||
this, | ||
new PaymentSessionConfig.Builder() | ||
.setShouldPrefetchCustomer(true) | ||
.setShippingInfoRequired(false) | ||
.setShippingMethodsRequired(false) | ||
.build() | ||
);*/ | ||
setupPaymentSession(); | ||
} | ||
|
||
private void setupPaymentSession() { | ||
paymentSession.init( | ||
new PaymentSession.PaymentSessionListener() { | ||
@Override | ||
public void onCommunicatingStateChanged(boolean isCommunicating) { | ||
// update UI, such as hiding or showing a progress bar | ||
} | ||
|
||
@Override | ||
public void onError(int errorCode, String errorMessage) { | ||
// handle error | ||
} | ||
|
||
@Override | ||
public void onPaymentSessionDataChanged(PaymentSessionData data) { | ||
final PaymentMethod paymentMethod = data.getPaymentMethod(); | ||
// use paymentMethod | ||
} | ||
} | ||
); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
if (data != null) { | ||
paymentSession.handlePaymentData(requestCode, resultCode, data); | ||
} | ||
} | ||
|
||
private ShippingInformation getDefaultShippingInfo() { | ||
// optionally specify default shipping address | ||
return new ShippingInformation(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters