#Emile

1 messages · Page 1 of 1 (latest)

jovial deltaBOT
grim storm
#

Sounds like you're working with Apple Pay tokens directly?

#

You need to create a Stripe tok_xxx from that token

wanton urchin
#

So in your own stripe SDK is that what happens? On google i get back an object {tok:"tok_123"} and i can pass that into stripe and create a succes resposne. From apple though i get the encrypted token, and i'm not sure what to do with that.

#
ApplePayToken(version: EC_v1, data: blahblah, header: ApplePayTokenHeader(ephemeralPublicKey: blahblah/blahblah==, publicKeyHash: blahblah, transactionId: ebablahblah6d2469f0169f1c8b74c1blahblah32))

I get this.

grim storm
#

This is largely undocumented, so its a bit it off piste

wanton urchin
#

this is my life on my project, thanks for the link.

wanton urchin
#
export const createStripeToken = function (incoming:any): Promise<Stripe.Token> {
    return new Promise<Stripe.Token>(async (resolve, reject) => {
        try {
            const Stripe_clientID = await getSecret1(`projects/${process.env.GCLOUD_PROJECT}/secrets/stripe_api_key/versions/latest`);
            const stripe = new Stripe(Stripe_clientID, {
                apiVersion: "2022-08-01",
            });
            logger.info(`putStripePayment(${incoming}). `);
            const tokenPayload = {
                card:{
                    name:"",
                    number:"",
                    exp_month:"",
                    exp_year:"",
                },
                pk_token_instrument_name : incoming.paymentMethod.displayName,
                pk_token_transaction_id : incoming.transactionIdentifier,
                pk_token_payment_network : incoming.paymentMethod.network,
                pk_token : incoming.token,
            }
            const token = await stripe.tokens.create(tokenPayload as any);

            resolve(token);
        } catch (error) {
            reject(error);
        }
    });
};
#

So close yet so far. I'm not convinced i'm passing the correct parameters. Any suggestions? I don't get billAddress or billContact from the payment details.

#
{
    token: {
        "version": "EC_v1",
            "data": "asdasdasdasd",
            "signature": "asdasd",
            "header": {
            "ephemeralPublicKey": "asdasd",
                "publicKeyHash": "Sa+asd=",
                "transactionId": "asd"
        }
    },
    paymentMethod: {network: "MasterCard", type: 1, displayName: "MasterCard asd"},
    transactionIdentifier: "asd"
}
remote helm
#

it overall would look like this

curl -u sk_test_123: https://api.stripe.com/v1/tokens \
  -d pk_token=<PKPaymentToken.paymentData decoded as JSON> \
  -d pk_token_instrument_name=<PKPaymentToken.paymentInstrumentName> \
  -d pk_token_payment_network=<PKPaymentToken.paymentNetwork> \
  -d pk_token_transaction_id=<PKPaymentToken.transactionIdentifier>
#

another example here

Map<String, Object> card = new HashMap<>();
card.put("pk_token", "\"data\": \"V4Ua.... \"version\": \"EC_v1\"}");//a string of the paymentData JSON object 
card.put("pk_token_instrument_name", "MasterCard 1471");//paymentMethod.displayName
card.put("pk_token_payment_network", "MasterCard");//paymentMethod.network
card.put("pk_token_transaction_id", "38A74D639B946C2B4D2CE65CC463BDB5EF6046A40BECD505C5E21B4A1F654C5D"); //transactionIdentifier
Map<String, Object> params = new HashMap<>();
params.put("card", card);
Token token = Token.create(params);
#

feel free to share things like the failed req_xx request IDs of your attempts and I can tell you what's wrong with them

wanton urchin
#

oh way, the pk_/?? is on the card ojbect. Doh.

#

it didn't like that. calling stripe.token.create ( {card : {pk_token:"" etc}})

#
Error: Received unknown parameters: pk_token_instrument_name, pk_token_payment_network, pk_token_transaction_id

remote helm
#

it's not inside card, they're top level params

#

my Java code is wrong, sorry about that

wanton urchin
#

np.

#

ok, so i think this is actually working . the card i'm using is wrong but i'm getting a response. Thanks.