-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from wavedigital/master
CardIO integration
- Loading branch information
Showing
6 changed files
with
112 additions
and
5 deletions.
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Oct 21 11:34:03 PDT 2015 | ||
#Thu May 12 17:32:56 EST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip |
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
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
66 changes: 66 additions & 0 deletions
66
promisepay/src/main/java/com/github/promisepay/PromisePayScanActivity.java
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,66 @@ | ||
package com.github.promisepay; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import java.util.Locale; | ||
|
||
import io.card.payment.CardIOActivity; | ||
import io.card.payment.CreditCard; | ||
|
||
public class PromisePayScanActivity extends AppCompatActivity { | ||
|
||
private final static Integer MY_SCAN_REQUEST_CODE = 100; | ||
|
||
public static final String PROMISE_PAY_SCAN_RESULT = "au.com.promisepay.scanResult"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
startScan(); | ||
} | ||
|
||
private void startScan() { | ||
Intent scanIntent = new Intent(this, CardIOActivity.class); | ||
|
||
// customize these values to suit your needs. | ||
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false | ||
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true); // default: false | ||
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false | ||
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CARDHOLDER_NAME, true); // default: false | ||
scanIntent.putExtra(CardIOActivity.EXTRA_HIDE_CARDIO_LOGO, true); // default: false | ||
|
||
// MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. | ||
startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
|
||
if (requestCode == MY_SCAN_REQUEST_CODE) { | ||
if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { | ||
|
||
CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); | ||
|
||
PPCard card = new PPCard(scanResult.cardNumber, | ||
scanResult.cardholderName, | ||
String.format(Locale.getDefault(), "%d", scanResult.expiryMonth), | ||
String.format(Locale.getDefault(), "%d", scanResult.expiryMonth), | ||
scanResult.cvv); | ||
|
||
Intent intent = new Intent(); | ||
intent.putExtra(PromisePayScanActivity.PROMISE_PAY_SCAN_RESULT, card); | ||
setResult(Activity.RESULT_OK, intent); | ||
} | ||
else { | ||
setResult(Activity.RESULT_CANCELED); | ||
} | ||
} | ||
|
||
finish(); | ||
} | ||
|
||
} |